I have a开发者_如何学Pythonsked this question several times in this and various other forums, but still unable to implement it in my code.
I am doing this example , and i need to add a listbox (like in the column MANUFACTURE
).
i am unable to display the Listbox or populate it with values from my Java class.
My java code looks like this;
private List<Hotel> listHotel;
public List<Hotel> ListAllHotels() {
return dml.displayAllHotels(); //dml.displayAllHotels() returns a List<Hotel>
}
Normally i create a listbox and populate it with values using the following JFS code;
<h:selectOneMenu value="#{HotelDataForm.stationedHotel}" id="globalFilter" onchange="carsTable.filter()" >
<f:selectItems value="#{HotelDataForm.ListAllHotels}" var="user" itemValue="#{user[1]}" itemDisabled="false" itemLabel="#{user[1]}" />
<h:outputText value="#{carsTable[1]}" />
</h:selectOneMenu>
And this works, but i am unable to add this code to the Manufacturer
column in the link i posted. In the example they make use of SelectItem[]
object to populate the listbox. I am clueless as in how to add and populate values to the manufacturer
column in my program.
This is from the example on Page 131 of the PrimeFaces 2.2 Guide
If you’d like to use a dropdown instead of an inputtext to only allow predefined filter values use filterOptions attribute and a collection/array of selectitems as value. In addition, filterMatchMode defines the built-in matcher which is startsWith by default. Following is an advanced filtering datatable with these options demonstrated.
<p:column
filterBy="#{car.manufacturer}"
headerText="Manufacturer"
filterOptions="#{carBean.manufacturerOptions}"
filterMatchMode="exact">
<h:outputText value="#{car.manufacturer}" />
</p:column>
So in this example, the carBean
should have a method getManufacturerOptions()
that returns either SelectItem[]
or List<SelectItem>
containing all the values that should be in the filter dropdown list.
REFERENCE: Javadoc for SelectItem
精彩评论