I am actually doing something similar inside a couple of struts 2
applications I've written and I am able to populate the value stack and or
request just fine.
I do the following,
<code>
/*
* Interceptor
*/
public String intercept(ActionInvocation _invocation) throws
Exception {
MenuContext menuContext = new MenuContext();
_invocation.getStack().set("menuContext", menuContext);
String response = null;
try {
response = _invocation.invoke();
} catch(Exception e){
ISFLogger.error("Error invoking action",
getClass(), "intercept(ActionInvocation)",e);
throw e;
}
return response;
}
/*
* JSP
* The menucontext object has a list named "sectionMenu" declared
on it that is being used for iteration.
*/
<struts:iterator id="statusLink" status="barIteratorStatus" value=
"menuContext.sectionMenu">
<!-- Do a bunch of stuff -->
</struts:iterator>
</code>
I really suggst you dont make the ActionContext final. Because the context
changes for each request (its mutable) and making it final is a misleading
statement.
I also suggest you use the value stack and not the session or request, its
just easier to get the information with struts tags when you do.
Matt Filion
CSC - GTS --> Raytheon - ISF
(818) 468-6271
[EMAIL PROTECTED]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit
written agreement or government initiative expressly permitting the use of
e-mail for such purpose.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
"Sarr, Nathan" <[EMAIL PROTECTED]>
03/07/2007 08:39 AM
Please respond to
"Struts Users Mailing List" <[email protected]>
To
<[email protected]>
cc
Subject
Interceptor + putting information on the request
Hello,
I am using struts 2.0.6. I wrote an interceptor to use with Acegi
security to place the UserDetails object on the request so I could
access it on my JSP page. However when I tried to access the object on
the page, it was not found.
I then instead placed it on the session using the following which
worked:
[code]
final ActionContext context = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest)
context.get(HTTP_REQUEST);
HttpSession session = request.getSession();
Authentication auth =
SecurityContextHolder.getContext().getAuthentication();
if(auth != null)
{
if(auth.getPrincipal() instanceof UserDetails)
{
IrUser user = (IrUser)auth.getPrincipal();
session.setAttribute("user", user);
}
}
return invocation.invoke();
[/code]
I was wondering is there any way to place this information on the
request in an interceptor.
Thanks for the help.
-Nate