struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "PILGRIM, Peter, FM" <Peter.PILG...@rbos.com>
Subject Role Based Struts Validation
Date Wed, 29 Jan 2003 10:59:20 GMT
My XML skills are brain dead. I just had a thought that my role base
struts validation will not work as intended.

I intended to customise FieldChecks with validators that checks
against a "role" attribute in the action form. I realise that
the Validator does not quite work that way.

Normally when you write the depends attribute you want
to do something like this

	<field property="ageText"  depends="required,integer,range" >
            <arg0 key="testForm.testRecord.ageText.displayname" />
            <arg1 name="range" key="${var:min}" resource="false" />
            <arg2 name="range" key="${var:max}" resource="false" />
            <var>
                 <var-name>min</var-name>
                 <var-value>18</var-value>
            </var>
            <var>
                 <var-name>max</var-name>
                 <var-value>125</var-value>
            </var>		
	</field>

Execute the "required" validator first, then the "integer" and "range"
ones.

Now with role base validation. Say I have validator that checks that
role was in the administration category.

	<field property="ageText"  depends="role,required,integer,range" >
            <arg0 key="testForm.testRecord.ageText.displayname" />
            <arg1 name="range" key="${var:min}" resource="false" />
            <arg2 name="range" key="${var:max}" resource="false" />
            <var>
                 <var-name>min</var-name>
                 <var-value>18</var-value>
            </var>
            <var>
                 <var-name>max</var-name>
                 <var-value>125</var-value>
            </var>		

            <var>
                 <var-name>roleProperty</var-name>
                 <var-value>role</var-value>   <!-- name of action form
property -->
            </var>            
		<var>
                 <var-name>roleGroup</var-name>
                 <var-value>admin</var-value>  <!-- comma delimited field
-->
            </var>

	</field>

This validator rule say that the action form has a property called
"role" and the group it should check for is "admin".

If the action form has the role "admin" then the validation should
continue, if the action form does not have the role "admin"
then further validation should terminate. It should skip the
remaining validations "required", "integer" and "range"

Of course I dont think the Validator works this way?
Is it possible to skip validations? If not, then I am sunk.

--
Peter Pilgrim,
Struts/J2EE Consultant, RBoS FM, Risk IT
Tel: +44 (0)207-375-4923


********************************************************************
      Visit our Internet site at http://www.rbsmarkets.com

This e-mail is intended only for the addressee named above.
As this e-mail may contain confidential or privileged information,
if you are not the named addressee, you are not authorised to
retain, read, copy or disseminate this message or any part of it.
The Royal Bank of Scotland plc is registered in Scotland No 90312
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB
Regulated by the Financial Services Authority
********************************************************************

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


Mime
View raw message