[jboss-user] [JBoss Seam] - Re: Feature request - @InOut

andrew.rw.robinson do-not-reply at jboss.com
Fri Feb 23 11:32:31 EST 2007


"shouldn't normally need such verbose in/out declarations"

-1

It is often very helpful with rendering specific member variables with conversation or session scoped beans. For example,  a SELECT box may use a selectItems that takes a List return value from a backing bean. If this were to be created in the get method, the list would be created multiple times per-request since the EL is evaluated more than once during the JSF phases. So, the technique can be used:

  | @In(scope=ScopeType.EVENT, value="some-unique-string", required=false)
  | @Out(scope=ScopeType.EVENT, value="some-unique-string", required=false)
  | private List<SelectItem> myOptions;
  | 
  | public List<SelectItem> getMyOptions()
  | {
  |   if (myOptions == null) { /* build the list */ }
  |   return myOptions;
  | }

In this example, myOptions is created only once per request and the developer doesn't have to code the: 1) get faces context 2) get the external context 3) get the request map 4) get the value from the map 5) if null create it and 6) store it in the map and finally 7) return it. 

This is also very useful for binding where you want the UIComponent to be created once per-request and not tied to the conversation. 

Perhaps in these instances the "@Scope" being applied to fields would be more useful. In that case the seam framework could null out any variable with a shorter lifespan than the bean. Examples could be:
@Scope(ScopeType.CONVERSATION) public class MyBean {
  | // Null this value after request
  | @Scope(ScopeType.EVENT) private String myVar;

@Scope(ScopeType.SESSION) public class MyBean {
  | // Null this value after a conversation is ended instead of waiting for the session to end
  | @Scope(ScopeType.CONVERSATION) private String myVar;


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4021185#4021185

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4021185



More information about the jboss-user mailing list