1 Reply Latest reply on Mar 8, 2016 6:00 AM by Michal Petrov

    Openfaces validation scripts not getting included in page

    sudda_1 Newbie

      Libraries used: javax.faces-2.2.9, richfaces-rich-4.5.4, openfaces 3.0

      Server Environment: JBoss EAP 6.4.2

      My xhtml page uses openfaces(xmlns:o="http://openfaces.org/") for validation only. See typical example below:

       

      <h:inputText value="#{secItem.itemName}"
        
      rendered="#{secItem.sectionItemType.customizable}"
        
      title="Enter the name, max allowed 1024 characters"
        
      maxlength="1024" id="secItemNameID"
        
      disabled="#{portalConfig.savedParams.readOnly or
        portalConfBB.portalSecConfig.sectionType.readOnly}"
      >
        
      <o:validateCustom clientFunction="return !isEmpty(value)"
        
      detail="Column name cannot be empty" />
        
      <o:floatingIconMessage for="secItemNameID"
        
      styleClass="errFloatIconMessage" />
      </h:inputText>


      The issue is: java script corresponding to <o: ..> tags gets rendered inconsistently. First time page is accessed, validation scripts included in page(verified using view source), however after a few clicks to other pages and when I come back, openfaces library related scripts are not included. Behavior is not consistent. Sometimes the scripts available when you come back to page. However, once they fail to load, I have not seeing them come back again.

      Below is example of validation scripts when they get rendered. See the section starting with <script ..> below. When user moves out of required field, an error icon appears next to field and background color of field changes:

       

      <td id="psForm:j_idt154:6:j_idt183" class="rf-dt-c">
        
      <img src="/expert3jsf2/image/requiredfield.gif" style="border:0;" title="Required Field" />
        
      <input id="psForm:j_idt154:6:secItemLabelId" type="text" name="psForm:j_idt154:6:secItemLabelId" value="Announcements" maxlength="20" size="50" title="Enter the label, max allowed 20 characters" />
        
      <script type="text/javascript">
        O$
      .addClientMessageRenderer(new O$._FloatingIconMessageRenderer('dfm20', 'psForm:j_idt154:6:secItemLabelId', '/expert3jsf2/javax.faces.resource/validation/error_icon.gif.jsf?ln=openfaces', -4, -4, 'o_floatingIconMessage', {}, false, false, true, true));
        
      </script>
        
      <script type="text/javascript">
        O$
      .addValidatorsById('psForm:j_idt154:6:secItemLabelId',[
        
      new O$._CustomValidator('Validation Error', 'Item label cannot be empty', function(input,value){return !isEmpty(value)})]);
        
      </script>

      .....


      Whenever above scripts gets included, validation works as expected. Whenever scripts fails to render, validation does not work.

      What could be the reason for openfaces library scripts to get rendered and not rendered inconsistently ?