struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: Struts2: Pre-populate form with values from a session bean
Date Thu, 04 Dec 2008 18:45:27 GMT
A couple of comments, although with the configuration provided I'm not getting as far as you

--- On Thu, 12/4/08, Robert Graf-Waczenski wrote:
> <struts>
>   <package namespace="/blah/blurp" 
>            name="com.blah.blurp"
>            extends="struts-default">
>     <action name="add"
>             class="com.blah.blurp.actions2.AddAction">
>       <result name="success"
>               type="redirect">
>         /JSP/blah/blurp/add.jsp
>       </result>
>     </action>
>   </package>
> </struts>

My first concern is that this is a "redirect" directly to a JSP. That will eliminate useful
functioning of the S2 tags (I thought, anyway) since the request won't be handled by the S2
request handling--meaning nothing will be on the stack at all.

If your goal is to redirect back to the action you should use "redirectAction"--redirecting
*directly* to a JSP that expects to be able to access S2 functionality is almost certainly
not what you want.

> public class AddAction implements
>     ModelDriven<AddAction.SessionValues>,
>     ServletRequestAware
> ...

You may want to consider implementing SessionAware; it's simpler and avoids coupling to the
servlet spec.

> public String getmAddress() {
>     return mAddress;
> } // ... and the other getters

I don't believe these are following the JavaBean spec, although I don't know if that's what's
causing any of your issues. IIRC they'd need to get getMAddress. That said, stylistically
I'm dead-set against exposing the internal naming convention to the getters/setters, irrespective
of if they're JavaBean-compliant names. (I tested w/ what I thought were compliant names and
a non-"redirect" type (which just won't work) and both values appear.)

I'd probably address these issues first, in particular the first and third, and we can take
it from there.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message