Conversion Error setting value '1' for 'null Converter' [duplicate] - jsf

This question already has answers here:
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 7 years ago.
When I click submit button in a jsf page I get the above error.
html:
<h:selectOneMenu id="ddlCountryCode" value="#{jsfFills.countries}">
<f:selectItems value="#{jsfFills.countries}" var="c"
itemLabel="#{c.CName}" itemValue="#{c.CCode}" />
</h:selectOneMenu>

The "value" attribute should point to a variable where you want to store the selected value of the component, not the list of choices.
In the example above, jsfFills.countries is used as both the list of options AND the value of the component, and that could be causing the issue. We'd want to create a variable in a bean somewhere and use that instead.
<h:selectOneMenu id="ddlCountryCode" value="#{jsfFills.selectedCountry}">
<f:selectItems value="#{jsfFills.countries}" var="c"
itemLabel="#{c.CName}" itemValue="#{c.CCode}" />
</h:selectOneMenu>

Related

Primefaces SelectOneMenu's ajax event inside outputPanel with rendered, is not working [duplicate]

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 3 years ago.
I've this code:
<p:outputPanel styleClass="ep-form-field-wrapper-s" rendered="#{monthlyProcessesReportsViewBean.showReports}">
<p:outputLabel for="columnsConfig" value="#{i18n['monthly-processes-reports-columns-configuration']}" styleClass="ep-data-edit-field"/>
<p:selectOneMenu id="columnsConfig" value="#{monthlyProcessesReportsModelBean.report}" effect="none" converter="#{genericUniqueEntityConverter}">
<f:selectItem itemValue="#{null}" itemLabel="#{i18n['monthly-processes-reports-as-payslip']}"/>
<f:selectItems value="#{monthlyProcessesReportsModelBean.reports}" var="report" itemValue="#{report}"
itemLabel="#{report.description}"/>
<p:ajax listener="#{monthlyProcessesReportsBackingBean.handleReportTypeSelected(report)}"/>
</p:selectOneMenu>
</p:outputPanel>
The ajax event is not working, but if I remove the rendered attribute from the outputPanel it works correctly.
What is wrong in my code?
Thanks!
Thank you for the link.
These are the dangers of the copy&paste: my monthlyProcessesReportsViewBean, which is used to store the property that manages the rendered attibute, was RequestScoped instead of ViewScoped and I'd not been noticed...

Not render an option in <p:selectOneRadio> [duplicate]

This question already has answers here:
How to conditionally render an f:selectItem tag?
(8 answers)
Closed 4 years ago.
i have a p:selectOneRadio
<p:selectOneRadio value="#{bean.value">
<f:selectItem rendered="#{bean.isbank}" itemLabel="Bank Clients" itemValue="bank" />
<f:selectItem itemLabel="Contacts" itemValue="contacts" />
</p:selectOneRadio>
I want the 'Bank Clients' option not to show every time 'isbank' is false. How do i achieve this?
There is an option to disable elements:
itemDisabled='#{isbank==false}'

How I can use a converter in a JSF tag selectOneMenu? [duplicate]

This question already has answers here:
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 4 years ago.
The following example works in my interface:
<h:outputText value="#{diplome.pays}">
<gn:converter origine="#{config.origManSirhen}"
nomenclature="#{config.codePays}"
propriete="libelleImpression" />
</h:outputText>
However, when I try to use the same converter does not work when the element is a selectOneMenu
<p:selectOneMenu id="pays">
<f:selectItem
itemValue="#{InformationsPersonnellesModele.adressePrincipale.pays}"
itemLabel="#{InformationsPersonnellesModele.adressePrincipale.pays}" />
<gn:converter origine="#{config.origManSirhen}"
nomenclature="#{config.codePays}" propriete="libelleImpression" />
</p:selectOneMenu>
I have tried to use the attribute converter into the selectOneMenu tag, but it does not work as I expect because I need to use as well the parameter nomenclature and propiete.
I found a possible solution:
The item selected by default must be the value of the selectOneMenu tag.
And the list of items and the converter are directly assigned to the value of the selectItems tag.
<p:selectOneMenu id="pays"
value="#{InformationsPersonnellesModele.adressePrincipale.pays}">
<f:selectItems
value="#{gnl:listeTri(config.origManSirhen, config.codePays,'libelleImpression')}" />
</p:selectOneMenu>

how to add tooltip for selectItems tag in JSF [duplicate]

This question already has answers here:
How to add tooltip to f:selectItems
(2 answers)
Closed 6 years ago.
<h:selectOneMenu id="sType"value="#{sBean.sCriteria.sType}" style="width:200px;" styleClass="black" onchange="sTypeChanged();">
<f:selectItems value="#{sBean.allSTypes}" />
</h:selectOneMenu>
I am using the above code in my xhtml file.
I want to add "tool tip" in my selectOneMenu tag.
How can I do this?
Please look at this question hope ot helps
How to add tooltip to f:selectItems
Try ans use the title attributes best thing will be to bind the title in a map in the backing bean and use it here dynamically
Use the title attribute of selectOneMenu
<h:selectOneMenu id="sType"
title="tooltip_goes_here"
...
http://docs.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/h/selectOneMenu.html

selectonemenu does not display value from bean [duplicate]

This question already has answers here:
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 7 years ago.
I am having problems with the primefaces selectonemenu, it only displays cube.name (the pulldown has the verbiage cube.name not the value of cube.name), here is the code.
<p:selectOneMenu id="cubeConfigId" value="#{projectModel.selectedProject.cubeConfigId}" >
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{projectModel.cubeConfigEntities}" var="cube" itemLabel="cube.name" itemValue="cube.cubeConfigId"/>
</p:selectOneMenu>
what exactly does the var="cube" do?
You got itemLabel="cube.name" instead of itemLabel="#{cube.name}" (same for itemValue).
What is displayed is determined by itemLabel="cube.name" so you see what you got in label - in this case it's only name (if you do something like this itemLabel="#{cube}" - toString() will be displayed of the Cube entity). What is saved in backing bean is under itemValue.
var="cube" is just iterator for value="#{projectModel.cubeConfigEntities}". If cubeConfigEntities is list of Cube entities then var="cube" is Cube in one loop iteration, in another loop iteration it takes another Cube from list etc. You can access Cube methods by invoking them on cube.

Resources