jsf - 复合组件标签和o :validateMultipleFields

标签 jsf label composite-component omnifaces

我有以下复合组件,我想使用 o:validateMultipleFields(更具体地说是 o:validateAllOrNone)。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui"
  xmlns:composite="http://java.sun.com/jsf/composite"
  >

<composite:interface>
    <composite:attribute name="target" />
    <composite:attribute name="label"/>
    <composite:attribute name="value" />
    <composite:attribute name="required" />
    <composite:attribute name="size" />
    <composite:attribute name="disabled" />
    <composite:attribute name="styleInput" required="false" />
    <composite:editableValueHolder name="input" targets="input" />
    <composite:clientBehavior name="change" event="change" targets="#{cc.attrs.target}" />
    <composite:clientBehavior name="keypress" event="keypress" targets="#{cc.attrs.target}" />
</composite:interface>

<composite:implementation>
    <p:outputLabel id="label" for="input" value="#{cc.attrs.label}" />
    <h:panelGrid columns="3">
        <p:inputText id="input" value="#{cc.attrs.value}" 
          style="#{cc.attrs.styleInput}" size="#{cc.attrs.size}"
          disabled="#{cc.attrs.disabled}" required="#{cc.attrs.required}">
        </p:inputText>
        <p:message for="input" display="icon">
          <p:effect type="pulsate" event="load" delay="500" />
        </p:message>
    </h:panelGrid>
</composite:implementation>
</html>

验证按预期工作,但 components 属性上指定的组件标签未显示。相反,它显示组件 ID。

<cetcomp:editar id="origem" label="Origem" size="10" />
<cetcomp:editar id="cst" label="CST" size="10" />
<o:validateAllOrNone id="origemCst" components="origem:input cst:input" showMessageFor="origem:input" />

最佳答案

ValidateMultipleFieldslabel 中提取标签物理输入组件的属性。这些标签也将在标准 JSF 验证中使用。你确实没有,它们只设置在<p:outputLabel>上.

相应地添加它们:

<p:inputText ... label="#{cc.attrs.label}">

另一种方法是使用 <o:outputLabel> 而不是<p:outputLabel>因为 OmniFaces 会自动将标签复制到关联的输入组件。

<o:outputLabel ... for="input" value="#{cc.attrs.label}" />
<p:inputText id="input" ... />

更新:事实证明它实际上仍然不起作用。 #{cc} ValidateMultipleFields 期间不可用正在提取标签。此问题已按照 issue 134 修复。它将在 OmniFaces 2.1 中提供。

关于jsf - 复合组件标签和o :validateMultipleFields,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30495389/

相关文章:

jsf - 使用 p :dataList in PrimeFaces 的页面事件

jquery 为什么我可以设置一个标签的位置而不是另一个?

ajax - 如何从#{cc.clientId} 中提取第一个组件 ID?

jsf - 如何制作JSF复合组件的网格?

jsf - PrimeFaces TypeError : PF(. ..) 未定义

facebook - 使用 jsf 获取 redirect_uri 不是 facebook 登录中的绝对 URI 错误

jsf - 为什么 jsf 生命周期在重定向页面时跳过调用应用程序后的渲染响应?

java - 我们可以在 switch case java 中添加标签吗

android - 你如何在 Android 中将文本放在 RadioButton 的上方或下方

jsf - 如何将 primeface 列包含到复合 Material 中