4 Replies Latest reply on Jul 23, 2010 1:09 PM by Flavio Henrique

    Calendar with required attribute problems

    Flavio Henrique Newbie

      Hi there! I'm using RF 3.3.3.Final, JSF 1.2, Facelets.

       

      When I use the required attribute on rich:calendar, the 'clean' button do not reset the component value (just clean the calendar inputField).

       

      See this simple test code:

       

      <r:calendar
          value="#{MyBean.attribute}"
          required="true"
          id="calTest">
          <a4j:support
              event="onchanged"
              reRender="test" />
      </r:calendar>
      <h:outputText
          value="#{r:findComponent('calTest').value}"
          id="test" />
      

       

      Use the calendar popup and choose any date. The outputText will be updated. Now use the 'clean' buttom. The outputText remains.

       

      I just need to remove the required="true" from the component and the it starts to work as expected.

       

      I need to solve this, because I need the actual (and right) component's value to validade the screen fields.

       

      Or this is known bug?

       

      Please, help. Thank you in advance.

       

      Flávio Henrique

        • 1. Re: Calendar with required attribute problems
          Ilya Shaikovsky Master
          Or this is known bug?

          Not a bug but just works as it should. The same you will see if will just use inputText. Component value can't be empty with required set to true(only on initial loading.) Add rich:messages - you will see the message about it.

          • 2. Re: Calendar with required attribute problems
            Flavio Henrique Newbie

            Hello Ilya! Thank you, again.

            Now, my problem is installed.

            In my form I have another calendar that depends on the first calendar's value to be validated. Something like this:

             

             

            <r:calendar
                value="#{MyBean.attribute}"
                required="#{not empty r:findComponent('someInputText').value}"
                id="calTest"/>
            <r:calendar
                value="#{MyBean.anotherAttribute}"
                required="#{not empty r:findComponent('calTest').value}"
                id="anotherCalendar"/>
            
            

             

            The first calendar is required if someInputText is not empty.

             

            So, the second calendar value is required if the first one is not empty, but as I said (and you confirmed that is not a bug), if I use the clean buttom in the first calendar, the second will be considered valid as the first value wasn't reseted.

             

            Do you have any suggestion how to achive this? As we can't have 'onclean' event to do something, can I force null value somehow?

             

            Thank you !

             

            Flávio Henrique

            • 3. Re: Calendar with required attribute problems
              Ilya Shaikovsky Master

              add a4j:support's to the components which should influence another ones (use onchanged even or calendar's). So when any value change occurs, including clearing - update dependent controls to keeps all of them in sync.

              • 4. Re: Calendar with required attribute problems
                Flavio Henrique Newbie

                Hello Ilya, thank you.

                 

                I dont know what I was doing wrong, but I tried that already and was'nt worked.

                Now I can validade the fields as expected.

                 

                Thank you.