p:selectOne* doesn't show submitted value after validation

UI Components for JSF
Post Reply
User avatar
gturner@unzane.com
Posts: 2
Joined: 01 Nov 2011, 00:44

01 Nov 2011, 01:33

I have a form with two inputs, a p:selectOneMenu and a p:inputText, and messages for displaying validation errors, etc.

When validation fails, p:inputText retains the submitted value, but the p:selectOneMenu returns to null/default/old-value.

Code: Select all

  <p:messages/>

  <h:panelGrid columns="3">
    <h:outputLabel for="type" value="Type:"/>
    <p:selectOneMenu id="type" value="#{controller.feature.type}">
      <f:selectItems value="#{controller.featureTypes}"/>
    </p:selectOneMenu>
    <p:message for="type"/>

    <h:outputLabel for="value" value="Value:"/>
    <p:inputText id="value" value="#{controller.feature.value}"/>
    <p:message for="value"/>
  </h:panelGrid>

  <p:commandButton value="Submit"
                   action="#{controller.saveFeature}"
                   update=":form:panel :form:edit"
                   process="edit"
                   ajax="false"/>
Looking at the InputTextRenderer code, I see it calling ComponentUtils.getStringValueToRender which has the following javadoc:

Algorithm works as follows;
- If it's an input component, submitted value is checked first since it'd be the value to be used in case validation errors terminates jsf lifecycle
- Finally the value of the component is retrieved from backing bean and if there's a converter, converted value is returned
- If the component is not a value holder, toString of component is used to support Facelets UIInstructions.


This works by invoking getSubmittedValue on the UIComponent (defined by EditableValueHolder interface).

OTOH SelectOneMenuRenderer makes does not appear to make any use of submitted value. With a debugger I see that submittedValue of SelectOneMenu UIComponent is set correctly, but apparently nothing uses it.

Is this a bug? Is there any work-around?

[primefaces 3.0.M4-SNAPSHOT]

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 46 guests