Solved

More Stripes

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

First of all let me say that the only language that I speak is English, but in answering questions here I often come across people whose English skills are not the best and I’d like to be able to communicate better with them, and the following descr…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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 …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

617 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