This content has been marked as final.
Show 2 replies
-
1. Re: Convert integer field to correspondig drop down field
kragoth Oct 8, 2010 1:40 AM (in response to mathandos)provide your JSF or whatever code for your drop down menu please.
-
2. Re: Convert integer field to correspondig drop down field
mathandos Oct 8, 2010 2:53 AM (in response to mathandos)Hi Tim
I hope i've provide enough code for your assistance, if not please do not hesitate to let me know if you need more info.
(List.java)
//to populate the dropdown with municipality description
public class MunicipalityList extends EntityQuery<Municipality> {
private static final String EJBQL = "select municipality from Municipality municipality";
private static final String[] RESTRICTIONS = {"lower(municipality.municipalityDescription) like lower(concat(#{municipalityList.municipality.municipalityDescription},'%'))",};
private Municipality municipality = new Municipality();
private SelectItem[] items = null;
public MunicipalityList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}
public Municipality getMunicipality() {
return municipality;
}
public SelectItem[] getItems() {
if (items == null) {
items = new SelectItem[this.getResultList().size()];
for (int i = 0; i < this.getResultList().size(); i++) {
Municipality entity = this.getResultList().get(i);
SelectItem item = new SelectItem(entity, entity.getMunicipalityDescription());
items[i] = item;
}
}
return items;
}
}
(.xhtml)
<s:decorate id="municipalityField" template="layout/edit.xhtml">
<ui:define name="label">Municipality</ui:define>
<h:selectOneMenu value="#{regionHome.instance.municipality}">
<f:selectItems value="#{municipalityList.items}" var="municipalityDescription"
noSelectionLabel="Please Select..."/>
<s:convertEntity />
<a:support event="onblur" reRender="municipalityField" bypassUpdates="true" ajaxSingle="true"/>
</h:selectOneMenu>
</s:decorate>