selectonemenu

How to display hashmap in JSF using selectonemenu?

ぐ巨炮叔叔 提交于 2019-11-30 07:31:59
问题 I have a Java hashmap with a a list of a groups: private HashMap<String, String> listGroups = new HashMap<>(); The question is how I can display the values from the hashmap into the selectonemenu? 回答1: The <f:selectItems> already supports maps. <f:selectItems value="#{bean.listGroups}" /> The map key becomes the option label and the map value becomes the option value. That said, you probably want to use LinkedHashMap instead of HashMap if displaying the map entries in insertion order is

Primefaces dependent selectOneMenu and required=“true”

牧云@^-^@ 提交于 2019-11-29 19:21:18
问题 In my application I have three dropdown menu ( p:selectOneMenu ), say A, B, C. Among them two are dependent, say B and C. By changing the value of B I am dynamically loading values to C. Also there is a textbox. The value of the textbox is generating by ajax when the on-change event is firing from these three dropdowns. Here is the xhtml: <p:selectOneMenu id="customerMenu" value="#{adminController.activityDTO.customerId}" required="true" label="Customer Name" style="width: 200px"> <f

h:selectOneMenu generic converter for all entities without calling DB again and again

*爱你&永不变心* 提交于 2019-11-29 15:01:26
I want to get selected object from <h:selectOneMenu> , but the problem is I couldn't find any generic converter for all type of entities. My first question is, is there a generic converter for all type of entities? I don't want to write another converter again for each other entity. My second question is, is there a way to get selected object without any converter? I don't want to call the DB again and again. I have a Car entity with id and name properties. BalusC My first question is, is there a generic converter for all type of entities? This does indeed not exist in standard JSF. The JSF

How to group selectItems in selectOneMenu

别说谁变了你拦得住时间么 提交于 2019-11-29 13:57:35
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. BalusC The source code of the showcase's #{formBean} is available here . Here's an extract of relevance: private

Cascading p:selectOneMenu model value not set

China☆狼群 提交于 2019-11-29 12:51:37
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="--select--" itemValue="--select--"/> <f:selectItem itemLabel="NSE" itemValue="nse"/> <f:selectItem

Conditionally render a component based on selectOneMenu value

天涯浪子 提交于 2019-11-29 12:28:25
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. BalusC Just check the dropdown menu's value in the rendered attribute of the target components and update their common parent

How to display hashmap in JSF using selectonemenu?

混江龙づ霸主 提交于 2019-11-29 07:21:49
I have a Java hashmap with a a list of a groups: private HashMap<String, String> listGroups = new HashMap<>(); The question is how I can display the values from the hashmap into the selectonemenu? BalusC The <f:selectItems> already supports maps. <f:selectItems value="#{bean.listGroups}" /> The map key becomes the option label and the map value becomes the option value. That said, you probably want to use LinkedHashMap instead of HashMap if displaying the map entries in insertion order is important, or TreeMap if you want to automatically sort them by map key. See also Our h:selectOneMenu wiki

Using f:selectItems var in passtrough attribute

你离开我真会死。 提交于 2019-11-28 13:37:03
can I pass expressions to JSF 2 passthrough-attributes? the following code is not working. expression #{country.isoCode} is not evaluated. <h:selectOneMenu value="#{bean.selectedCountry}" styleClass="selectlist"> <f:selectItems value="#{bean.countries}" var="country" itemLabel="#{country.countryName}" pt:data-icon="flag flag-#{country.isoCode}"/> </h:selectOneMenu> I am using namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" and bootstrap-select. attribute "data-icon" is used to show an image. see: http://silviomoreto.github.io/bootstrap-select/#data-icon rendered output: <i class=

SelectOneMenu updates other SelectOneMenu

折月煮酒 提交于 2019-11-28 10:21:58
I want to update the second SelectOneMenu when I select any item of the first SelectOnMenu. As it is now, I get the values for the SelectOneMenus from a ManagedBean. I guess I've to use AJAX (jquery) to send parameters to the ManagedBean. <h:form> <div class="center"> <h:panelGrid id="editTable" columns="2" styleClass="center"> ... <h:outputText value="#{msg.timetable_list_category}" /> <h:selectOneMenu class="category"> <f:selectItems value="#{categoryBackingBean.categorys}" var="c" itemLabel="#{c.category_Name}" itemValue="#{c.id}" /> </h:selectOneMenu> <h:outputText value="#{msg.timetable

h:selectOneMenu onchange=“submit()” immediate=“true” does not skip validation of other inputs

半腔热情 提交于 2019-11-28 10:17:32
I can't set my h:selectOneMenu to submit immediately without validating other inputs. Here is the code: <h:selectOneMenu value="#{a.avalue}" onchange="submit()" immediate="true"> <f:selectItems value="#{b.bvalue}" var="k" itemLabel="#{k.asdad}" itemValue="#{k.asdad}"/> </h:selectOneMenu> <h:inputText id="sada" value="#{c.cvalue}" required="true" requiredMessage="*asdadadadasd" validatorMessage="*asdsadadadadad"> <f:validateLength maximum="80"/> </h:inputText> When I change the menu value, the validators of other inputs still fire. How can I deny that? BalusC The immediate="true" on current