I want to display some data through the datalist component. For this, I have an arrayList, for example ArrayList<Person>.
A person's class looks something like this:
class Person{
private String name;
private String age;
private ArrayList<String> hobbies;
}
To display the data, I use the following code:
<p:dataList value="{gameBean.persons}" var="person" itemType="disc">
Name: #{person.getName()}, Age: #{person.getAge()},
<h:link value="Hobbies" onclick="dlg1.show();" />
</p:dataList>
Now I want to do to create a link that opens a dialog when clicked:
<p:dialog header="Hobbies" widgetVar="dlg1" modal="true"height="100">
//iterate through hobbies list to print it
</p:dialog>
So far this works, because I hardcoded the dialog, as mentioned above, in the xhtml file.
This method, of course, does not work for a dynamic number of people, since I cannot hard-code dialogs and links. My question is: how can I create these dialogs programmatically and assign the correct widgetVar variable to the onClick method for links?
Any help is extremely limited, greetings of Nikolaus
source