You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Evans <ds...@gmail.com> on 2011/01/19 23:21:04 UTC
Add a map to HttpRequest attributes
Hello,
I have a business layer method that returns a map of objects. I would
like to put all of the keys and values of this map into the request
attribute map, like this:
HttpRequest.putAll(map);
This of course doesn't work, as the request isn't a map and the
attributes map isn't available as a map.
Are there any Struts or Apache commons utils that will do this?
Thanks,
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Add a map to HttpRequest attributes
Posted by Dave Evans <ds...@gmail.com>.
Yes, that's what I've done, I was just thinking that it was a common
operation and maybe there was a util built in to the frameworks I'm
already using.
On Wed, Jan 19, 2011 at 3:16 PM, Alfredo Manuel Osorio Martinez
<al...@afirme.com> wrote:
> What about iterating the map and put each attribute in the HttpRequest.
>
> Something like this:
> Map<String, Object> myMap = getMyMap();
> Set<Map.Entry<String, Object>> entrySet = myMap.entrySet();
> for (Map.Entry<String, Object> entry : myMap.entrySet()) {
> request.setAttribute(entry.getKey(), entry.getValue());
> }
>
> Alfredo Osorio
>
> -----Mensaje original-----
> De: Dave Evans [mailto:dsevans93@gmail.com]
> Enviado el: Wednesday, January 19, 2011 4:21 PM
> Para: Struts Users Mailing List
> Asunto: Add a map to HttpRequest attributes
>
> Hello,
>
> I have a business layer method that returns a map of objects. I would
> like to put all of the keys and values of this map into the request
> attribute map, like this:
> HttpRequest.putAll(map);
> This of course doesn't work, as the request isn't a map and the
> attributes map isn't available as a map.
>
> Are there any Struts or Apache commons utils that will do this?
>
> Thanks,
>
> Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Add a map to HttpRequest attributes
Posted by Alfredo Manuel Osorio Martinez <al...@afirme.com>.
What about iterating the map and put each attribute in the HttpRequest.
Something like this:
Map<String, Object> myMap = getMyMap();
Set<Map.Entry<String, Object>> entrySet = myMap.entrySet();
for (Map.Entry<String, Object> entry : myMap.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue());
}
Alfredo Osorio
-----Mensaje original-----
De: Dave Evans [mailto:dsevans93@gmail.com]
Enviado el: Wednesday, January 19, 2011 4:21 PM
Para: Struts Users Mailing List
Asunto: Add a map to HttpRequest attributes
Hello,
I have a business layer method that returns a map of objects. I would
like to put all of the keys and values of this map into the request
attribute map, like this:
HttpRequest.putAll(map);
This of course doesn't work, as the request isn't a map and the
attributes map isn't available as a map.
Are there any Struts or Apache commons utils that will do this?
Thanks,
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org