4 Replies Latest reply on Apr 26, 2011 8:45 AM by madhavi vaka

    Regarding <f:validateLength>

    madhavi vaka Newbie

      Hi,

              I am using richfaces.I use <f:validateLength max=100> for <inputTextarea label="Address" > .After <inputTextarea> , i have one more field <h:inputText id="invoiceNo" label="invoice number" maxlength="30" value="#{invoiceNo.number}" style="width: 330px;" required="false"/>

       

      If i enter more than 100 characters for address field , and enter value for number field, after clicking the confirm button , its showing erroe message for address field like this  "Maximum number of characters allowed are 100", But at the same time ,the value entered in Number field is reset(value gone).For solving this i remove <f:validateLength> from jsp and i wrote validation action level.Its working fine.But i did not understand whats the problem with <f:validateLength>...anyone plaese tell me tha problem?

       

      HERE IS THE  CODE.

       

      <h:panelGroup id="enterDataPanel"  layout="block" style="width: 500px; height:150px; overflow : auto;">

                                  <h6><h:outputText value="Recipient(s)"/></h6>

                                  <rich:separator height="1"/>

       

                                  <table width="100%"  >

                                  <ui:repeat id="recipients" value="#{invoicesManagement.recipients}" var="invoiceRecipient">

                                      <tr>

                                          <td width="85">

                                          </td>

                                          <td width="10"><rich:spacer width="10"/></td>

                                          <td>

                                              <table>

                                                  <tr>

                                                      <td width="52" class="required-field" ><h:outputText value="Name: "/></td>

                                                      <td>

                                                          <s:decorate id="recipientNameDec">

                                                              <table cellspacing="0" cellpadding="0">

                                                                  <tr>

                                                                      <td>                                       

                                                                          <h:inputText id="recipientName" maxlength="30" label="name" value="#{invoiceRecipient.recipient}" style="width: 330px;" required="false"/>

                                                                      </td>

                                                                  </tr>

                                                                  <tr>

                                                                      <td><s:message errorClass="error" /></td>

                                                                  </tr>

                                                              </table>

                                                          </s:decorate>

                                                      </td>

                                                  </tr>

                                                  <tr>

                                                      <td width="52" class="required-field" ><h:outputText value="Address: "/></td>

                                                      <td>

                                                          <s:decorate id="recipientAddressDec">

                                                              <table cellspacing="0" cellpadding="0">

                                                                  <tr>

                                                                      <td>                                       

                                                                          <h:inputTextarea id="recipientAddress"  label="Address" value="#{invoiceRecipient.address}" style="width: 332px; height: 40px;" required="false">

      <f:validateLength max=100/>

                                                                          </h:inputTextarea>

                                                                      </td>

                                                                  </tr>

                                                                  <tr>

                                                                      <td><s:message errorClass="error" /></td>

                                                                  </tr>

                                                              </table>

                                                          </s:decorate>

                                                      </td>

                                                  </tr>

                                              </table>

                                              <br/>

                                          </td>

                                      </tr>

                                  </ui:repeat>

                                  </table>

       

                                  <s:fragment rendered="#{not selectedInstance.generateInvoiceNo}">

                                      <h6><h:outputText value="Invoice number(s)"/></h6>

                                      <rich:separator height="1"/>

                                      <table width="100%">

                                      <ui:repeat id="invoices" value="#{invoicesManagement.invoices}" var="invoiceNo">

                                          <tr>

                                              <td width="85">

                                              </td>

                                              <td width="10"><rich:spacer width="10"/></td>

                                              <td>

                                                  <table>

                                                      <tr>

                                                          <td width="52" class="required-field" ><h:outputText value="Number: "/></td>

                                                          <td>

                                                              <s:decorate id="invoiceNoDec">

                                                                  <table cellspacing="0" cellpadding="0">

                                                                      <tr>

                                                                          <td>                                       

                                                                              <h:inputText id="invoiceNo" label="invoice number" maxlength="30" value="#{invoiceNo.number}" style="width: 330px;" required="false"/>

                                                                          </td>

                                                                      </tr>

                                                                      <tr>

                                                                          <td><s:message errorClass="error" /></td>

                                                                      </tr>

                                                                  </table>

                                                              </s:decorate>

                                                          </td>

                                                      </tr>

                                                  </table>

                                              </td>

                                          </tr>

                                      </ui:repeat>

                                      </table>

                                  </s:fragment>

                              </h:panelGroup>

                          </s:validateAll>

                      </h:panelGroup>

                      <br/>

                      <h:panelGroup id="buttonsPanel">

                           <a:commandButton action="#{invoicesManagement.prepareToShow()}" value="Continue" oncomplete="continueWithNormalInvoice()" reRender="errorMessagesPanel,prepareInvoicePanel,invoicePreviewDlgPanel" rendered="#{invoicesManagement.invoiceGenerationMode eq 'normal'}" limitToList="true" title="Continue"/>

                           <a:commandButton action="#{invoicesManagement.prepareToSplit()}" value="Continue" oncomplete="continueWithSplittedInvoice()" reRender="errorMessagesPanel,prepareInvoicePanel,splitInvoiceDlgPanel2" rendered="#{invoicesManagement.invoiceGenerationMode eq 'splitted'}" limitToList="true" title="Continue"/>

                             <input type="button" value="Cancel" onclick="#{rich:component('prepareInvoiceDlg')}.hide()" title="Cancel"/>

                         </h:panelGroup>