[ 
http://www.stripesframework.org/jira/browse/STS-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11303#action_11303
 ] 

Jerrold Poh commented on STS-429:
---------------------------------

Hi Christian,

You're right, my comment does look a little ambiguous without a code snippit.  
What I'm saying is I have an abstract parent class like below:

public abstract class Parent implements ActionBean { 
    @Session private String foo;
    public string getFoo() { return foo; }
    public void setFoo(string f) { foo = f; }
}

Then child classes extending it:

public class ChildOne extends Parent {
    public ChildOne() {
        foo = "foo";
    }
}

public class ChildTwo extends Parent {
    public ChildTwo() {
        foo = "bar";
    }
}

What I'm trying to achieve is to have ChildOne and ChildTwo have a field call 
foo (which I've moved into Parent) and set the foo field both to different 
values.  

This doesn't work currently though as the field for both ChildOne and ChildTwo 
are stored in the session using the same key.

To get the result I have to declare the foo field in both child classes: 

public class ChildOne implements ActionBean {
    @Session private String foo;
    public string getFoo() { return foo; }
    public void setFoo(string f) { foo = f; }

    public ChildOne() {
        foo = "bar";
    }
}

public class ChildTwo implements ActionBean {
    @Session private String foo;
    public string getFoo() { return foo; }
    public void setFoo(string f) { foo = f; }

    public ChildTwo() {
        foo = "bar";
    }
}

I hope this clears things up.

Thanks

> @Session annotation to save and restore fields automatically
> ------------------------------------------------------------
>
>                 Key: STS-429
>                 URL: http://www.stripesframework.org/jira/browse/STS-429
>             Project: Stripes
>          Issue Type: New Feature
>            Reporter: Christian Poitras
>            Priority: Minor
>         Attachments: session-plugin-6.zip, session-plugin.jar, 
> session-plugin2.jar, session-plugin3.jar, session-plugin4.jar, 
> session-plugin5.jar
>
>
> I've added a @Session annotation and an interceptor that automatically saves 
> annotated fields in session and restores the fields on following request.
> This could be a great add-on to Stripes.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to