You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Andrews <jo...@in1solutions.com> on 2005/10/12 16:57:07 UTC

action class not being called for repeat initial requests when using validation

I have the action mapping below in my struts config file:

        <action
            path="/packageActionCreateT"
            type="struts.actions.packages.PackageAction"
            name="PackageForm"
            input="/pages/createPackage.jsp"
            parameter="dispatch"
            scope="session">
        <forward name="createPackagePage" path="/pages/createPackage.jsp"/>
        <forward name="createPackageTResults"
path="/pages/createPackageTResults.jsp"/>
        </action>

When I request that the corresponding action be executed using the URL:

http://www.xxxxxx.com/packages/packageActionCreateT.do?dispatch=createPackag
e


Then the action is only executed once - unless i hit the submit button on
the createPackage.jsp page. On all other ocasions the action will act just
like a forward. It will just forward straight back to the createPackage.jsp
page. This I presume? is because the validation is finding the corresponding
formbean in the session and then going straight back to the jsp page.
However it is not acting exactly like a normal validation because the
incorrect fields are not highlighted.

Is there someway to get the validator to only return directly to the jsp
page only after a submit - not after an initial request? - or is there some
other good way to solve/design around this issue?

Thanks for any help
John



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


Re: action class not being called for repeat requests when using validation

Posted by Dave Newton <ne...@pingsite.com>.
John Andrews wrote:

>>Is there someway to get the validator to only return directly to the jsp
>>page only after a submit - not after an initial request? - or is there
>>some other good way to solve/design around this issue?
>>    
>>
I simply turn off auto-validation.

In my Actions I forward to the input forward on a GET. On a POST (which 
all my forms submit with) I run the form's validate method and do the 
appropriate thing.

This is the easiest way to use the same Action classes for initial form 
display and form processing, although some might argue that this isn't a 
good idea :)

Dave



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


Where to go after unsuccesfull ActionForm validation?

Posted by Koen Jans <ko...@student.kuleuven.be>.
Here is the problem; (sorry for long text)

Normally, when you validate an actionform and there is a validation
error, the "input" argument
in struts-config.xml points you back to the inputform, so you can place
an error message
on the form where the incorrect input is..

First problem:
----------------------
If the input form uses some parameter from request, it cannot find this
parameter
when you try to go back to the form after an unsuccesful validation..
For example; a form where you add a user, and there is a parameter
"languages"
from which the user can select a language on the form..

(in the example the "/actions/adduserform" collects the languages and
puts them
as a parameter in request, so the add user form displays those languages
from that parameter)

If after unsuccesful validation, you just point back to
/forms/adduserform.jsp,
you will get an error because the jsp page cannot find the attribute
languages anymore.
I solved this problem by recollecting the languages on unsuccesfull
validation..

(so struts-config.xml looks like:)

<action path="/actions/adduserform"
                 type="user.actions.AddUserFormAction">
            <forward name="success"  path="/forms/adduserform.jsp" />
</action>
     
<action path="/actions/adduser"
     type="user.actions.AddUserAction"
     name="addUserFormBean"
     scope="request"
     validate="true"
     input="/actions/adduserform.do">
            <forward name="succes" path="/succes.do" />
</action>

So far, so good.. but:

Real problem:
-----------------
If (for instance on a user edit), you first choose which user to edit
and then
go to an edit form, how can you on unsuccesful validation of the edit form
return to that editform? The choice of which user you choose is lost......

So.. you collect all the users:

<action path="/actions/edituserselectionform"
      type="user.actions.CollectusersAction">
    <forward name="success" path="/forms/edituserselectionform.jsp" />
</action>
       
You choose which one you wanna edit:

<action path="/actions/edituserform"
      type="user.actions.EdituserFormAction"
      name="selectedUserFormBean">
<forward name="success"  path="/forms/edituserform.jsp" />
</action>
       
And you display the edit user form here..

<action path="/actions/edituser"
      type="user.actions.EdituserAction"
      name="edituserFormBean"
      scope="request"
      validate="true"
      input="??????????????????">
     <forward name="success"  path="/actions/usersoverview.do" />
</action>

If i put as input "/actions/edituserform.do", it cannot remember which
user i selected.
Any suggestions?

Thanks for your time!

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


RE: action class not being called for repeat requests when using validation

Posted by John Andrews <jo...@in1solutions.com>.
Hi Sunil,

I am much clearer now on what the problem is.

It is a problem with the struts validator.

If I follow the following sequence:

1) Request a URL
2) Struts reads action mapping
3) Struts creates a formbean
4) Struts passes this FORMBean to the validator - Before!!! the page has
ever been displayed
5) IF validation is successfuly based on the initial values in the
formbean - struts then passes control to the acion class. I then have the
action class completing the population of the formbean with values from the
DB
6) IF the validation fails - struts displays the jsp page - without going
into the action class

Conclusion is that the Initial Values put into the formbean in the
struts-config file (not in the action class) must validate for successful
display of the page.

Is there a way round this - as the implication is that it would be
impossible to validate arrays and such like as they could never be specified
in struts-config?

John

-----Original Message-----
From: Sunil_Sahu@Keane.com [mailto:Sunil_Sahu@Keane.com]
Sent: 13 October 2005 05:02
To: Struts Users Mailing List
Subject: RE: action class not being called for repeat initial requests
when using validation


John,

Can you explain your problem little bit more, i am not getting your
problem exactly.

Sunil



"John Andrews" <jo...@in1solutions.com>
10/12/2005 10:16 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
"Struts Users Mailing List" <us...@struts.apache.org>, "Martin Gainty"
<mg...@hotmail.com>
cc

Subject
RE: action class not being called for repeat initial requests when using
validation






Hi Martin,

Thanks for your suggestion.

Basically the problem that I have is that my action class is only being
called intermittently - the rest of the time  I am just being sent
straight
to the jsp that I want to display - without ever getting into the action
class. This is causing a major problem since the action class is
neccessary
to populate the form's formbean correctly.

John

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: 12 October 2005 17:00
To: Struts Users Mailing List
Subject: Re: action class not being called for repeat initial requests
when using validation


John
There are a number of solutions I would suggest looking at JBuilder doc
located at
http://bdn.borland.com/borcon2004/article/paper/0,1963,32246,00.html

the fastest way is for your button to route to your jsp page is to route
to
the page identified by the action mapping in struts-config.xml For example
here is a form which routes to logon page URI when username, password are
satisfied and submit is called
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form
action="logon.do" focus="userName"><br>        User Name: <html:text
maxlength="16" property="userName" size="16"/><br />        Password:
<html:text maxlength="16" property="password" size="16"/><br
/><html:submit
value="Submit" property="Submit"/><html:reset
value="Reset"/></html:form>you
could also place in a html:link to forward such as <html:link
forward="Home">
whereas Home idenitifies a URI which you will link to
from the definition associated with 'home' in the Global forwards defined
in
struts-config.xml
HTH,
Martin-

----- Original Message -----
From: "John Andrews" <jo...@in1solutions.com>
To: <us...@struts.apache.org>
Sent: Wednesday, October 12, 2005 10:57 AM
Subject: action class not being called for repeat initial requests when
using validation


>I have the action mapping below in my struts config file:
>
>        <action
>            path="/packageActionCreateT"
>            type="struts.actions.packages.PackageAction"
>            name="PackageForm"
>            input="/pages/createPackage.jsp"
>            parameter="dispatch"
>            scope="session">
>        <forward name="createPackagePage"
path="/pages/createPackage.jsp"/>
>        <forward name="createPackageTResults"
> path="/pages/createPackageTResults.jsp"/>
>        </action>
>
> When I request that the corresponding action be executed using the URL:
>
>
http://www.xxxxxx.com/packages/packageActionCreateT.do?dispatch=createPackag

> e
>
>
> Then the action is only executed once - unless i hit the submit button
on
> the createPackage.jsp page. On all other ocasions the action will act
just
> like a forward. It will just forward straight back to the
> createPackage.jsp
> page. This I presume? is because the validation is finding the
> corresponding
> formbean in the session and then going straight back to the jsp page.
> However it is not acting exactly like a normal validation because the
> incorrect fields are not highlighted.
>
> Is there someway to get the validator to only return directly to the jsp
> page only after a submit - not after an initial request? - or is there
> some
> other good way to solve/design around this issue?
>
> Thanks for any help
> John
>
>
>
> ---------------------------------------------------------------------
> 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




---------------------------------------------------------------------
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: action class not being called for repeat initial requests when using validation

Posted by Su...@Keane.com.
John,

Can you explain your problem little bit more, i am not getting your 
problem exactly.

Sunil



"John Andrews" <jo...@in1solutions.com> 
10/12/2005 10:16 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
"Struts Users Mailing List" <us...@struts.apache.org>, "Martin Gainty" 
<mg...@hotmail.com>
cc

Subject
RE: action class not being called for repeat initial requests when using 
validation






Hi Martin,

Thanks for your suggestion.

Basically the problem that I have is that my action class is only being
called intermittently - the rest of the time  I am just being sent 
straight
to the jsp that I want to display - without ever getting into the action
class. This is causing a major problem since the action class is 
neccessary
to populate the form's formbean correctly.

John

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: 12 October 2005 17:00
To: Struts Users Mailing List
Subject: Re: action class not being called for repeat initial requests
when using validation


John
There are a number of solutions I would suggest looking at JBuilder doc
located at
http://bdn.borland.com/borcon2004/article/paper/0,1963,32246,00.html

the fastest way is for your button to route to your jsp page is to route 
to
the page identified by the action mapping in struts-config.xml For example
here is a form which routes to logon page URI when username, password are
satisfied and submit is called
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form
action="logon.do" focus="userName"><br>        User Name: <html:text
maxlength="16" property="userName" size="16"/><br />        Password:
<html:text maxlength="16" property="password" size="16"/><br 
/><html:submit
value="Submit" property="Submit"/><html:reset 
value="Reset"/></html:form>you
could also place in a html:link to forward such as <html:link
forward="Home">
whereas Home idenitifies a URI which you will link to
from the definition associated with 'home' in the Global forwards defined 
in
struts-config.xml
HTH,
Martin-

----- Original Message -----
From: "John Andrews" <jo...@in1solutions.com>
To: <us...@struts.apache.org>
Sent: Wednesday, October 12, 2005 10:57 AM
Subject: action class not being called for repeat initial requests when
using validation


>I have the action mapping below in my struts config file:
>
>        <action
>            path="/packageActionCreateT"
>            type="struts.actions.packages.PackageAction"
>            name="PackageForm"
>            input="/pages/createPackage.jsp"
>            parameter="dispatch"
>            scope="session">
>        <forward name="createPackagePage" 
path="/pages/createPackage.jsp"/>
>        <forward name="createPackageTResults"
> path="/pages/createPackageTResults.jsp"/>
>        </action>
>
> When I request that the corresponding action be executed using the URL:
>
>
http://www.xxxxxx.com/packages/packageActionCreateT.do?dispatch=createPackag

> e
>
>
> Then the action is only executed once - unless i hit the submit button 
on
> the createPackage.jsp page. On all other ocasions the action will act 
just
> like a forward. It will just forward straight back to the
> createPackage.jsp
> page. This I presume? is because the validation is finding the
> corresponding
> formbean in the session and then going straight back to the jsp page.
> However it is not acting exactly like a normal validation because the
> incorrect fields are not highlighted.
>
> Is there someway to get the validator to only return directly to the jsp
> page only after a submit - not after an initial request? - or is there
> some
> other good way to solve/design around this issue?
>
> Thanks for any help
> John
>
>
>
> ---------------------------------------------------------------------
> 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




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



RE: action class not being called for repeat initial requests when using validation

Posted by John Andrews <jo...@in1solutions.com>.
Hi Martin,

Thanks for your suggestion.

Basically the problem that I have is that my action class is only being
called intermittently - the rest of the time  I am just being sent straight
to the jsp that I want to display - without ever getting into the action
class. This is causing a major problem since the action class is neccessary
to populate the form's formbean correctly.

John

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: 12 October 2005 17:00
To: Struts Users Mailing List
Subject: Re: action class not being called for repeat initial requests
when using validation


John
There are a number of solutions I would suggest looking at JBuilder doc
located at
http://bdn.borland.com/borcon2004/article/paper/0,1963,32246,00.html

the fastest way is for your button to route to your jsp page is to route to
the page identified by the action mapping in struts-config.xml For example
here is a form which routes to logon page URI when username, password are
satisfied and submit is called
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form
action="logon.do" focus="userName"><br>        User Name: <html:text
maxlength="16" property="userName" size="16"/><br />        Password:
<html:text maxlength="16" property="password" size="16"/><br /><html:submit
value="Submit" property="Submit"/><html:reset value="Reset"/></html:form>you
could also place in a html:link to forward such as <html:link
forward="Home">
whereas Home idenitifies a URI which you will link to
from the definition associated with 'home' in the Global forwards defined in
struts-config.xml
HTH,
Martin-

----- Original Message -----
From: "John Andrews" <jo...@in1solutions.com>
To: <us...@struts.apache.org>
Sent: Wednesday, October 12, 2005 10:57 AM
Subject: action class not being called for repeat initial requests when
using validation


>I have the action mapping below in my struts config file:
>
>        <action
>            path="/packageActionCreateT"
>            type="struts.actions.packages.PackageAction"
>            name="PackageForm"
>            input="/pages/createPackage.jsp"
>            parameter="dispatch"
>            scope="session">
>        <forward name="createPackagePage" path="/pages/createPackage.jsp"/>
>        <forward name="createPackageTResults"
> path="/pages/createPackageTResults.jsp"/>
>        </action>
>
> When I request that the corresponding action be executed using the URL:
>
>
http://www.xxxxxx.com/packages/packageActionCreateT.do?dispatch=createPackag
> e
>
>
> Then the action is only executed once - unless i hit the submit button on
> the createPackage.jsp page. On all other ocasions the action will act just
> like a forward. It will just forward straight back to the
> createPackage.jsp
> page. This I presume? is because the validation is finding the
> corresponding
> formbean in the session and then going straight back to the jsp page.
> However it is not acting exactly like a normal validation because the
> incorrect fields are not highlighted.
>
> Is there someway to get the validator to only return directly to the jsp
> page only after a submit - not after an initial request? - or is there
> some
> other good way to solve/design around this issue?
>
> Thanks for any help
> John
>
>
>
> ---------------------------------------------------------------------
> 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




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


Re: action class not being called for repeat initial requests when using validation

Posted by Martin Gainty <mg...@hotmail.com>.
John
There are a number of solutions I would suggest looking at JBuilder doc 
located at
http://bdn.borland.com/borcon2004/article/paper/0,1963,32246,00.html

the fastest way is for your button to route to your jsp page is to route to 
the page identified by the action mapping in struts-config.xml For example 
here is a form which routes to logon page URI when username, password are 
satisfied and submit is called
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html:form 
action="logon.do" focus="userName"><br>        User Name: <html:text 
maxlength="16" property="userName" size="16"/><br />        Password: 
<html:text maxlength="16" property="password" size="16"/><br /><html:submit 
value="Submit" property="Submit"/><html:reset value="Reset"/></html:form>you 
could also place in a html:link to forward such as <html:link forward="Home">
whereas Home idenitifies a URI which you will link to
from the definition associated with 'home' in the Global forwards defined in 
struts-config.xml
HTH,
Martin-

----- Original Message ----- 
From: "John Andrews" <jo...@in1solutions.com>
To: <us...@struts.apache.org>
Sent: Wednesday, October 12, 2005 10:57 AM
Subject: action class not being called for repeat initial requests when 
using validation


>I have the action mapping below in my struts config file:
>
>        <action
>            path="/packageActionCreateT"
>            type="struts.actions.packages.PackageAction"
>            name="PackageForm"
>            input="/pages/createPackage.jsp"
>            parameter="dispatch"
>            scope="session">
>        <forward name="createPackagePage" path="/pages/createPackage.jsp"/>
>        <forward name="createPackageTResults"
> path="/pages/createPackageTResults.jsp"/>
>        </action>
>
> When I request that the corresponding action be executed using the URL:
>
> http://www.xxxxxx.com/packages/packageActionCreateT.do?dispatch=createPackag
> e
>
>
> Then the action is only executed once - unless i hit the submit button on
> the createPackage.jsp page. On all other ocasions the action will act just
> like a forward. It will just forward straight back to the 
> createPackage.jsp
> page. This I presume? is because the validation is finding the 
> corresponding
> formbean in the session and then going straight back to the jsp page.
> However it is not acting exactly like a normal validation because the
> incorrect fields are not highlighted.
>
> Is there someway to get the validator to only return directly to the jsp
> page only after a submit - not after an initial request? - or is there 
> some
> other good way to solve/design around this issue?
>
> Thanks for any help
> John
>
>
>
> ---------------------------------------------------------------------
> 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