File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Simple Question 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 "Simple Question" Watch "Simple Question" New topic
Author

Simple Question

Steve Li
Greenhorn

Joined: Jun 29, 2005
Posts: 5
How to get values into my bean?
Thank you in advance
Steve
Action Form

Bean

struts-config.xml

[ June 29, 2005: Message edited by: Steve Li ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Define a loading Action that is assigned to MyForm and forwards to the JSP. In the execute() method of the action, insert code that will populate the bean.

For example:

MyForm myForm = (MyForm) form;
myform.setMyObj(new MyObj[3]);
myform.setMyObj(0, new MyObj(1, new Date()));
myform.setMyObj(1, new MyObj(55, new Date()));
myform.setMyObj(2, new MyObj(100, new Date()));


return mapping.findForward("MyForm");



Once you do this, the form bean will have the necessary information to display in the form.


Merrill
Consultant, Sima Solutions
Steve Li
Greenhorn

Joined: Jun 29, 2005
Posts: 5
Thank you very much for your reply, but I want to capture user input and populate "private MyObj []myObject" of action in order to save user input in DB.
Question: What should be the value of "name" and "property" in JSP for "html:text" tag.
Thank you in advance
Steve

struts-config.xml




JSP Code


Cendy Nguvy
Ranch Hand

Joined: May 25, 2005
Posts: 37
Hi,

Try this :


[ June 30, 2005: Message edited by: cendy nguvy ]
Steve Li
Greenhorn

Joined: Jun 29, 2005
Posts: 5
Thank you for your reply, but I am looping over a different collection which has different objects in it.But I want the user input to populate
"MyObj []myObject" where MyObj has a number and a date.

JSP Code:


Thank you in advance
Steve
Steve Li
Greenhorn

Joined: Jun 29, 2005
Posts: 5
Since, I am going over a collection to output the description of doc.And I want to get user input to save it in database.
Question: How to get user input, ie how to pupolate

The JSP is


Thank you in advance
Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Question
 
Similar Threads
displaying data from arrays with html:text
ActionForm not setting indexed properties
Indexed Properties Help!!!
Generate Radio Buttons
Nested Iterator Tags