struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t t <wantt...@yahoo.com>
Subject RE: session form bean problem -- post again.
Date Tue, 04 Jan 2005 15:21:17 GMT
Thanks, David. Could you please give a simple example to explain how to "specify another bean"?

"David G. Friedman" <humble@ix.netcom.com> wrote:T.T.,

If you want to display something form the session object stored with
"Constants.USER_KEY" in /search.jsp (your "success" forward), you don't need
to copy the values in your Action's execute() method. Just specify another
bean (in any scope) with the 'name="User"' attribute/value pair. Of course,
you'll have to change "User" to the actual string defined by
"Constants.USER_KEY". This works for many tags in the "bean" and "html"
taglibs.

Regards,
David

-----Original Message-----
From: t t [mailto:wantte03@yahoo.com]
Sent: Monday, January 03, 2005 9:30 AM
To: user@struts.apache.org
Subject: session form bean problem -- post again.


Happy new year!
Since I posted this problem before Christmas and didn't get answer, I post
it again.
. I have such action mapping:
--------------------------------
type="myClasses.PopulateAction"
name="SearchForm"
scope="request"
validate="false">


-----------------------------
The code in the "PopulateAction" class is:
-------
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

HttpSession session = request.getSession();
User user = (User)
session.getAttribute(Constants.USER_KEY);
SearchForm searchForm=(SearchForm) form;
searchForm.setZipcode(user.getZipcode());
searchForm.setCity(user.getCity());
searchForm.setState(user.getState());
searchForm.setCountry(user.getCountry());

return (mapping.findForward("success"));

}
----------

I want to populate "SearchForm" with some existed values(stored in
session) before showing "search.jsp". This work is done in "execute" method
of "PopulateAction".
It works well when I use the mapping code shown above. But when I take
out the line -- scope="request", that is, I want this form bean to be a
session bean. Then the values were not set. They are just the initial
values of the form bean.
It seems a new form bean object was created after "execute" method of
"PopulateAction". Or , "execute" method of "PopulateAction" was not
executed.
Any idea anyone?

Thanks in advance.



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



		
---------------------------------
Do you Yahoo!?
 Take Yahoo! Mail with you! Get it on your mobile phone.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message