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...
this is your problem, you should use the jsf variable resolver mechanism
to take care of the backend bean generation.
I can recommend to use the excellent JsfUtil class you can find
on www.javaworld.com and in appfuse, which encapsules all the
mechanisms. This class has a getManagedBean method which takes care
of all that.
Werner
[EMAIL PROTECTED] wrote:
> I 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.
> ______________________________________________________________________