0

I am making a JSF project on eclipse neon using JSF 2.0, Primefaces and Bootsfaces components. Even though I am able to create the output and put it inside an arraylist, I am having hard time displaying that arraylist on datatable. Here is my Bean:

@ManagedBean
@SessionScoped
public class FinalList implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    List<ListElements> newList = new ArrayList<>();

    public List<ListElements> getResultList(String url, String title) {

        ListElements list = new ListElements();
        list.setUrl(url);
        list.setTitle(title);
        newList.add(list);
        return newList;

    }

}

Here is the contents of my List:

public class ListElements implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 
     */
    private String Title;
    private String Url;


    public String getTitle() {
        return Title;
    }

    public void setTitle(String title) {
        Title = title;
    }

    public String getUrl() {
        return Url;
    }

    public void setUrl(String url) {
        Url = url;
    }
}

Here is my datatable on .xhtml page:

<h:form>
            <b:dataTable id="datatbl" value="#{finalList.class}" var="d"
                excel="true" csv="true" pdf="true" columnVisibility="true"
                copy="true" print="true">
                <b:dataTableColumn value="#{d.url}" />
                <b:dataTableColumn value="#{d.title}" />
            </b:dataTable>
</h:form>

Appearently I am not able to reach my ListElements list. If I try to change value="#{finalList.class}" with anything else , I get

list cannot be resolved as a member of finalList

error. I think I should be able to change it as value="#{finalList.list}". Can someone tell me where I go wrong?

I have tried every way I know but nothing changed. I desperately need help. All help will be appreciated.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
KontrCode
  • 89
  • 11
  • why are you starting with jsf 2.0? That is prehistoric... – Kukeltje May 07 '18 at 20:19
  • which one should I use? jsf 2.0 must be enough for such task. What do you recommend? – KontrCode May 07 '18 at 20:38
  • I have switched it to version 2.2.4. Still getting the same error. What else can I do sir? – KontrCode May 07 '18 at 21:01
  • tried .results instead of .class? – Kukeltje May 08 '18 at 05:40
  • and please read https://stackoverflow.com/questions/2090033/why-jsf-calls-getters-multiple-times – Kukeltje May 08 '18 at 05:52
  • I just did try `.results` and nothing changed. I get `The class 'com.ey.ilter.controller.FinalList' does not have the property 'results'` error. I am thinking of putting my arraylist into db and fetching data from that db using preparedstatement. Do you think this would work? – KontrCode May 08 '18 at 06:28
  • A db won't solve anything... If the EL cannot find the getter, trying to get the content from somewhere else won't help at all. And the `.result` I mentioned should have been `.resultList`... I just HOPE you did try that one since it is THE one to use.... – Kukeltje May 08 '18 at 06:38
  • Oh wait, not even that one... You don't seem to have ANY getter for the list... None... Please take a step back and start with a basic JSF tutorial... – Kukeltje May 08 '18 at 06:43
  • Yes you were right. It was caused by missing getter setter for list so now I have `value="#{finalList.list}"`. I feel I am almost done with it. Now I need to call title and url. Could `` work or should it be in `` format. By the way that you for all your help, you already helped me a lot. – KontrCode May 08 '18 at 07:06
  • It should be the latter, `d.title`, assuming in the end you want to iterate over mulitple items in a list.., but please take a step back to read some tutorials... You really missed the basics of JSF developement and even java web developement in a sense... – Kukeltje May 08 '18 at 07:11

0 Answers0