Solved

More Stripes

Posted on 2006-07-06
4
256 Views
Last Modified: 2006-11-18
Hi stripes users,
How can pass a data field value from JSP to my ActionBean class.
e.g:
1.myPage.jsp has n fields
2.i want to be able to retrieve those values from myPage.jsp
and construst some object with in ActionBean class
0
Comment
Question by:komlaaa
4 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 17056142
Will the array of string be helpful?

String[] nameOfComponent;

David
0
 
LVL 8

Accepted Solution

by:
thomas908 earned 200 total points
ID: 17056831
Are these value form fields?
If Yes and each field has only value associated with it then you'll have to do

String field1 = request.getParameter("field1");
String field2 = request.getParameter("field2");
......

If teach field can have multiple values (like a checkbox) then
String []field1 = request.getParameterValues("field1");

0
 
LVL 3

Assisted Solution

by:anumalas
anumalas earned 100 total points
ID: 17056939
Hi

You can do in the following way.

1.
public class YourForm {

ActionBean aBean = new ActionBean();
// some other variables;
// getter and setters of your actionbean;
}

public class ActionBean{

// your n number of variables and their getter and setters;
}

public class YourAction(.......){

yourform.getActionBean().setXX(); // set your values in your actionbean using setters;

}

In your jsp

<bean:define id="yourForm" name="YourForm" type="com..forms.YourForm"/>
<bean:define id="actionBean" name="yourForm" property = "actionBean" />

after this to set values in n number of your fields
for eg you have to set item number in your action bean
<td>
<html:text name="yourForm" size="10" maxlength="10" property=actionBean.itemnumber"/>
</td>

after doing this in your action form your bean varibels are available in a single object.

you can retrive those values using getters like

yourForm.getActionBean().getItemNumber();

Hope this will help :)
0
 

Author Comment

by:komlaaa
ID: 17060976
thomas, I dont thinks it is a good idea to use request.... in ActionBean class beacause, i want to be able to use JUnit to test my methods.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hashcode is calculated on the basis of value object 2 124
SimpleDateFormat.parse examples 19 109
sortaSum challenge java 17 174
eclipse buid path vs tomcat lib path 10 37
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question