jsf 2 - retrive value from collection and show in datatable -
i want show language in view_lang.xhtml using datatable,below classes
countrybean.java
private arraylist<country> existingcountrylist; public arraylist<country> getexistingcountrylist() { system.out.println("countrybean.getexistingcountrylist::enter"); existingcountrylist = new arraylist<country>(); existingcountrylist.addall(getcountryservice().getexistingcountry()); system.out.println("existingcountrylist in countrybean"+existingcountrylist); system.out.println("countrybean.getexistingcountrylist:::exit"); return existingcountrylist; }
country.java
private set<countrylanguage> countrylanguage = new hashset<countrylanguage>(0);
countrylanguage.java
private countrylanguageid countrylangpk = new countrylanguageid();
countrylanguageid.java
private country country; private language language;
view_lang.xhtml
<h:datatable id="existingcountry" var="countrylang" value="#{countrybean.existingcountrylist}" style="width: 100%" cellpadding="0" cellspacing="1" border="0" class="role_detail_section" rowclasses="activity_white, activity_blue"> <h:column> <f:facet name="header"> <h:outputtext value="language(code)" styleclass="heading_pm_det_white"/> </f:facet> <h:outputtext value="#{countrylang.languagename}(#{countrylang.languagecode})" styleclass="heading_pm_det_white" /> </h:column> </h:datatable>
i able country object language not able print in datatabel. syntex have use foreach, if yes how. thnx
you can use <ui:repeat>
this, doesn't support set
(because it's not ordered index). need convert list
or array. if you're using el 2.2, use set#toarray()
call directly in el:
<ui:repeat value="#{countrylang.countrylanguage.toarray()}" var="countrylanguage"> ... </ui:repeat>
update, per comments, you'd ot print comma separated, here's how it:
<ui:repeat value="#{countrylanguage.language.languagename}" var="languagename" varstatus="loop"> #{languagename}#{loop.last ? '' : ', '} </ui:repeat>
note: if languagename
set
instead of list
, use toarray()
there.
Comments
Post a Comment