I tried using the following combination:

Client validators defined in http://jsf-comp.sourceforge.net/components/clientvalidators/index.html  + sandbox subForm component to do partial client side validations.

 

It did not work!!!

 

Code snippet:

 

<s:subForm id="demogrphicMain">

          <t:inputText id="txtLastName" forceId="true" value="#{addUserWizardBean.wizard.demographicCaptureState.lastName}">

     </t:inputText>

     <cv:requiredFieldValidator componentToValidate="txtLastName" highlight="true" display="dynamic"/>

</s:subForm>

 

<s:subForm id="addressSubForm">

<t:panelGroup>

           <t:outputText value="#{msg['label.demographicdetails.address-1']}"

                 styleClass="outputLabelText"></t:outputText>

           <f:verbatim>

                 <font color="red">*&nbsp;</font>

           </f:verbatim>

     </t:panelGroup>

     <t:panelGroup>

           <t:inputText id="txtAddressLine1" forceId="true" size="60">

           </t:inputText>

           <cv:requiredFieldValidator componentToValidate="txtAddressLine1" display="dyamic" highlight="true"/>

     </t:panelGroup>

</s:subForm>

 

<t:panelGrid align="center" columns="1">

     <t:panelGroup>

           <t:commandButton

                 value="#{msg['button.demographicdetails.add-another']}"

                 action="#{addUserWizardBean.addAddress}" actionFor="addressSubForm"></t:commandButton>

           <f:verbatim>&#160;&#160;</f:verbatim>

           <t:commandButton value="#{msg['button.demographicdetails.reset']}"></t:commandButton>

     </t:panelGroup>

</t:panelGrid>

 

<t:panelGrid align="center" columns="1">

     <t:panelGroup>

           <t:commandButton value="#{msg['button.demographicdetails.proceed']}"

           action="#{addUserWizardBean.proceed}" onclick="return validate();" actionFor="demogrphicMain"></t:commandButton>

     </t:panelGroup>

</t:panelGrid>

 

Whenever proceed button is clicked both the fields marked as required are validated which is not what the intention was. Does sandox subForm only work for server side validations? Is the client validator library which is going to be part of myfaces not compatible with subForm?

 

Is there any way in which partial form validations can be done at the client side?

 

Thanks,

~madhav

 


From: Kumar, Abhilash (Gok) [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 07, 2006 12:27 PM
To: MyFaces Discussion
Subject: RE: client side validations

 

I haven't worked with client side validation but the problem that you mentioned can be solved using sandbox subForm or trinidad subform or by using the OptionalValidator listed in the MyFaces Wiki. I have used sandbox subForm to solve this problem with server side validation.

 

-- Kannan.

 


From: Madhav Bhargava [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 07, 2006 11:10 AM
To: MyFaces Discussion
Subject: client side validations

Hi All,

 

MyForm:

Mandatory fields on the form:
1. Last Name
2. First Name
3. Gender
4. email

There is a section on the page where the user needs to provide address information. Mandatory fields in that section are:
1. address type
2. address line 1
3. state
4. zip
5. city

Address section has the following buttons - "Add Address", "Reset" "Delete"

Page level buttons are: "Proceed", "Cancel"

When the user has entered all the information then the user will click on the proceed button. However, the user can first enter the address information and click "Add address" and then enter a list of other addresses similary. The problem is that when the user clicks "Add address" form is submitted and all the fields which are assigned a validator are validated. So even if the "proceed" button is not clicked fields like "last name", "first name" etc will be validated and will therefore throw error messages on the screen.

I want to partially validate a page based on which button is clicked. How can you do that with the client side validators that you have created.

 

Currently I am using struts client validator with Myfaces but this framework does not solve the above mentioned problem.

 

Googling a bit I found the following:

 

  1. http://shale.apache.org/shale-validator/index.html
  2. http://jsf-comp.sourceforge.net/components/clientvalidators/index.html

 

I am wondering will any one them solve the problem that I am facing above.

 

~madhav

 

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

 

Reply via email to