Meaningless Drivel is fun!*
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


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

Populating form bean in structs

Jobin Mathew
Ranch Hand

Joined: Oct 17, 2006
Posts: 83
Hi,
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
Jo,

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 ]

Merrill
Consultant, Sima Solutions
 
 
subject: Populating form bean in structs
 
Similar Threads
problem with url rewriting in sturts link
How to get parameter using struts Tag
using html:link tag
how to refresh the jsp page when onload?
Getting Values from a window to parent page