You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kanuri, Chand" <ch...@landg.com> on 2005/11/08 11:29:45 UTC

Struts validator Nested properties problem!!!


Hi all,
i have an action form called UserForm in which i instantiated a bean called
UserBean.
there are 5 users in total.so i instantiated UserBean 5 times in my action
form(using an arraylist).
UserBean has the following properties: name,sex,postcode
hence there are 5*3=15 properties in total.
how can i validate these properties using struts validator(using
validator-rules.xml,validation.xml and struts-config.xml).
i can validate the simple properties in my action form but how can i
validate the nested properties?
the simple properties in my form are type and code.
i am validating them as below:

i am validating like this in my validation.xml file: (validation for
required fileds)

<form-validation>
  <formset>
    <form name="userForm">
      <field property="type" 
            depends="required">
        <arg0 key="prompt.type"/>
      </field>
	<field property="code" 
            depends="required">
        <arg0 key="prompt.code"/>
      </field>

    </form>
  </formset>
</form-validation>

i am instatiating the UserBean like this in my actionForm:(the UserForm
constructor is like this)

private List users = new ArrayList(5);

public UserForm() {
		super();
		
		for (int i = 0; i < 5; i++) {
			UserBean ub = new UserBean();
			users.add(ub);
		}
	}



can i validate the nested properties like this:

<form-validation>
  <formset>
    <form name="userForm">
      
	<field property="ub.name" 
            depends="required">
        <arg0 key="prompt.ub.name"/>
      </field>

	<field property="ub.sex" 
            depends="required">
        <arg0 key="prompt.ub.sex"/>
      </field>

<field property="ub.postcode" 
            depends="required">
        <arg0 key="prompt.ub.postcode"/>
      </field>

    </form>
  </formset>
</form-validation>


if this is correct,in this case i could validate 3 properties.does it
validateall the 15 fields (nested properties) in my form?

any ideas..your suggestions are highly appreciated.

regards and many thanks in advance.



This e-mail (and any attachments) may contain privileged and/or confidential information. If you are not the intended recipient please do not disclose, copy, distribute, disseminate or take any action in reliance on it. If you have received this message in error please reply and tell us and then delete it. Should you wish to communicate with us by e-mail we cannot guarantee the security of any data outside our own computer systems. For the protection of Legal & General's systems and staff, incoming emails will be automatically scanned.

Any information contained in this message may be subject to applicable terms and conditions and must not be construed as giving investment advice within or outside the United Kingdom.

The following companies are subsidiary companies of the Legal & General Group Plc which are authorised and regulated by the Financial Services Authority for advising and arranging the products shown: Legal & General Partnership Services Limited (insurance and mortgages), Legal & General Insurance Limited (insurance), Legal & General Assurance Society Limited 
(life assurance, pensions and investments), Legal & General Unit Trust Managers Limited and Legal & General Portfolio Management Services Limited (investments).

They are registered in England under numbers shown.
The registered office is Temple Court, 11 Queen Victoria Street, London EC4N 4TP.

Legal & General Partnership Services Limited: 5045000 Legal & General Assurance Society Limited: 166055 Legal & General (Unit Trust Managers) Limited: 1009418 Legal & General (Portfolio Management Services) Limited: 2457525 Legal & General Insurance Limited: 423930

They are registered with the Financial Services Authority under numbers shown. You can check this at www.fsa.gov.uk/register

Legal & General Partnership Services Limited: 300792 Legal & General Assurance Society Limited: 117659 Legal & General (Unit Trust Managers) Limited: 119273 Legal & General (Portfolio Management Services) Limited: 146786 Legal & General Insurance Limited: 202050


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org