You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mazhar, Osman (Home Office)" <Os...@lls.org> on 2008/01/29 19:31:07 UTC

help with execAndWait

Hello,

 

I am trying to use the execAndWait interceptor. My struts.xml looks
like:

 

<action name="foo" method="input" class="org.lls.classA">

<result name="input">foo.jsp</result>

</action>

<action name="foo_process" method="processFoo" class="org.lls.classA">

<interceptor-ref name="defaultStack"/>

<interceptor-ref name="token"/>

<!--

<interceptor-ref name="execAndWait">

<param name="delay">100</param>

<param name="delaySleepInterval">50</param>

</interceptor-ref>

-->   

<result name="success">foo-success.jsp</result>

<result name="wait">foo-wait.jsp</result>

<result name="input">foo.jsp</result>

<result name="invalid.token">foo.jsp</result>

</action>

 

Now in my action class, I have a bean with appropriate getter and setter
methods on it. The foo.jsp has a form which is mapped to attributes of
the bean in the action class. For example, <s:textfield
name="myBean.name".../>. The form tag looks like <s:form
action="foo_process"...>

 

When I run the application with the given struts.xml above, myBean gets
populated properly in the processFoo method (I'm assuming the Parameter
interceptor does that).

 

However, when I uncomment and try to use the execAndWait interceptor,
for some reason, myBean comes out to be NULL in processFoo().

 

Any help will be appreciated.

 

- Osman

 


______________________________________________________________________
This e-mail has been scanned by The Leukemia & Lymphoma Society Managed Email Content Service, provided by Verizon Business.

NOTICE: This message, including all attachments transmitted with it, is for the use of the addressee only. It may contain proprietary, confidential and/or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, you must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message. If you believe you have received this message in error, please delete it and all copies of it from your system and notify the sender immediately by reply e-mail. Thank you.


RE: Struts validator

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
Struts valdiator developers, Doesn't struts support this requirment?

-----Original Message-----
From: Zhang, Larry (L.) 
Sent: Friday, February 01, 2008 10:55 AM
To: 'Struts Users Mailing List'
Subject: RE: Struts validator


No, I am using struts 1.1, I would like to implement the following case:
In valiation.xml:

 <form name="/myAction">
		 <!--if submit button 1 clicked, I validate the
following field>-->
		<field property="myProperty" depends="required">
			<msg name="required" key="error.key1" />
		</field>   

		<!--if submit button 2 clicked, I validate the following
field>-->
		<field property="name" depends="myValidator">
			<msg name="myValidator"	key="error.key2" /> 
		</field>
</form>  


I don't want to validate both fields at the same time when just one
submit button is clicked. Your helps are appreciated!

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, February 01, 2008 10:45 AM
To: Struts Users Mailing List
Subject: RE: Struts validator

--- "Zhang, Larry (L.)" <lz...@ford.com> wrote:
> We are not using Struts 2 tag and thus I can't use s:submit tag. 

Are you using Struts 2 at all?

You can still use the generated HTML as a template to create your own
HTML,
although... not sure why you wouldn't just use the tag in this case.

Dave


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


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


RE: Struts validator

Posted by Alexandru BARBAT <al...@ucs.ro>.
Hi,

You can override method 
 public String getValidationKey(ActionMapping mapping,
                                   HttpServletRequest request) {..}

>From your ValidatorForm (it doesn't matter if it is dyna or not)

And return different validation keys for each button pressed.

Validation key identify the rules of validation.

The validation file will look then something like:

<form name="myAction_button1">
		 <!--if submit button 1 clicked, I validate the
following field>-->
		<field property="myProperty" depends="required">
			<msg name="required" key="error.key1" />
		</field>   
</form>

<form name="myAction_button2">
		<!--if submit button 2 clicked, I validate the following
field>-->
		<field property="name" depends="myValidator">
			<msg name="myValidator"	key="error.key2" /> 
		</field>
</form>


alex

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, February 01, 2008 6:29 PM
To: Struts Users Mailing List
Subject: RE: Struts validator

--- "Zhang, Larry (L.)" <lz...@ford.com> wrote:
> No, I am using struts 1.1,

Oh, wow.

Does validwhen[1] not exist in S1.1? You can always create a custom
validator
as well if you find your validation stretches what's easy to do with the
existing validation configuration possibilities. You may also be able to
combine declarative validation (via XML) and Java-based validation, although
it's been a pretty long time since I've thought about that :)

Dave

[1] http://struts.apache.org/1.1/userGuide/dev_validator.html (about 1/3 of
the way down)


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



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


RE: Struts validator

Posted by Dave Newton <ne...@yahoo.com>.
--- "Zhang, Larry (L.)" <lz...@ford.com> wrote:
> No, I am using struts 1.1,

Oh, wow.

Does validwhen[1] not exist in S1.1? You can always create a custom validator
as well if you find your validation stretches what's easy to do with the
existing validation configuration possibilities. You may also be able to
combine declarative validation (via XML) and Java-based validation, although
it's been a pretty long time since I've thought about that :)

Dave

[1] http://struts.apache.org/1.1/userGuide/dev_validator.html (about 1/3 of
the way down)


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


RE: Struts validator

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
No, I am using struts 1.1, I would like to implement the following case:
In valiation.xml:

 <form name="/myAction">
		 <!--if submit button 1 clicked, I validate the
following field>
		<field property="myProperty" depends="required">
			<msg name="required" key="error.key1" />
		</field>   

		<!--if submit button 2 clicked, I validate the following
field>
		<field property="name" depends="myValidator">
			<msg name="myValidator"	key="error.key2" /> 
		</field>
</form>  


I don't want to validate both fields at the same time when just one
submit button is clicked. Your helps are appreciated!

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, February 01, 2008 10:45 AM
To: Struts Users Mailing List
Subject: RE: Struts validator

--- "Zhang, Larry (L.)" <lz...@ford.com> wrote:
> We are not using Struts 2 tag and thus I can't use s:submit tag. 

Are you using Struts 2 at all?

You can still use the generated HTML as a template to create your own
HTML,
although... not sure why you wouldn't just use the tag in this case.

Dave


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


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


RE: Struts validator

Posted by Dave Newton <ne...@yahoo.com>.
--- "Zhang, Larry (L.)" <lz...@ford.com> wrote:
> We are not using Struts 2 tag and thus I can't use s:submit tag. 

Are you using Struts 2 at all?

You can still use the generated HTML as a template to create your own HTML,
although... not sure why you wouldn't just use the tag in this case.

Dave


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


RE: Struts validator

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
We are not using Struts 2 tag and thus I can't use s:submit tag. 

-----Original Message-----
From: David Harland [mailto:dharland@ufi.com] 
Sent: Friday, February 01, 2008 10:01 AM
To: Struts Users Mailing List
Subject: RE: Struts validator

You can do it by having 3 different methods such as

method1() method2() method3() and then have 

validateMethod1() validateMethod2() validateMethod3() 

then in your form 

<s:submit key="button.method1" method="method1"/> 
<s:submit key="button.method2" method="method2"/> 
<s:submit key="button.method3" method="method3"/> 

or you can do by using action aliases and have three validation xml
files.

http://struts.apache.org/2.0.11/docs/validation.html

-----Original Message-----
From: Zhang, Larry (L.) [mailto:lzhang20@ford.com] 
Sent: 01 February 2008 14:45
To: Struts Users Mailing List
Subject: RE: Struts validator

 
Can some Struts guru answer the following questions?
-----Original Message-----
From: Zhang, Larry (L.)
Sent: Thursday, January 31, 2008 3:27 PM
To: 'Struts Users Mailing List'
Subject: Struts validator

Hello coworkers,

I have a questions regarding the struts validation..., say I have three
text fields to be validated in struts validation, and three submit
buttons as well. When I submit one buttion, I only need to validate one
field, and when I click on the other submit button, I need to validate
the other field. Currently, all three fields are validated even though I
don't need to. Is there any way to overcome this issue?

Thanks. 

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


- ------
ML {UFI}

______________________________________________________________________
Ufi Limited 
Registered in England No.  3980770 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

learndirect Solutions Ltd 
Registered in England No. 5081669 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

UFI Charitable Trust 
Registered in England No.  3658378 
Registered Charity No.  1081028 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

This email has been scanned by the MessageLabs Email Security System.

______________________________________________________________________

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


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


RE: Struts validator

Posted by David Harland <dh...@ufi.com>.
You can do it by having 3 different methods such as

method1() method2() method3() and then have 

validateMethod1() validateMethod2() validateMethod3() 

then in your form 

<s:submit key="button.method1" method="method1"/> 
<s:submit key="button.method2" method="method2"/> 
<s:submit key="button.method3" method="method3"/> 

or you can do by using action aliases and have three validation xml
files.

http://struts.apache.org/2.0.11/docs/validation.html

-----Original Message-----
From: Zhang, Larry (L.) [mailto:lzhang20@ford.com] 
Sent: 01 February 2008 14:45
To: Struts Users Mailing List
Subject: RE: Struts validator

 
Can some Struts guru answer the following questions?
-----Original Message-----
From: Zhang, Larry (L.)
Sent: Thursday, January 31, 2008 3:27 PM
To: 'Struts Users Mailing List'
Subject: Struts validator

Hello coworkers,

I have a questions regarding the struts validation..., say I have three
text fields to be validated in struts validation, and three submit
buttons as well. When I submit one buttion, I only need to validate one
field, and when I click on the other submit button, I need to validate
the other field. Currently, all three fields are validated even though I
don't need to. Is there any way to overcome this issue?

Thanks. 

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


- ------
ML {UFI}

______________________________________________________________________
Ufi Limited 
Registered in England No.  3980770 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

learndirect Solutions Ltd 
Registered in England No. 5081669 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

UFI Charitable Trust 
Registered in England No.  3658378 
Registered Charity No.  1081028 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

This email has been scanned by the MessageLabs Email Security System.

______________________________________________________________________

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


RE: Struts validator

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
 
Can some Struts guru answer the following questions?
-----Original Message-----
From: Zhang, Larry (L.) 
Sent: Thursday, January 31, 2008 3:27 PM
To: 'Struts Users Mailing List'
Subject: Struts validator

Hello coworkers,

I have a questions regarding the struts validation..., say I have three
text fields to be validated in struts validation, and three submit
buttons as well. When I submit one buttion, I only need to validate one
field, and when I click on the other submit button, I need to validate
the other field. Currently, all three fields are validated even though I
don't need to. Is there any way to overcome this issue?

Thanks. 

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


Struts validator

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
Hello coworkers,

I have a questions regarding the struts validation..., say I have three
text fields to be validated in struts validation, and three submit
buttons as well. When I submit one buttion, I only need to validate one
field, and when I click on the other submit button, I need to validate
the other field. Currently, all three fields are validated even though I
don't need to. Is there any way to overcome this issue?

Thanks. 

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


Re: [struts] help with execAndWait

Posted by Dale Newfield <Da...@Newfield.org>.
Mazhar, Osman (Home Office) wrote:
> I turned debug level logging for struts and xwork packages.
> I see that the ParametersInterceptor is being called indeed for both
> scenarios (with or without execAndWait)
> 
> However, one interesting thing is when I comment out the "delay" and
> "delaySleepInterval" params from the execAndWait interceptor, I don't
> get this problem.
> 
> Maybe this problem has to do with timing? Not sure but this is weird...

If you set those parameters in a stack definition, and then refer to 
that stack in the action, what happens?

-Dale

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


RE: [struts] help with execAndWait

Posted by "Mazhar, Osman (Home Office)" <Os...@lls.org>.
I turned debug level logging for struts and xwork packages.
I see that the ParametersInterceptor is being called indeed for both
scenarios (with or without execAndWait)

However, one interesting thing is when I comment out the "delay" and
"delaySleepInterval" params from the execAndWait interceptor, I don't
get this problem.

Maybe this problem has to do with timing? Not sure but this is weird...

-----Original Message-----
From: Dale Newfield [mailto:Dale@Newfield.org] 
Sent: Tuesday, January 29, 2008 3:21 PM
To: Struts Users Mailing List
Subject: Re: [struts] help with execAndWait

Mazhar, Osman (Home Office) wrote:
> That is an interesting point. The bean is a hibernate object, however,
I
> am not retrieving it from the database, but rather only trying to
> populate it from the form values.

You should be able to tell from the call stack which interceptors have 
been called--can you verify that parameters is included?

I don't know if including more than one interceptor-ref inside the 
action definition uses all of them (in what order?) or just the last 
one--I always define  the stacks I need separately and just refer to the

appropriate one within my action definition...

> So, it's a CREATE operation if you look at it from the CRUD
perspective.
> 
> After reading on HibernateAndSpringEnabledExecuteAndWaitInterceptor,
> what I understand is it would be necessary for objects being populated
> from the database (using Hibernate obviously)

Does this created object contain any references to other DB objects?

-Dale

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


______________________________________________________________________
This e-mail has been scanned by The Leukemia & Lymphoma Society Managed Email Content Service, provided by Verizon Business.

NOTICE: This message, including all attachments transmitted with it, is for the use of the addressee only. It may contain proprietary, confidential and/or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, you must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message. If you believe you have received this message in error, please delete it and all copies of it from your system and notify the sender immediately by reply e-mail. Thank you.



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


Re: [struts] help with execAndWait

Posted by Dale Newfield <Da...@Newfield.org>.
Mazhar, Osman (Home Office) wrote:
> That is an interesting point. The bean is a hibernate object, however, I
> am not retrieving it from the database, but rather only trying to
> populate it from the form values.

You should be able to tell from the call stack which interceptors have 
been called--can you verify that parameters is included?

I don't know if including more than one interceptor-ref inside the 
action definition uses all of them (in what order?) or just the last 
one--I always define  the stacks I need separately and just refer to the 
appropriate one within my action definition...

> So, it's a CREATE operation if you look at it from the CRUD perspective.
> 
> After reading on HibernateAndSpringEnabledExecuteAndWaitInterceptor,
> what I understand is it would be necessary for objects being populated
> from the database (using Hibernate obviously)

Does this created object contain any references to other DB objects?

-Dale

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


RE: [struts] help with execAndWait

Posted by "Mazhar, Osman (Home Office)" <Os...@lls.org>.
That is an interesting point. The bean is a hibernate object, however, I
am not retrieving it from the database, but rather only trying to
populate it from the form values. 

So, it's a CREATE operation if you look at it from the CRUD perspective.

After reading on HibernateAndSpringEnabledExecuteAndWaitInterceptor,
what I understand is it would be necessary for objects being populated
from the database (using Hibernate obviously)

Unless I'm mistaken....

-----Original Message-----
From: Dale Newfield [mailto:Dale@Newfield.org] 
Sent: Tuesday, January 29, 2008 1:46 PM
To: Struts Users Mailing List
Subject: Re: [struts] help with execAndWait

Mazhar, Osman (Home Office) wrote:
> I am trying to use the execAndWait interceptor.

If this bean is retrieved from your DB, then it's likely the DB session 
is being closed.

http://wiki.opensymphony.com/display/WW/HibernateAndSpringEnabledExecute
AndWaitInterceptor

-Dale

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


______________________________________________________________________
This e-mail has been scanned by The Leukemia & Lymphoma Society Managed Email Content Service, provided by Verizon Business.

NOTICE: This message, including all attachments transmitted with it, is for the use of the addressee only. It may contain proprietary, confidential and/or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, you must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message. If you believe you have received this message in error, please delete it and all copies of it from your system and notify the sender immediately by reply e-mail. Thank you.



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


Re: [struts] help with execAndWait

Posted by Dale Newfield <Da...@Newfield.org>.
Mazhar, Osman (Home Office) wrote:
> I am trying to use the execAndWait interceptor.

If this bean is retrieved from your DB, then it's likely the DB session 
is being closed.

http://wiki.opensymphony.com/display/WW/HibernateAndSpringEnabledExecuteAndWaitInterceptor

-Dale

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