Thanks but... this is what I knew so far :-)
What I want is not sharing an ENTIRE bean, just ONE variable. (a managed property)
Is this possible as well?

Thought of these 2 possibilities: (donno whether it would work/ whether at least one of them is correct)

<managed-bean>
        <managed-bean-name>A</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
<managed-bean>
 <managed-bean-name>B</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
<property-name>beanB_varA</property-name> <!-- Name of the very same var in bean B--> <value>#{beanA.varA}</value> <!-- referencing this way allowed?-->
        </managed-property>
 </managed-bean>

Or:

<managed-bean>
        <managed-bean-name>A</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
<property-name>varA</property-name> <!-- Name of the var in bean A --> <value>what to put here if the var is only defined at runtime? It appears to be a required element </value>
        </managed-property>
</managed-bean>
 <managed-bean>
        <managed-bean-name>B</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
<property-name>beanB_varA</property-name> <!-- Name of the very same var in bean B--> <value>#{varA}</value> <!-- referencing of a managed prop of another bean in this way allowed?-->
        </managed-property>
 </managed-bean>

Any ideas?
Wolf


On 30 May 2006, at 11:45, Ondrej Svetlik wrote:

Wolf Benz wrote:
Hi,
Short question: (thought of another solution)
Is this the proper way of passing just one variable from one backing bean to another, or is there a better way? (I'd just like to avoid sharing the entire bean, which you usually see)
So if e.g.
- bean A has varA
- bean B wants to access just this ONE variable from bean A
--> Is this correct? (or is there a better/proper way)
    <managed-bean>
        <managed-bean-name>A</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
           <managed-bean>
        <managed-bean-name>B</managed-bean-name>
        <managed-bean-class>...</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
<property-name>beanB_varA</property-name> <!-- Name of the very same var in bean B--> <value>#{beanA.varA}</value> <!-- referencing this way allowed?-->
        </managed-property>
    </managed-bean>
... Or does one really have to reference the entire bean and then perform a getter? So in this case: reference entire bean A from Bean B and in bean B's code do beanB_varA = getBeanA().getVarA() ?
Thx,
Wolf

Hello,

this should help you:

http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother

Best regards

Ondrej Svetlik

Reply via email to