Multiple validation messages do not display in a JSF 2.0 portlet on WebSphere Portal 8.0 or later

Technote (troubleshooting)


Problem(Abstract)

Multiple validation messages do not display in a JavaServer Faces (JSF) 2.0 portlet deployed on IBM WebSphere Portal 8.0 or later, with javax.faces.PROJECT_STAGE set as Development in the web.xml file.

Symptom

In the portlet facelet of a JSF 2.0 portlet published on WebSphere Portal v8.0, or later, when multiple validation messages are added on one component with <h:message> tag.

For example:


<h:form id="form1" styleClass="form">
<h:inputText id="text1" styleClass="inputText">
<f:validateRequired></f:validateRequired>
<f:validateLength minimum="5" maximum="10"></f:validateLength>
</h:inputText>
<h:message for="text1"></h:message>

<h:commandButton type="submit" value="Submit" id="button1"
styleClass="commandButton" action="/<portletname>View.xhtml"></h:commandButton>
</h:form>


For validateRequired, the following message displays in the UI:

viewns_Z7_1AE81A41JOMKC0AGQ8DP931083_:form1:text1: Validation Error: Value is required.

For validateLength, the following message displays in the console:

0000006c RenderRespons W   There are some unhandled FacesMessages, which means not every FacesMessage had a chance to be rendered.
These unhandled FacesMessages are:
- viewns_Z7_1AE81A41JOMKC0AGQ8DP931083_:form1:text1: Validation Error: Value is less than allowable minimum of '5'


Resolving the problem

To display multiple validation messages in a JSF 2.0 portlet with javax.faces.PROJECT_STAGE set as Development in the web.xml:

WebSphere Portal 8.0.x installed on WebSphere Application Server 8.0.0.8 or earlier

  1. Ensure the <h:message> tag is not present

  2. Add the <h:messages> tag inside the <h:form> tag in the portlet facelet.

    For example:

    <h:form id="form1" styleClass="form">
    <h:inputText id="text1" styleClass="inputText">
    <f:validateRequired></f:validateRequired>
    <f:validateLength minimum="5" maximum="10"></f:validateLength>
    </h:inputText>
    <h:commandButton type="submit" value="Submit" id="button1"
    styleClass="commandButton" action="/<portletname>View.xhtml"></h:commandButton>
    <h:messages id="messages1" styleClass="messages"></h:messages>
    </h:form>



WebSphere Portal 8.0.x installed on WebSphere Application Server 8.0.0.9 or later
  1. Wrap the entire portlet facelet content inside the <h:body></h:body> tags

    For example, if the portlet facelet has the <h:form> tag, then add the <h:body></h:body> tags around it as follows:

    <h:body>
    <h:form id="form1" styleClass="form">
    <h:inputText id="text1" styleClass="inputText">
    <f:validateRequired></f:validateRequired>
    <f:validateLength minimum="5" maximum="10"></f:validateLength>
    </h:inputText>
    <h:message for="text1"></h:message>

    <h:commandButton type="submit" value="Submit" id="button1"
    styleClass="commandButton" action="/<portletname>View.xhtml"></h:commandButton>
    </h:form>
    </h:body>


  2. Add the following entries in the faces-config.xml file:

    <render-kit>
    <renderer>
    <component-family>javax.faces.Output</component-family>
    <renderer-type>javax.faces.Head</renderer-type>
    <renderer-class>com.ibm.faces20.portlet.tag.render.JSF20PortletTagImpl_Head</renderer-class>
    </renderer>
    </render-kit>
    <render-kit>
    <renderer>
    <component-family>javax.faces.Output</component-family>
    <renderer-type>javax.faces.Body</renderer-type>
    <renderer-class>com.ibm.faces20.portlet.tag.render.JSF20PortletTagImpl_Body</renderer-class>
    </renderer>
    </render-kit>


  3. Add the following <context-param></context-param> tag in the web.xml file:

    <context-param>     <param-name>com.ibm.faces.portlet.RENDER_UNHANDLED_FACES_MESSAGES</param-name>
    <param-value>true</param-value>
    </context-param>

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational Application Developer for WebSphere Software
Portal / Portlet Development

Software version:

9.0, 9.0.1, 9.1, 9.1.0.1

Operating system(s):

Windows

Reference #:

1649550

Modified date:

2014-06-23

Translate my page

Machine Translation

Content navigation