On 11/30/06 5:29 PM, "Don Brown" <[EMAIL PROTECTED]> wrote:
> If you only need request-scoped data, you don't need to bother with
> the ScopeInterceptor or even the ServletRequestAware interface.
> Simply define a getter on your action that returns the object in
> question, then access it via your JSP via JSP EL (JSP 2.0), a JSTL
> expression, or a Struts 2 property tag.
To expand on Don's answer. (I know he's busy. Thanks Don.)
Let's say you have the following Action (this is not a complete listing):
public class MyAction extends ActionSupport {
private String dataRetrievedFromSessionBean;
public String execute () throws Exception {
MySessionBean sb = getSessionBean ();
this.dataRetrievedFromSessionBean = sb.getMyData ();
return SUCCESS;
}
public String getDataRetrievedFromSessionBean () {
return this.dataRetrievedFromSessionBean;
}
private MySessionBean getSessionBean () {
// Some code to get your EJB.
}
}
In your JSP you can display this data with the <s:property> tag:
<s:property value="%{dataRetrievedFromSessionBean}" />
That's it.
You don't need to mess with Session scope, other interceptors, or any of
that stuff. It's very simple and elegant. Almost too much so. It eluded me
for a while, but now I'm really starting to get it, and it's good.
Mark
--
Mark Menard
personal: http://www.vitarara.org/
business: http://www.vitarara.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]