before the return statement of the method "public String listforeditContact()"

you made a new QueryHelper qh so u expect that the new qh wil relace the "queryHelper" you configuerd in the faces-config but that's not true you have to replace it manually by replacing the old object with the new one.

if u don't want to creat a new QueryHelper object you may get the one you configuered from the session by:

QueryHelper qh=null;
qh=(QueryHelper)
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("queryHelper"); //get it from session if it was initialized.

if(qh == null){ // if it wasnot initialized yet
qh=new QueryHelper();
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("queryHelper",qh); // put it on the session
}

On 10/24/05, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:
Sorry, I'm a bit confused, but when do I have to use that (what return Statement do you mean?):
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("queryHelper",qh);
And do I have to create a Object like this:
QueryHelper qh = new QueryHelper();
 
 
Regards,
Andy
-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]]Im Auftrag von Michael Ageeb
Gesendet: Montag, 24. Oktober 2005 13:41
An: MyFaces Discussion

Betreff: Re: Problems with setting Variable in Bean

before the return statement
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("queryHelper",qh);

On 10/24/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Werner has send me the following links:

http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html

and the code is
http://www.javaworld.com/javaworld/jw-07-2004/jsf/jw-0719-jsf.zip

with the FacesUtils class under:
src/java/catalog/view/util


Regards
Andy

-----Ursprüngliche Nachricht-----
Von: Hans Sowa [mailto: [EMAIL PROTECTED]]
Gesendet: Montag, 24. Oktober 2005 13:19
An: 'MyFaces Discussion'; [EMAIL PROTECTED]
Betreff: AW: Problems with setting Variable in Bean


HI

I would like to have a look at the JsfUtil class but I can't find it. Please
could explain it in more detail where we can find it.

Thanks a lot.

mfg Hans Sowa
PROCON DATA Datenverarbeitung Ges.m.b.H.
mailto:[EMAIL PROTECTED]
http://www.procon.co.at


-----Ursprüngliche Nachricht-----
Von: news [mailto: [EMAIL PROTECTED]] Im Auftrag von Werner Punz
Gesendet: Montag, 24. Oktober 2005 12:57
An: users@myfaces.apache.org
Betreff: Re: Problems with setting Variable in Bean

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.
> ______________________________________________________________________


______________________________________________________________________

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.
______________________________________________________________________



--
Michael Ageeb Fakhry
Software Developer OpenCraft
Home Phone: +2 03 5053707
Business Phone: +2 02 3363848 / 110
Mobile Phone: +2 010 1336546
Business E-mail : [EMAIL PROTECTED]



--
Michael Ageeb Fakhry
Software Developer OpenCraft
Home Phone: +2 03 5053707
Business Phone: +2 02 3363848 / 110
Mobile Phone: +2 010 1336546
Business E-mail : [EMAIL PROTECTED]

Reply via email to