Solved

More Stripes

Posted on 2006-07-06
4
255 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Troubleshooting common task sequence error codes
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now