Scope of Manged Bean Stored During ValueExpression.setValue

Enviroment: Tomcat 6.0.10/JSF 1.2 RI

faces-config.xml:

<managed-bean>

<managed-bean-name>CurrentPartyBean</managed-bean-name>

<managed-bean-class>com.web.managedbean.PartyBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

Code snipit inside one managed bean:

publicvoid selectResult(ActionEvent e){

PartyBean partyBean =new PartyBean();

partyBean.foo();

FacesContext facesContext = FacesContext.getCurrentInstance();

ELContext elcontext = facesContext.getELContext();

ValueExpression ve = facesContext.getApplication()

.getExpressionFactory().createValueExpression(elcontext,

"#{CurrentPartyBean}", PartyBean.class);

ve.setValue(elcontext, partyBean);

...

Issue:

The bean stored in #{CurrentPartyBean} is not placed in session scope as labeled in the faces-config.xml. It seems to be placed there only for request scope and not session.

Question: What method exists for having dynamicly created managed beans adhear to the the scope as defined in the faces-config.xml file?

[1348 byte] By [jshaina] at [2007-11-27 1:47:17]
# 1
Put it in ExternalContext#getSessionMap() with the managed bean name as key.
BalusCa at 2007-7-12 1:09:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks for the quick response, however, I don't fully understand the answer. Trying both #{CurrentPartyBean#getSessionMap()} and #{CurrentPartyBean}#getSessionMap() results in exceptions. What should the key look like in the above example?
jshaina at 2007-7-12 1:09:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Here is the API: [url=http://dsc.sun.com/docs/jscreator/apis/jsf/javax/faces/context/ExternalContext.html#getSessionMap()]ExternalContext#getSessionMap()[/url]

The key is the managed bean name. Here is an example:

faces-config<managed-bean>

<managed-bean-name>myBean</managed-bean-name>

<managed-bean-class>mypackage.MyBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

SomeBean:String managedBeanName = "myBean";

MyBean myBean = new MyBean();

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(managedBeanName, myBean);

BalusCa at 2007-7-12 1:09:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...