[jboss-user] [JBoss Seam] - Re: Difference between Page and Event scope

dustismo do-not-reply at jboss.com
Thu Aug 23 15:05:14 EDT 2007


Here is how I would explain it, if I get anything wrong anyone is welcome to correct me.

Event scope is essentially stateless, the bean is created for a single action and destroyed when that action is complete.

Page scope maintains its state until the page is rendered.  So here is an example that might illustrate it better:

you have a bean with a couple of properties:

  | @Scope(PAGE)
  | @Name("demoBean")
  | ....
  | int id;
  | String message = "message not set";
  | 
  | public int getId() ...
  | public void setId(int id) {
  |   this.id = id;
  |   this.message = "ID Is set!";
  | }
  | 
  | public String getMessage()
  | public void setMessage(String message)
  | ....
  | 

Say you set your id as a page param defined in pages.xml.  Then you could successfully access #{demoBean.message} within your page and get the expected result ("ID Is set!").  If you set the scope to event then you would get ("message not set"). 

Hopefully that helps,
Dustin


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

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



More information about the jboss-user mailing list