How to access page A.jsp's variable inside page B.jsp's bean constructor

I've been stuck with the following problem for a while now:

I have two pages called A.jsp and B.jsp backed by A-Bean.java and B-Bean.java.

On page A.jsp i have a text box where the user enters a code. Depending on this code, page B.jsp creates a drop down list. The values for this drop down list are created via an array list in the bean's constructor. How can I access page A's variable inside B's constructor ?

I'd appreciate any help. Thanks in advance

[486 byte] By [obaid_1982a] at [2007-10-2 17:09:46]
# 1

Why not using a managed property?

<managed-bean>

<managed-bean-name>beanA</managed-bean-name>

...

</managed-bean>

<managed-bean>

<managed-bean-name>beanB</managed-bean-name>

...

<managed-property>

<property-name>referredBean</property-name>

<value>#{beanA}</value>

</managed-property>

</managed-bean>

public class BeanB {

private BeanA referredBean; // remember the setter

public String secondPageAction() {

// get what ever properties from BeanA (referredBean),

// initialised the list

return "next";

}

...

}

The markup above assumes that the list is not initialised in BeanB constructor, but in secondPageAction instead.

Billy

lamekissera at 2007-7-13 18:24:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Man (or woman),Why don't you serach first the forum?Like this: http://www.jsffaq.com/
pringia at 2007-7-13 18:24:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thanks pringi and lamekisser, you guyz solved the problem

i set the bean property in the config file and used the following java code to access it:

Config:

<managed-bean>

<managed-bean-name>Person</managed-bean-name>

<managed-bean-class>demo.PersonBean</managed-bean-class>

<managed-bean-scope>request</managed-bean-scope>

<managed-property>

<property-name>userName</property-name>

<property-class>java.lang.String</property-class>

<value/>

</managed-property>

<managed-bean>

JavaCode

FacesContext fc = FacesContext.getCurrentInstance();

String userName = (String)fc.getApplication().createValueBinding("#{Person.userName}").getValue(fc);

obaid_1982a at 2007-7-13 18:24:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...