[seam-dev] How to store data in contexts

Dan Allen dan.j.allen at gmail.com
Fri May 8 03:18:32 EDT 2009


On Thu, May 7, 2009 at 9:06 AM, Gavin King <gavin.king at gmail.com> wrote:

> Right.
>
> Contextual is there so that frameworks can put stuff in contexts for
> "special" cases.
>
> It's not really meant to be used by application code or "normal"
> framework code. Stick the stuff in a bean, or use a producer method.


So the question was also brought up whether we should provide the unified
API to the standard attribute maps in the Servlet and JSF APIs. Ideally, of
course, you are using beans and producer methods to populate these contexts.
But one of the major usability improvements provided by Seam was the fact
that you had one way to access all contexts. Given that we have all been
involved in writing applications for companies, you should know as well as I
do that it's extremely common to have to use these attribute maps for one
thing or another. It's life. Clint said in the meeting you can always just
get a handle to that map the regular way. Let me remind you how this is done
in JSF:

application scope:
FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()
request scope:
FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
session scope:
FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
view scope: FacesContext.getCurrentInstance().getViewRoot().getViewMap()
flash scope: very bizarre mix of request map and some internal state

All I'm saying is that I think Seam should provide producers that expose
these maps so that they are injectable (as the type AttributeMap). I'm not
saying we use these maps to manipulate or access beans. This is for
integration with legacy systems, storing data ad-hoc in a non-JSR-299 way,
or whatever else the case may be. The question is going to come up and I
think people will just look for solutions elsewhere (sourceforge.net) to
patch Seam to provide something like this. It's not perfect. It's life.

-Dan

-- 
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://in.relation.to/Bloggers/Dan

NOTE: While I make a strong effort to keep up with my email on a daily
basis, personal or other work matters can sometimes keep me away
from my email. If you contact me, but don't hear back for more than a week,
it is very likely that I am excessively backlogged or the message was
caught in the spam filters.  Please don't hesitate to resend a message if
you feel that it did not reach my attention.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20090508/01fe32ab/attachment.html 


More information about the seam-dev mailing list