0

I have 2 arraylists inside an outer arrayList on JSF as follows:

private List<ArrayList<String>> newList; which contains private List<String> urlx and private List<String> titlex

and this is how I added them into newList:

newList.add((ArrayList<String>) urlx);
newList.add((ArrayList<String>) titlex);

My xhtml code is as follows:

<p:dataTable var="car" value="#{MyBean.newList}">
                <p:column headerText="Title">
                    <h:outputText value="#{car.xxxx}" />
                </p:column>

                <p:column headerText="Url">
                    <h:outputText value="#{car.xxxx}" />
                </p:column>
</p:dataTable>

Does anyone know how I can populate Title and Url columns on my datatable using urlx and titlex lists? Urlx and titlex both contains elements that are in type of strings.

KontrCode
  • 89
  • 11
  • 1
    Read this [XY Problem](http://xyproblem.info) and see if it is your case. I'm asking that because what you are asking is not making much of a sense in terms of showing a data. – Jorge Campos May 08 '18 at 21:28
  • You Probably need an entity like `class SomeEntity{ String Tile; String url }` and in your bean `List list = new ArrayList<>()`; and only then in your datatable ` ..... //same for url` – Jorge Campos May 08 '18 at 21:32
  • My full code is too long to paste in here so, I wanted to be as brief as possible. I just need to print two arrays that are inside an arraylist onto a datatable but nothing is displayed on datatable after running my code basically shown as above. – KontrCode May 08 '18 at 21:34
  • 2
    Your code makes no sense with your datatable request... you are filling two complete distinct lists (texts and urls) and trying to fetch both at same time in your xhtml file. Although both are strings and your new list object can be fetched in the xhtml it has absolutely no way to know which is an url or a title (because everything inside is just Strings). – Jorge Campos May 08 '18 at 21:37
  • @JorgeCampos thank you for the ideas. Even though I have created an entity like `class SomeEntity{ String Tile; String url }` before which did not work, I will give it another try. Could the reason why my code is not working be that I am using a bean class which is extended by another bean without using `@ManagedProperty("#{myBean}")`? – KontrCode May 09 '18 at 05:29
  • 1
    Here, read this: https://stackoverflow.com/q/6627384/460557 – Jorge Campos May 09 '18 at 12:55
  • Thank you for all your help Sir. – KontrCode May 09 '18 at 13:01
  • Your are welcome! – Jorge Campos May 09 '18 at 13:03

0 Answers0