Search code examples
javajsfrichfaces

Validation for checking the field value before submitting the page to the server


I have developed an JSF and richfaces based application, Here I want to know about a nice way to throw the warning to the user if described field (Rich:inplaceInput) is empty

I have created rich:extendedDataTable in which one of the column is this...

<rich:column width="120" id="col15" label="yardNo">
    <f:facet name="header">
        <h:outputText value="Yard Number"></h:outputText>
        </f:facet>
        <rich:inplaceInput value="#{r.runSlNo}" defaultLabel="Assign Manual Number" 
                           inputWidth="90" showControls="true"/>
</rich:column>

and i have created a rich:contextMenu for displaying menu like this...enter image description here

One commandbutton is also there for submitting the page.
I have two problems over here regarding rich:inplaceInput.
first, I just dont want to allow the user to submit the page if the rich:InplaceInput value field is empty, rather throw an warning to fill it.
I know how to throw the error or warning before submitting the page.
Second, how can i avoid displaying contextMenu over rich:InplaceInput value but let it display at other 4 columns....


Solution

  • you can add required="true" to inplaceInput that way you wont submit the form... and you add h:messages bellow the table to display the error of required field or try adding h:message with for="id_of_the_rich:inplaceInput" and locate the h:message bellow the <rich:inplaceInput