v5.1 selectOneMenu selectItem null/empty value Issue?

UI Components for JSF
Post Reply
rmatson
Posts: 2
Joined: 29 Oct 2014, 21:08

29 Oct 2014, 22:30

Hello,

Under 5.1 the handling of a selectItem with a null or empty itemValue seems to be handled differently than in previous versions (?)

What is happening:

With 5.1 a selectItem with an itemValue = null or blank is now being sent to the converter with a value = itemLabel.

Previously, this would happen when not including an itemValue, but an empty string "" or a "#{null}" would not fire the converter and the bound value would be set to null.

Code: Select all

<p:selectOneMenu id="competitor" value="#{customerController.selected.competitorId}" converter="competitorConverter" required="false">
                <f:selectItem itemLabel="Select a Competitor" itemValue="" />
                <f:selectItems value="#{competitorController.activeItems}" var="competitor" itemLabel="#{competitor.name}" itemValue="#{competitor}"/>  
            </p:selectOneMenu>
So, in the above case my converter's getAsObject method is being called with the value param set to "Select a Competitor".

I searched the forums and didn't find anything, is anyone else experiencing this?

I'm not sure if this is a bug, or a change in direction...(or I'm totally missing something)?

Mathieu-Castets
Posts: 45
Joined: 03 Jul 2014, 19:04
Location: Biarritz, France

30 Oct 2014, 17:33

Maybe you could try to replace itemValue="" by noSelectionOption="true" in your f:selectItem
PrimeFaces 5.3 - PF Extensions 4.0.0 - OmniFaces 2.2 - Mojara 2.2.12 - GlassFish 4.1.1 - Java 7 - Netbeans 8.1

rmatson
Posts: 2
Joined: 29 Oct 2014, 21:08

30 Oct 2014, 20:29

Awesome! That worked and is a much better solution than coding a work-around in my converter. Thank you!

I would still be interested if there was a change between 5.0 and 5.1 as it will require some coding changes in places where we are generating the empty value as part of the selectItems and not "hard coding" it with an added selectItem.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests