0

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 and false}"
    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 ?

Nirmal581
  • 43
  • 1
  • 5
  • JSF won't load resources for unrendered components, the rendered expression might be returning false when it's being processed. – Makhiel Mar 07 '16 at 09:02
  • 1) The components are rendered. They are fields which are always available/visible. 2) Not sure how rendered expression returns false ? Generally first time the scripts renders and then don't for unknown reason. – Nirmal581 Mar 07 '16 at 15:52
  • Oh, the script isn't generated? I thought the javascript files were missing. If you're rerendering by AJAX the JavaScript will be executed but not added to the page, that shouldn't matter though. – Makhiel Mar 07 '16 at 16:08
  • Correct. The problem is that script isn't generated. The script is not rendered through AJAX. The script should be part of page rendering. What would cause it not to render ? As I mentioned it does render, but then stops rendering at some later point. – Nirmal581 Mar 07 '16 at 20:22

0 Answers0