Board index JavaServer Faces General How to dynamically generate content of Drop Down List

How to dynamically generate content of Drop Down List

Components, Ajax Framework, Utilities and More.


Posts: 280
I am very new to JSF and PrimeFace. So please forgive my ignorance if the answer to the question is too obvious. I have couple Drop down list on my page. The contents of the drop down list are populated when the page is loaded. As I select the item in that first drop down list, content of the second drop down list get populated. How can I do that with JSF + PrimeFace. Sample code would be greatly appreciated


Posts: 768
Hi,

There's an example in the PrimeFaces showcase that would be a good start. I can't link you to the online demo at the moment because the demo server appears to be down and I don't have the required URL in my head!

You can download the entire showcase from the download page http://www.primefaces.org/downloads.html

The xhtml file to look at is pprSelect.xhtml
The corrseponding bean is in PPRBean.java

pprSelect.xhtml has two <h:selectOneMenu> tags called "city" and "suburbs" that do what you want to do.


Posts: 15051
Location: Cybertron

PrimeFaces Lead


Posts: 280
Thank you so much. I will take a look at it.

Mojarra 2.1.10, Glassfish 3.1, Tomcat 7, Primeface 3.3.1
IE 6-8, FireFox 10-13
MAC OSX Lion, Windows XP, 7


Posts: 13
Any hints on how to style these a little better?


Posts: 13
Actually never mind about that. I got busy with the CSS and prettified it.

I do wonder about styling these sorts of components (jsf/html) in general. For example the datatable's row cardinality selector. It looks a little naff compared to the other controls.


Return to General