You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by roncville <ro...@ronsgallery.com> on 2009/10/08 17:09:38 UTC

Basic question on Struts 2 flow

I'm just getting into Struts 2, and have read through some tutorials and
experimented a bit with some small Struts 2 applications.  But, I'm still
missing a fundamental point about the flow, and am looking for help.  My
background with JSPs and even HTML is limited, so I apologize if this is
ridiculously elementary, which it probably is.

Here's a simple 2 page application snippet to illustrate my question:
- Page 1 has a button labeled "Edit User Profile".
- Page 2 shows the user profile with a couple editable fields (e.g. name and
email address), and a button labeled 'Submit Changes'.  The page when first
displayed should be populated with the existing profile.  The user can then
edit fields and submit the page.  I placed the fields within a form tied to
action USER_PROFILE_ACTION, which is tied to an action class. I defined the
fields using textfield tags.

My issue is in initially displaying Page 2.  If I define the Page 1 button
to reference the Page 2 JSP file directly, then Page 2 is displayed, but
with empty fields.  That is, no getters are called, and the fields aren't
prepopulated.

So, I instead did something that didn't really seem quite right to me. I
defined the Page 1 button to reference action USER_PROFILE_ACTION instead of
the Page 2 JSP file.  Now the initial display does call the getters and
populate the page.  But, it also calls the action class execute() method,
which I don't want because at initial display the submit action hasn't yet
occured.

Thanks for any clarification you can provide.
-- 
View this message in context: http://www.nabble.com/Basic-question-on-Struts-2-flow-tp25803238p25803238.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Basic question on Struts 2 flow

Posted by Greg Lindholm <gr...@gmail.com>.
All of your links and forms etc in your applications should point to
'actions' they should never point directly to jsp files. (I.e. the user
should never see a url in the address bar that end in .jsp).
It's is normal to have noop actions that do nothing but return 'SUCCESS'.

You would do yourself a big favor if you went and got the book Struts 2 In
Action form Manning. You will save yourself a huge amount of time in the
long run.

On Thu, Oct 8, 2009 at 11:09 AM, roncville <ro...@ronsgallery.com> wrote:

>
> I'm just getting into Struts 2, and have read through some tutorials and
> experimented a bit with some small Struts 2 applications.  But, I'm still
> missing a fundamental point about the flow, and am looking for help.  My
> background with JSPs and even HTML is limited, so I apologize if this is
> ridiculously elementary, which it probably is.
>
> Here's a simple 2 page application snippet to illustrate my question:
> - Page 1 has a button labeled "Edit User Profile".
> - Page 2 shows the user profile with a couple editable fields (e.g. name
> and
> email address), and a button labeled 'Submit Changes'.  The page when first
> displayed should be populated with the existing profile.  The user can then
> edit fields and submit the page.  I placed the fields within a form tied to
> action USER_PROFILE_ACTION, which is tied to an action class. I defined the
> fields using textfield tags.
>
> My issue is in initially displaying Page 2.  If I define the Page 1 button
> to reference the Page 2 JSP file directly, then Page 2 is displayed, but
> with empty fields.  That is, no getters are called, and the fields aren't
> prepopulated.
>
> So, I instead did something that didn't really seem quite right to me. I
> defined the Page 1 button to reference action USER_PROFILE_ACTION instead
> of
> the Page 2 JSP file.  Now the initial display does call the getters and
> populate the page.  But, it also calls the action class execute() method,
> which I don't want because at initial display the submit action hasn't yet
> occured.
>
> Thanks for any clarification you can provide.
> --
> View this message in context:
> http://www.nabble.com/Basic-question-on-Struts-2-flow-tp25803238p25803238.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>