It's not a secret anymore!
The moose likes Struts and the fly likes Populating form bean in structs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating form bean in structs" Watch "Populating form bean in structs" New topic

Populating form bean in structs

Jobin Mathew
Ranch Hand

Joined: Oct 17, 2006
Posts: 83
I want to make a page or editing some information.
So at the first time I need to load the values from database and display it in the form. So how can I initialize that formbean. I am using these tags

<action forward="a" path="/a.jsp"/>
in structs-config.xml

and <html:link page="a">Click here</html:link>

so on clicking this link I want to go to the page a.jsp with the values from database. ie I need to initialize the form bean of a.jsp.

Thanks in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

We're glad you dropped by the Java Ranch. There aren't many rules here, but we do ask that you let us know who you are by giving us your actual first and last names. Please make sure the "publicly displayed name" in your profile meets the JavaRanch naming policy.

In good faith assuming you'll comply with my request and change your name, here is a response to your question:

Create an Action class, and in the execute method of that class put logic to populate your ActionForm bean and then forward to the JSP. Your Configuration file will look something like this:

Your execute method will look something like this:

Your link would look something like this:

<html:link action="/MyAction" >click here</html:link>
[ October 17, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: Populating form bean in structs
It's not a secret anymore!