You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nicolas Robert <nr...@peopleware.lu> on 2003/04/07 15:45:36 UTC

how to reduce validator.xml
Hi,

In validator.xml, I use multipage form definitions.

For each of my form definitions, I've redondant fields definitions.

For example :

 <form name="multipage1">
  <field property="price" depends="integer,range" page="1">
   <arg0 key="validator.price" />
   <arg1 name="range" key="${var:min}"  resource="false"/>
   <arg2 name="range" key="${var:max}"  resource="false"/>
   <var>
    <var-name>min</var-name>
    <var-value>0</var-value>
   </var>
   <var>
    <var-name>max</var-name>
    <var-value>30</var-value>
   </var>
  </field>
  <field property="value1" depends="float" page="1">
   <arg0 key="validator.price" />
  </field>
 </form>

 <form name="multipage2">
  <field property="price" depends="integer,range" page="4">
   <arg0 key="validator.price" />
   <arg1 name="range" key="${var:min}"  resource="false"/>
   <arg2 name="range" key="${var:max}"  resource="false"/>
   <var>
    <var-name>min</var-name>
    <var-value>0</var-value>
   </var>
   <var>
    <var-name>max</var-name>
    <var-value>30</var-value>
   </var>
  </field>
 </form>

 <form name="multipage3">
  <field property="price" depends="integer,range" page="3">
   <arg0 key="validator.price" />
   <arg1 name="range" key="${var:min}"  resource="false"/>
   <arg2 name="range" key="${var:max}"  resource="false"/>
   <var>
    <var-name>min</var-name>
    <var-value>0</var-value>
   </var>
   <var>
    <var-name>max</var-name>
    <var-value>30</var-value>
   </var>
  </field>
 </form>

And I would like to know if there's a way to simplify my form definitions
like that :

<global>
 <constant name="price">
  <arg0 key="validator.price" />
  <arg1 name="range" key="${var:min}"  resource="false"/>
  <arg2 name="range" key="${var:max}"  resource="false"/>
  <var>
   <var-name>min</var-name>
   <var-value>0</var-value>
  </var>
  <var>
   <var-name>max</var-name>
   <var-value>30</var-value>
  </var>
 </constant>
</global>
...
 <form name="multipage1">
  <field property="price" depends="integer,range" page="1">
   ${var:price}
  </field>
  <field property="value1" depends="float" page="1">
   <arg0 key="validator.price" />
  </field>
 </form>
 <form name="multipage2">
  <field property="price" depends="integer,range" page="4">
   ${var:price}
  </field>
 </form>
 <form name="multipage3">
  <field property="price" depends="integer,range" page="3">
   ${var:price}
  </field>
 </form>

Could you help me?


Thanks,


Nicolas

RE: Determining last action

Posted by Mike Jasnowski <mj...@bea.com>.
But is the action really responsible for "generating" the view? No, the tags
on the JSP (IMHO) are the ones with this responsibility, the action merely
provide/prepare data to the view, and interact with a delegate. Sure, some
of this view data could be "WHo am I?" etc..

In any event, I was hoping struts just stored this somewhere as a
convenience, we have concluded we would have to do the same as you describe.

-----Original Message-----
From: Paul Yunusov [mailto:pyunusov@rogers.com]
Sent: Monday, April 07, 2003 10:20 AM
To: Struts Users Mailing List
Subject: Re: Determining last action


On Monday 07 April 2003 10:04 am, Mike Jasnowski wrote:
> Greetings,
>
> I have a need to determine the last action for purposes of refreshing via
a
> link. I've looked at the findActionConfig() variants and these seem to
> assume you have some previous knowledge, or path information. What I need
> though is just the path to the action that forwarded to a JSP, then use
> this path in this refresh link. Is using the HTTP referrer heading safe
> enough or not?
>
> I looked at the archives, but couldn't find an answer to this.  Is there
> something like a Globals.LAST_ACTION_PATH attribute somewhere?
>
> TIA,
> Mike

Simplify, simplify. If the action is responsible for generating the view,
charge this action with embedding its own invocation semantics in the link
within the view.

Your action generates a view that's supposed to have a link that invokes the
same action. Have the action buid the right link, that's it.

Paul

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



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


Re: Determining last action

Posted by Paul Yunusov <py...@rogers.com>.
On Monday 07 April 2003 10:04 am, Mike Jasnowski wrote:
> Greetings,
>
> I have a need to determine the last action for purposes of refreshing via a
> link. I've looked at the findActionConfig() variants and these seem to
> assume you have some previous knowledge, or path information. What I need
> though is just the path to the action that forwarded to a JSP, then use
> this path in this refresh link. Is using the HTTP referrer heading safe
> enough or not?
>
> I looked at the archives, but couldn't find an answer to this.  Is there
> something like a Globals.LAST_ACTION_PATH attribute somewhere?
>
> TIA,
> Mike

Simplify, simplify. If the action is responsible for generating the view, 
charge this action with embedding its own invocation semantics in the link 
within the view.

Your action generates a view that's supposed to have a link that invokes the 
same action. Have the action buid the right link, that's it.

Paul

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


Determining last action

Posted by Mike Jasnowski <mj...@bea.com>.
Greetings,

I have a need to determine the last action for purposes of refreshing via a
link. I've looked at the findActionConfig() variants and these seem to
assume you have some previous knowledge, or path information. What I need
though is just the path to the action that forwarded to a JSP, then use this
path in this refresh link. Is using the HTTP referrer heading safe enough or
not?

I looked at the archives, but couldn't find an answer to this.  Is there
something like a Globals.LAST_ACTION_PATH attribute somewhere?

TIA,
Mike


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