shale-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig McClanahan" <>
Subject Re: @Property with in out like in seam
Date Mon, 12 Feb 2007 02:06:27 GMT
On 2/11/07, Ingo Düppe <> wrote:
> Hi,
> I wonder if shale should support an out semantic like in shale.

I presume you mean like in Seam? :-)

In my page classes I always neet to get some object from the session
> scope and mostly I need to refresh them in the prerender method and put
> the refreshed object back to the session scope. Like in the following
> example.
> @Property (value="#{sessionScope.enrollment})
> private Enrollment enrollment;
> public void prerender () {
>      if (enrollment != null) {
>           enrollment = lectureService.getEnrollment(enrollment.getId());
>           setSessionBean("enrollment", enrollment);
>      } else {
>          // error cannot display without a selected enrollment -
> redirect to some starting page
>      }
> }
> So for me it would be nice if all properties that are defined as out
> will be set back to their scope after the prerender method is called
> @Property (value="#{sessionScope.enrollment}", out=true)
> private Enrollment enrollment;
> public void prerender() {
>    if (enrollment != null)
>       enrollment = lectureService.getEnrollment(enrollment.getId());
>    else
>       // redirect
> }

That would indeed be an interesting approach.  One of the things I would
like to see Shale do in the future is be an implementation of JSR-299
(WebBeans), and it wouldn't surprise me at all to see this concept be
included there.

In the mean time, I've found it useful to use the saveData() and
restoreData() methods in the AbstractViewController base class to save and
restore state information across requests (it saves the state in a generic
attribute on the UIViewRoot, so JSF's state machinery does the heavy
lifting.  You could simulate injection and outjection pretty easily with one

    public void preprocess() {
        setValue("#{sessionScope.enrollment}", restoreData("enrollment"));
        // May need conditional logic here if it won't always exist

    public void prerender() {
        saveData("enrollment", getValue("#{sessionScope.enrollment}"));

This also works to save variables local to the current view (sort of like
"flash scope" when you are redisplaying the same page).  It can also be
combined with the normal injection that JSF supports on managed beans to
initialize local (to your view controller bean) references to session or
application scope objects.

> Ingo


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message