-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, October 24, 2005 5:07 AM
To: [email protected]
Subject: Problems with setting Variable in BeanI have problems setting values in a backing bean.
In my JSF Page a method is called through an action attribute. This method calls another method from another bean.
In this second method some variables for the JSF Page are set. The Problem now is, that the new JSF Page doesn't display these variables and I get an error stack.Could it be, that the new Object which I create is another object than the JSF page has... How can I do that, that it works?
I hope this isn't too confusing.. Here is the code.
This is the method of the first bean(newPartner), which is called by the action attribute of the first JSF Page:
public String listforeditContact() {
String returnstring = "";
QueryHelper qh = new QueryHelper(); ---> HERE I'm making a new Object of the second bean!!! The methods of the object qh fill some SelectItem[] Variables...try {
if (contacttypeArt.equalsIgnoreCase("gateway")) {
logger.info("Contacttypeart: GATEWAY");
qh.listContactTypes(0);
returnstring = "popupContactGA";
}
if (contacttypeArt.equalsIgnoreCase("datenart")) {
logger.info("Contacttypeart: DATENART");
qh.listContactTypes(1);
returnstring = "popupContactDA";
}
qh.listPhonePrefix();
qh.listFaxPrefix();
qh.listGeschlecht();}
catch (Exception e1) {
e1.printStackTrace();
}One of the methods of the second bean(QueryHelper) look like this:
public void listGeschlecht() throws Exception {
Session session = HibernateUtil.currentSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
Query q = session.createQuery("from EtGendertype et");
querylist = q.list();geschlecht = new SelectItem[querylist.size()];
int i = 0;
for (Iterator it = querylist.iterator(); it.hasNext();) {
EtGendertype gender = (EtGendertype) it.next();
geschlecht[i] = new SelectItem(gender.getgId(), gender
.getGender());
i++;
}tx.commit();
}
catch (Exception ex) {
if (tx != null)
tx.rollback();
msg = bundle.getString("selectboxGeschlecht");
context.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_WARN, msg, null));
throw ex;}
finally {
HibernateUtil.closeSession();
}}
On the second JSF Page I have the following: (JUST one snippet)
<td><h:selectOneMenu id="geschlecht" styleClass="mustfield"
value="#{newPartnerDto.geschlechtId}" required="true">
<f:selectItems value="#{queryHelper.geschlecht}" /> -->HERE I'm trying to get the SELECTITEM VARIABLE OF THE BEAN QUERYHELPER!!!</h:selectOneMenu></td>
Thx!
Regards
Andy
______________________________________________________________________ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ______________________________________________________________________
Title: Message
I see
you have a lot of responses for this question already. As you have
probably discovered, JSF itself is responsible for instantiating your managed
beans; all you have to worry about is setting the values. If you create a
new object, that just sets your local reference, not the reference that JSF
maintains. Is there a reason why you need to instantiate the object
yourself?
-
Brendan
- RE: Problems with setting Variable in Bean CONNER, BRENDAN \(SBCSI\)
- Re: Problems with setting Variable in Bean Simon Kitching
- Re: Problems with setting Variable in B... Werner Punz

