2 Replies Latest reply on Jun 10, 2010 4:49 PM by Flavio Henrique

    rich:findComponent and required not working

    Flavio Henrique Newbie

      Hi there!

      I'm trying to make an h:inputText required only if another one is not empty, but or I'm doing it in the wrong way or... dont know.

       

      The snipppet:

       

      <r:columnGroup>
          <r:column styleClass="noBorders">
              <h:inputText
                  id="field1"
                  size="7"
                  disabled="#{MyBean.isExclusao}"
                  value="#{MyBean.object.field1}" />
          </r:column>
          <r:column styleClass="noBorders">
              <h:inputText
                  id="field2"
                  size="2"
                  required="#{not empty r:findComponent('field1').value}"
                  requiredMessage="Informe o ramal"
                  disabled="#{MyBean.isExclusao}"
                  value="#{MyBean.object.field2}" />
          </r:column>
      </r:columnGroup>
      
      

       

      I tried the other form:

       

      required="#{not empty r:findComponent('field1').attributes['value']}"
      

       

      but didn't work too.

       

      Please, someone has any idea why this do not work? Or some idea how to achieve my goal?

      Please?

       

      Thank you in advance!

       

      Flávio Henrique

       

      Ahhh... why we can have a 'preview post' here? Message was edited by: Flavio Henrique

        • 1. Re: rich:findComponent and required not working
          Rafael de Carvalho Newbie

          Hello Flávio!

          Can you try this?

           

          {code:xml}

          <r:columnGroup>
              <r:column styleClass="noBorders">
                  <h:inputText
                      id="field1"
                      size="7"
                      disabled="#{MyBean.isExclusao}"
                      value="#{MyBean.object.field1}">
                      <a4j:support event="onkeyup" reRender="field2"/>
                  </h:inputText>
              </r:column>
              <r:column styleClass="noBorders">
                  <h:inputText
                      id="field2"
                      size="2"
                      required="#{not empty r:findComponent('field1').value}"
                      requiredMessage="Informe o ramal"
                      disabled="#{MyBean.isExclusao}"
                      value="#{MyBean.object.field2}" />
              </r:column>
          </r:columnGroup>

          {code}

           

           

          A post preview would be very nice!

          • 2. Re: rich:findComponent and required not working
            Flavio Henrique Newbie

            Rafael, obrigado!

            Resolvido.