On 5/18/07, Carlos Ortiz <[EMAIL PROTECTED]> wrote:
Thx Just a couple questions.

> Multiple ways
>
> 1) Use JBoss-Seam @In/@Out annotations to inject/outject the values
> 2) Use managed properties in the faces-config.xml to have bean b
> always pull the value from bean A for a given property
Noob , How i do that ?¡

 <managed-bean>
   <managed-bean-name>A</managed-bean-name>
   <managed-bean-class>example.A</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <managed-bean>
   <managed-bean-name>B</managed-bean-name>
   <managed-bean-class>example.B</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
   <managed-property>
     <property-name>valueFromA</property-name>
     <value>#{A.propertyFromA}</value>
   </managed-property>
 </managed-bean>

This assumes A has "getPropertyFromA" and B has "setValueFromA", so
just change those property names to fit your use case

> 3) Put the value in the ExternalContext requestMap in bean A and get
> it in bean B from the same map
> 4) Set it directly:
>
> FacesContext facesContext = FacesContext.getCurrentInstance();
> ValueBinding vb =
> facesContext.getApplication().createValueBinding("#{B}");
> B b = (B)vb.getValue(facesContext);
> b.setPropValue(getPropValue());
Does this last one works for all type of beans (request,session
application ...) ¡?

Yes, because the faces context (application actually) already knows
the scope of every bean due to its declared scope in the
faces-context. If the bean doesn't already exist, it is created and
stored in the scope defined from the configuration file.

Reply via email to