I'm not a commiter, but the idea sounds reasonable to me. I do something very similiar in Struts when using Jelly scripts, where I have a struts action that takes all of the http 'stuff' and puts it into the jelly context, executes a script and then takes the data from the context and puts it back into the appropriate http scope.

If this is accepted, A couple more would be nice to have for session and application scope as well.

Robert

Jeff Caddel wrote:
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.


Is this:
A) A terrible idea violating abstractions of the Chain of Responsibility pattern? B) A good idea demonstrating good use of the pattern?
C) Something else?



public class ContextToRequestCommand implements Command { String key = "contextToRequest";

public boolean execute(Context context) throws Exception {
HttpServletRequest request = (HttpServletRequest)context.get("request");
Map map = (Map)context.get(key);
if (map == null) {
return false;
}


       Iterator pairs = map.entrySet().iterator();
       while (pairs.hasNext()) {
           Map.Entry pair = (Map.Entry)pairs.next();
           request.setAttribute((String)pair.getKey(), pair.getValue());
       }

       return false;
   }
}


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




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



Reply via email to