0

Its been quite some time since i have started developing web pages using JSF but i am still learning most of the stuff. Now I have an interesting question

When I have the values those to be displayed in a data table in the ArrayList and I am adding those ArrayList objects in another array list , so now how will i be able to display them in a data table.

I am doing this since , i need my table to be so dynamic so that i dont know how many columns will i be getting in the result set to be displayed in the page, hece i cannot have a Bean obj for storing my variable values. So i have decided to have something like

ArrayList<ArrayList<String>>

ArrayList<String> - Values for Each row

Does this have a solution that can be provided int he jsf page

1 Answer 1

1

Use either plain HTML with a nested <ui:repeat>

<table>
    <ui:repeat value="#{bean.rows}" var="row">
        <tr>
            <ui:repeat value="#{row}" var="column">
                <td>#{column}</td>
            </ui:repeat>
        </tr>
    </ui:repeat>
</table>

or grab a 3rd party component library which has sort of a <x:columns> tag like PrimeFaces with <p:columns> and Tomahawk with <t:columns>.

<p:dataTable value="#{bean.rows}" var="row">
    <p:columns value="#{row}" var="column">
        #{column}
    </p:columns>
</p:dataTable>

Either way, you can even keep the columns in a separate list.

Sign up to request clarification or add additional context in comments.

1 Comment

Now will i be able to insert a checkbox in the columns so that for those rows the user selects i can take the action

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.