[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1233) Extend @Scope to work on member variables/properties

Andrew (JIRA) jira-events at lists.jboss.org
Mon Apr 23 13:28:30 EDT 2007

    [ http://jira.jboss.com/jira/browse/JBSEAM-1233?page=comments#action_12360246 ] 
Andrew commented on JBSEAM-1233:

True, out does do it, but what if I don't want to store it anywhere, I just want to lose the value (for transient, temporary values). Mostly this would be an alternative to using "global variables".

Use case A:
<h:outputText value="#{someGlobalVariable}" />

Ties to:
private String someGlobalVariable;

Use case B:
<h:outputText value="#{bean.someVariable}" />

Ties to:
private String someVariable;

Use case B is (perhaps) more maintainable for large applications, as you don't need to search all of your java code to find where the value is coming from. The "#{bean" lets you know the variable is owned by which bean. The first use case, it may be harder to know where that value comes from. 

With this approach, the user doesn't want to out-ject the value into the EVENT context object since the value is already readily available as a property of a bean. The limitation with this approach however, is that by default, the member variable is scoped to the scope of the Bean. 

So it isn't a replacement of @Out by any means, but instead just a different approach of accessing the variable (making the variable only accessible via a bean property), but still leveraging Seam's Scope handling functionality.

> Extend @Scope to work on member variables/properties
> ----------------------------------------------------
>                 Key: JBSEAM-1233
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1233
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Core
>    Affects Versions: 1.1.6.GA
>            Reporter: Andrew
> I have a relate bug:
> http://jira.jboss.com/jira/browse/JBSEAM-903
> My purpose for this bug was mostly due to binding issues. There are times that I want to have the scope of a member variable to be different from the scope of the bean. Especially, if the bean is conversational and I want the field/property to have event scope. Instead of the proposed @InOut from the above bug, perhaps just extending @Scope would work:
> @Scope(ScopeType.EVENT)
> private MyVar myVar;
> Unlike @In and @Out, this scope would not put use the contexts to get and set values, but simply control the lifecycle of the variable. In this example, myVar could be set to null when the the variables of the bean are out-jected. As it stands, there is no other easy way that I know of to have a variable set to null at then end of a page request.

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


More information about the seam-issues mailing list