Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

More Stripes

Posted on 2006-07-06
4
Medium Priority
?
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 800 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this article, I’ll show how research, determination, and use of modern technology helped me solve a DNA mystery.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 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