This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes how to populate a bean in a form? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to populate a bean in a form?" Watch "how to populate a bean in a form?" New topic
Author

how to populate a bean in a form?

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi there,

I would like to populate an object's (bean) info into my form.

can anyone assist what the code should be look like???

I have this:



the bean is in this format:
<bean:write name="empl" property="name" />

thanks

PS:
I know I can simply populate the form from the action prior to this page, but this isn't the case since the page is a composition of couple of pages.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
value= "what should be written here???"


Answer: nothing

You shouldn't code a value attribute at all. The <html:text> tag automatically uses the value of the actionform property you specify.
I know I can simply populate the form from the action prior to this page, but this isn't the case since the page is a composition of couple of pages.

Whether the page is a composition of pages is irrelevant. The correct place to set the ActionForm property is in an Action class that forwards to this JSP. If this page is part of a tiles definition, that's fine. You can still populate the ActionForm prior to the page being displayed.


Merrill
Consultant, Sima Solutions
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
well the problem occurred when I placed the fw in a composition page:

original (worked OK)


the fw I replaced was this


and it doesn't work. I assumed it's because of the page composition.
any idea?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to populate a bean in a form?
 
Similar Threads
can't get indexed form property to work.
struts equivalent of request.getParameter
Error while trying NewsLetter Example
Simple Question
To map more than one form bean to one action