selectonemenu

primefaces selectOneMenu doesn't working when it should [duplicate]

谁说我不能喝 提交于 2019-11-27 07:14:39
问题 This question already has an answer here : How do UISelectOne and UISelectMany components preselect defaults in f:selectItems (1 answer) Closed 3 years ago . I'm losing days with this strange problem, I double checked everything but my selectOneMenu simply doesn't works and I can't understand why. So here are my codes: My jsf <p:selectOneMenu id="entityType" value="#{entityBean.entity.type}" style="width:240px;" converter="entityTypeConverter" valueChangeListener="#{entityBean

JSF 2 - f:selectItems with a Date keyed Map

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:48:10
问题 The below selectItems is fed from a Session Scoped Map. When the user clicks the Submit button, it is supposed to set a date field in the Request Scoped backing bean and display it on the page. <h:selectOneMenu value="#{dropDown.selectedDate}"> <f:selectItems value="#{mapValues.dateMap.entrySet()}" var="entry" itemLabel="#{entry.value}" itemValue="#{entry.key}" /> </h:selectOneMenu> <h:commandButton value="Submit" /> You selected Date #{dropDown.selectedDate} However, the following conversion

Using a “Please select” f:selectItem with null/empty value inside a p:selectOneMenu

醉酒当歌 提交于 2019-11-26 22:33:00
I'm populating a <p:selectOneMenu/> from database as follows. <p:selectOneMenu id="cmbCountry" value="#{bean.country}" required="true" converter="#{countryConverter}"> <f:selectItem itemLabel="Select" itemValue="#{null}"/> <f:selectItems var="country" value="#{bean.countries}" itemLabel="#{country.countryName}" itemValue="#{country}"/> <p:ajax update="anotherMenu" listener=/> </p:selectOneMenu> <p:message for="cmbCountry"/> The default selected option, when this page is loaded is, <f:selectItem itemLabel="Select" itemValue="#{null}"/> The converter: @ManagedBean @ApplicationScoped public final

How to preselect an option of h:selectOneMenu

随声附和 提交于 2019-11-26 22:07:19
问题 Is it possible to preselect one of the options from the select menu? I have this UI Component: <h:selectOneMenu value="#{authenticateController.country}"> <f:selectItems value="#{constants.countrySelectMenu}" /> </h:selectOneMenu> The values of #{constants.countrySelectMenu} are a list of country ID - country name pairs. Is there a way to render the list with a preselected value or at least is there a work-around to get this done? 回答1: Just preset the property behind <h:selectOneMenu value>

Different colors of options in selectOneMenu (Primefaces)

扶醉桌前 提交于 2019-11-26 21:23:32
问题 I need to display different colors of options in Primefaces. I have a selectOneMenu with dynamical items (List) <p:selectOneMenu id="carMenu" style="margin-top:4px;" value="#{Bean.selectedCar}" effect="fade" autoupdate="true"> <f:selectItems id="carsId" value="#{myBean.allCars}" var="carItems" itemLabel="#{carItems.name}" itemValue="#{carItems}" /> </p:selectOneMenu> private List<Cars> allCars; If the car is sold, I need to display the background of the option RED otherwise BLACK. In my Model

Default selection for <f:selectItem> within <h:selectOneMenu>

假如想象 提交于 2019-11-26 20:49:43
问题 How to make default selection for <f:selectItem> within <h:selectOneMenu> ? It's needed,that particular "20" item of dropdown to be already selected when page is loaded. <h:selectOneMenu value="#{fileSearchCriteriaOut.recordsPerPage}" > <f:selectItem itemLabel="5" itemValue="5" /> <f:selectItem itemLabel="10" itemValue="10" /> <f:selectItem itemLabel="20" itemValue="20" selected="true"/> </h:selectOneMenu> these four don't work: <f:selectItem itemLabel="20" selected="true"/> <f:selectItem

Populate p:selectOneMenu based on another p:selectOneMenu in each row of a p:dataTable

你。 提交于 2019-11-26 17:14:43
问题 I have a <p:dataTable> with lazy load. In two of the columns, there is a <p:selectOneMenu> in each of them. The first column holds a list of countries and the second one holds a list of states from a database. I want the second menu (the one that contains a list of states) to show only those states in each row of the data table which correspond to the country in the first menu in each row of the data table. During edit mode, when a country in its menu is changed, the states corresponding to

Make multiple dependent / cascading selectOneMenu dropdown lists in JSF

你说的曾经没有我的故事 提交于 2019-11-26 15:27:22
I am trying to make 4 dependent menus. When the user chooses an item from the first menu, the second menu will show dependent data and when the user chooses item from the second one , the third one will show dependent data and so on. The user will see items on the first menu only and the other ones will be blank. If he chooses an item on the first menu the second one will show data but the third and the fourth will remain blank, and so on. The user must eventually choose entries from all the 4 menus. <h:selectOneMenu id="first" value="#{nodes.selectState"}> <f:selectItems value="#{nodes

How to load and display dependent h:selectOneMenu on change of a h:selectOneMenu

一世执手 提交于 2019-11-26 11:55:32
I want to create JSF registration form which has select menu with the list of all countries. I know that this is easy for implementation with Java HashMap but the tricky part that I don't know how to implement is how right after the user selects his country from the list, second select menu to appear with the cities in his country? Is there any useful example? Best wishes. BalusC You can use <f:ajax> for this. When nested in an input component such as <h:selectOneMenu> , then it will by default be invoked when the input value is changed. You can specify a listener method which could

How to get both label and value from f:selectItems

独自空忆成欢 提交于 2019-11-26 11:06:55
问题 I am working on a JSF page which has a dropdown based on List<SelectItem> : <h:selectOneMenu value=\"#{bean.selectedItem}\"> <f:selectItems value=\"#{bean.availableItems}\" /> </h:selectOneMenu> I need to get both the value and label of the currently selected item. Right now I only get the value. How can I get the label, too? 回答1: You can't. That's just how HTML works. You know, JSF is a HTML code generator. The JSF <h:selectOneMenu> generates a HTML <select><option> . The HTML <select>