0

I have a component created

<cc:interface>
......
</cc:interface>
<cc:implementation>
<cc:implementation>
    <div id="#{cc.clientId}" style="margin: 0; padding: 0; width: 100%;">
        ...
        <p:inputText id="texto" value="#{cc.attrs.value}"
            readonly="#{cc.attrs.readonly}"
            required="#{cc.attrs.required}" 
            maxlength="#{cc.attrs.maxlength}">
        </p:inputText>
        ...
    </div>
</cc:implementation>    </cc:implementation>

This component is used in a template, like this

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:util="http://java.sun.com/jsf/composite/util"
......
<p:outputLabel val="name" for="foo">
<util:texto id="foo" val="#{bean.text}" required="true" />
......
</html>

But, on submit form, the component foo doesn't have red borders and p:outputLabel doesn't show the required icon, [if for="foo:texto" in p:outputlabel paint red but not icon required]

Please, show me, what is the solution, thanks

PD:excuse my very bad english.

mhatch
  • 4,441
  • 6
  • 36
  • 62

1 Answers1

0

First, put all your input components inside a h:form. Then, try this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.org/ui">

<cc:interface>
    <cc:attribute name="value" />
    <cc:attribute name="readonly" />
    <cc:attribute name="required" />
    <cc:attribute name="maxlength" />
</cc:interface>

<cc:implementation>
    <div id="#{cc.clientId}:_div" style="margin: 0; padding: 0; width: 100%;">
        <p:inputText id="_input"
                     value="#{cc.attrs.value}"
                     required="#{cc.attrs.required}"
                     maxlength="#{cc.attrs.maxlength}" />
    </div>
</cc:implementation>

</html>

View:

<h:form id="abcForm">
    <app:test id="abcText"
              value="#{some.thing}"
              required="true"
              maxlength="60" />
</h:form>

This way, you can access your div and inputText by their ids: abcForm:abcText:_div and abcForm:abcText:_input. In my tests, the inputText go red when submitted empty.

Victor T.
  • 121
  • 3