selectonemenu

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

我是研究僧i 提交于 2019-12-18 08:55:37
问题 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. 回答1: My first question is, is there

<f:selectItems> only shows toString() of the model as item label

拥有回忆 提交于 2019-12-18 07:17:20
问题 I am facing a problem to populate SelectOneMenu correctly using converter. I followed several google references and lastly http://balusc.blogspot.in/2007/09/objects-in-hselectonemenu.html link of BalusC. But could not figure out the problem. I am giving all my entity, managedbean and jsf code for your consideration. Entity: @Entity @Table(name = "gender") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Gender.findAll", query = "SELECT g FROM Gender g"), @NamedQuery(name = "Gender.findById

Using f:selectItems var in passtrough attribute

依然范特西╮ 提交于 2019-12-17 20:47:23
问题 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

How do UISelectOne and UISelectMany components preselect defaults in f:selectItems

非 Y 不嫁゛ 提交于 2019-12-17 03:19:18
问题 I know how to preselect <p:selectOneMenu> , in selected value should be one of the objects from <f:selectItems> , but how does this component work under the hood and can I change this behavior? In my case I've a duplicate object, actually this is two objects with the same values but created twice and selected object in <p:selectOneMenu> differs from object from <f:selectItems> and it doens't recognize it. Most likely I will change my design so, it will point to same object but in case I can't

How to show images in <option> elements rendered by <h:selectOneMenu> tag

﹥>﹥吖頭↗ 提交于 2019-12-14 02:32:16
问题 Is it possible to show images in <option> elements rendered by <h:selectOneMenu> tag of JSF? I use <f:selectItems> to generate the options that I get from the database. But the content I want to show in <h:selectOneMenu> is the image associated with each item. How can I achieve that? 回答1: It is impossible to embed images within JSF's <h:selectOneMenu> / <f:selectItem> / <f:selectItems> , as there are no attributes designed for that purpose. Moreover, there is hardly a cross-browser compatible

primefaces selectonemenu change event not working for null value

主宰稳场 提交于 2019-12-14 01:13:49
问题 I have a selectonemenu that includes some items. And a null item for showing "please choose one".. MY goal is to query some data when I select one of them. And if i select the "please choose one" do another thing. But eventually, the change event is fired for normal values but if I select "please choose one" item , it is not fired. Thanks for your help. Here is my code. <p:selectOneMenu style="width: 200px" id="positionForward" value="#{hrProcessController.queryCriteria.positionForward}"

confirmDialog is not taken the new value of the selectOneMenu

自作多情 提交于 2019-12-13 04:55:22
问题 I need to change the status in database but when I change the status the confirmDialog is not taking the new value, it gets the old one <p:selectOneMenu converter="omnifaces.SelectItemsConverter" disabled="#{myBB.currentStatus != StatusEnum.TEMP}" id="statusSOM" onchange="PF('confirm').show();" value="#{myBB.currentStatus}" widgetVar="statusWV"> <f:selectItems itemDisabled="#{status == StatusEnum.ALL}" itemLabel="#{msgs[status.name]}" itemValue="#{status}" value="#{myBB.statusList}" var=

p:selectOneMenu doesn't receive focus on tab key navigation

隐身守侯 提交于 2019-12-13 00:40:38
问题 I have a form with <p:inputText> and <p:selectOneMenu> components next to each other. When the focus is on the input text and I press the tab key in order to navigate to select one menu by keyboard, then the focus is lost. I don't see which component is focused. How can I get the focus on the select one menu when I tab into it? 回答1: You need to use the tabindex property of <p:inputText> and <p:selectOneMenu> , as explained in the documentation. 回答2: Using the tabindex property makes it

JSF link in SelectItem label

旧城冷巷雨未停 提交于 2019-12-12 13:25:26
问题 Is it possible to set a <a href /> around my <f:selectItem itemLabel="label" /> where my link text is the itemLabel ? I'm using the plain sun components. 回答1: The desired result is not possible in HTML. You'll need to add a shot of JavaScript for this. <h:selectOneMenu onchange="window.location=this.options[this.selectedIndex].value"> <f:selectItems value="#{bean.links}" /> <h:selectOneMenu> Where bean.getLinks() returns a List<SelectItem> with a fullworthy URL as item value . If you want to

Update SelectOneMenu if value of ohter SelectOneMenu is set (Event isn't fired)

回眸只為那壹抹淺笑 提交于 2019-12-12 10:54:38
问题 In my application I'm trying to set/update a SelectOneMenu if another SelectOneMenu is set. We're using primefaces, so I checked the primefaces showcase and found exactly what I was looking for. Unfortunately it's not working. The Event isn't fired and I don't know why. Hopefully you can help me Link to the Example of the primefaces showcase -> If the language is set, it should automatically reload the list with the salutations, but it doesn't. I have to press F5 to reload. Any ideas? My