Quoting Jeff Caddel <[EMAIL PROTECTED]>:

> Any feedback on this Command implementation?
> 
> The idea is that as a chain of commands is executing objects get 
> aggregated into a map.  The context holds a reference to the map.  At 
> the tail end of the execution chain, this command places the objects 
> from the map into the request as request attributes so that front end 
> components (Tiles, JSP's etc) can display them.
> 

If your application uses WebContext (or one of it's subclasses) as the Context
object being passed down the chain, you already have access to the request
attributes via the getRequestScope() method.  There's also other Map-returning
methods on WebContext for lots of other useful stuff (headers, cookies, session
attributes, context attributes, context init parameters, ...).

On the attribute collections in particular, the Map implementation is two-way
... for example, usage like this:

  public boolean execute(Context context) throws Exception {
    ...
    WebContext wcontext = (WebContext) context;
    // Following is equivalent to request.getAttribute("foo")
    String fooValue = wcontext.getRequestScope().get("foo");
    // Following is equivalent to request.setAttribute("foo", "bar")
    wcontext.getRequestScope().put("foo", "bar");
    ...
  }

makes a request attribute named "foo" with value "bar" visible to a JSP page (or
whatever) that will ultimately create the response.

Does this satisfy the sorts of requirements you were after?

Craig


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to