selectonemenu

How to group selectItems in selectOneMenu

99封情书 提交于 2019-11-28 07:23:12
问题 I would like to use the example from the primefaces showcase to group selectItems in selectOneMenu: <h:outputText value="Grouping: " /> <p:selectOneMenu value="#{formBean.car}"> <f:selectItem itemLabel="Select One" itemValue="" /> <f:selectItems value="#{formBean.cars}" /> </p:selectOneMenu> My problem is, that there is no implementation of the bean. Now I don't know, how to implement the grouping of the selectItems inside the method getCars(). And I can't find any other example. 回答1: The

Cascading p:selectOneMenu model value not set

旧时模样 提交于 2019-11-28 06:11:36
问题 i have an application where i have a cascading dropdown, a simple dropdown and a submit commandButton. i wish to show report in datatable by selecting various criteria from the dropdowns. all works fine except when i wish to select the criteria from child dropdown. it doesnt bind with its value in the managed bean(found that by debugging). here's my code: xhtml: <h:outputText value="Exchange"/> <p:selectOneMenu style="width: 150px" value="#{reportBean.exchange}"> <f:selectItem itemLabel="-

Conditionally make inputs required depending on checkbox value

做~自己de王妃 提交于 2019-11-28 06:02:32
问题 On my JSF page, I have a HTML input checkbox where allows users to choose if they want the gift or not, and the <div> section under the checkbox information will only be displayed if the checkbox is checked. Once the checkbox is checked, users will be required to select an option (from a dropdown menu, initial value of dropdown menu = null); however, the selection is not required if the checkbox is not checked. So, here comes two conditions: A. Checkbox is checked ( == div view is played)

Conditionally render a component based on selectOneMenu value

自闭症网瘾萝莉.ら 提交于 2019-11-28 05:55:09
问题 Is there a way to render a component based on the current value the user has selected from a selectOneMenu component? My selectOneMenu component is populated with an enum consisting of two values, smoker and non-smoker. If the user has smoker selected I want to render a checkbox below it which lets the user check how many they smoke a day 10, 20, 30+, etc. I also want the opposite to work if they user has selected non-smoker i.e. the check boxes don't render/disappear. 回答1: Just check the

How to preselect an option of h:selectOneMenu

我们两清 提交于 2019-11-28 02:07:32
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? BalusC Just preset the property behind <h:selectOneMenu value> with the desired value. You can do it in for example the bean's (post)constructor, action(listener)

JSF 2 - f:selectItems with a Date keyed Map

青春壹個敷衍的年華 提交于 2019-11-28 01:37:33
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 error is received: Conversion Error setting value 'Wed Dec 26 15:09:32 EST 2012' for 'null Converter'.

Different colors of options in selectOneMenu (Primefaces)

懵懂的女人 提交于 2019-11-27 23:09:43
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 I got an attribute which gives me the value (boolean sold) back if the car is sold or not. How can I

Getting selected value of a SelectOneMenu

…衆ロ難τιáo~ 提交于 2019-11-27 22:30:15
问题 I'm testing the component "SelectOneMenu" on a jsf page. I'm populating this component dinamically though my ManageBean (that will get all Animals from database). I would like to know if is possible to see the user selected item of that "SelectOneMenu" (combobox), I'm trying with value="#{animalsManage.animalSelect}" but it is only called on the beginning of the page. Also, I'm using an inputText to see the value of the selected intem of the "SelectOneMenu". What I'm doing wrong? JSF: <body>

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

女生的网名这么多〃 提交于 2019-11-27 15:31:26
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 that country should be populated in its menu in that current row. How to load such lists of states that

How to get both label and value from f:selectItems

时光怂恿深爱的人放手 提交于 2019-11-27 13:15:06
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? 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> element will only send the value attribute of the selected <option> element. It will not send its label. But that