struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David G. Friedman" <>
Subject RE: session form bean problem -- post again.
Date Wed, 05 Jan 2005 01:23:12 GMT

Before I give you an example, let me just yell "read the manual" at:
Struts Developer Guide -> link "HTML Taglib API Reference" URL

Now, on to practical matters.

As you may know, traditionally, you have an html:form in your JSP like so:

<html:form action="someaction" />
  <html:text property="field1" />
  <html:text property="field2" />

If you saved a bean named "user" in request or session scope, you can access
its property "firstName" from any JSP with many of the bean/html taglib
commands  such as:

<bean:write name="user" property="firstName" />
<html:text name="user" property="firstName" />

Using the above, I've done the unthinkable..... I have created a page that
has the html:form tag, then includes different "center" (I use tiles to do
this) JSP pages based on a Tiles controller.  Then, each page uses the
html:text with name="anyScopedBeanName" to show particular fields from ANY
of the stored beans I choose to show.   It works well with multi-page
validation schemes.


-----Original Message-----
From: t t []
Sent: Tuesday, January 04, 2005 10:21 AM
To: Struts Users Mailing List
Subject: RE: session form bean problem -- post again.

Thanks, David. Could you please give a simple example to explain how to
"specify another bean"?

"David G. Friedman" <> 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"


-----Original Message-----
From: t t []
Sent: Monday, January 03, 2005 9:30 AM
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:

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)
SearchForm searchForm=(SearchForm) form;

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
Any idea anyone?

Thanks in advance.

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

To unsubscribe, e-mail:
For additional commands, e-mail:

Do you Yahoo!?
 Take Yahoo! Mail with you! Get it on your mobile phone.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message