2 Replies Latest reply on Aug 28, 2008 7:40 AM by Ruzbeh Shokranian

    Clearing Calendar Problem

    Ruzbeh Shokranian Newbie

      I have a jsf form with text fields, combo boxes and a rich face calander component. I have a button that clears all the components. The button calls a javascript function that clears all fields.

      However, I also have an include button that includes all the data in the database, if I fill all the fields, except one, the validation will fail, and if after that I press the clear button, all the fields will be cleared, except the rich face calender component.

      Here is the code for the clear button:

      <h:commandButton styleClass="botao" immediate="true"
      value="#{Message['comando.limpar']}" onclick="clearFields()"/>


      And here is the javascript function:

      function clearFields()
      {
       for( var n = 0; n < document.forms.length; n++ )
       {
       for(var i = 0; i < document.forms[n].elements.length; i++)
       {
       if( document.forms[n].elements.type == 'text')
       {
       document.forms[n].elements.value = "";
       }
      
       if( document.forms[n].elements.type == 'select-one')
       {
       document.forms[n].elements.value = null;
       }
       }
       }
      }


      I have already seen that the calendar component enters in the 'text' type, if I put an alert message, I can see it, and I can even see that the calender is cleaned, but after the last alert message, the page reloads and the date that was supposed to be cleared isn´t.

      I have already tried to do the cleaning in the backing bean, but in this case none of the fields are cleaned. Note that this problem only happens if before I press the clear button I press the include button with some fields not filled.

      Can anyone help me?