0

使用的库: javax.faces-2.2.9、richfaces-rich-4.5.4、openfaces 3.0

服务器环境: JBoss EAP 6.4.2

我的 xhtml 页面仅使用openfaces ( xmlns:o="http://openfaces.org/") 进行验证。请参见下面的典型示例:

<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>

问题是:与标签对应的 java 脚本<o: ..>呈现不一致。第一次访问页面,页面中包含验证脚本(使用查看源验证),但是在单击其他页面后,当我回来时,不包括 openfaces 库相关脚本。行为不一致。有时当您返回页面时脚本可用。但是,一旦它们无法加载,我就再也没有看到它们回来了。

下面是渲染时验证脚本的示例。请参阅<script ..>下面开始的部分。当用户移出必填字段时,字段旁边会出现一个错误图标,并且字段的背景颜色会发生变化:

<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>
.....

只要包含上述脚本,验证就会按预期工作。每当脚本无法呈现时,验证就不起作用。

openfaces 库脚本被渲染而不是不一致地渲染的原因可能是什么?

4

0 回答 0