4 Replies Latest reply on Feb 25, 2014 9:55 AM by damonchong

    Richfaces popup panel not working with h:inputText when required="true"

    damonchong

      Hi, this is my first question in the richfaces forum, please be patient with me.

       

      I set the h:inputText required attribute as true in a richfaces popup panel. The code is as below:

       

      <rich:popupPanel id="testPopupPanel" minWidth="600" minHeight="300">    
          <f:facet name="header">
            <h:outputText value="Simple popup panel" />
        </f:facet>  
        <f:facet name="controls">
          <h:outputLink value="#" onclick="#{rich:component('testPopupPanel')}.hide(); return false;">
             X
          </h:outputLink>
        </f:facet>
        <h:form id="popupForm">
        <div id="newCategoryDiv" style="width:100%">
         <s:decorate id="newCategoryNameDecorate" template="/layout/edit.xhtml">
              <ui:define name="label">Category name: </ui:define>
              <h:inputText id="newCategoryNameText" value="#{adminCategory.categoryNew.categoryName}" style="width: 500px;" 
              required="true" onchange="return changed();"/>
          </s:decorate>
        <br clear="both" />
        <h:commandButton id="createButton" action="#{adminCategory.createCategory()}" value="Create">
        </h:commandButton>
        </div>
        </h:form>
      </rich:popupPanel>
      

       

      As you can see I created the popup panel with its own form element outside of another form element. My question is that I deliberately left the inputText as blank and click on the commandButton to submit the form. The validation failed as expected but the popup panel closes immediately. Upon showing the popup panel you can see that there is an error associated with the missing value for h:inputText. But it is annoying as users would have to show the popup panel a second time just to see the error.

       

      How do I stop the popup panel from hiding after clicking on the submit button? Thank you for your help!

       

      Warmest regards,

      Damon