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 How to get the field details from one jsp page in struts dispatchaction action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to get the field details from one jsp page in struts dispatchaction action class" Watch "How to get the field details from one jsp page in struts dispatchaction action class" New topic
Author

How to get the field details from one jsp page in struts dispatchaction action class

Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Hi there,

I do have a jsp page which contains 4/5 buttons and some text boxes .
So have used the dispatch Action class to work with all the submits.
In one method want to get one textbox value.

So created the formbean object and used the getter method to access the value. But that is not working.

Can anybody help me regarding this ??

thanks in advance.

zeet


Zeet

SCJP 6.0
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
You're going to need to post some code to get to the bottom of this. Particularly, the relevant portions of your struts.xml or struts-config.xml file, the file that generated your input fields (html, jsp, etc), your form bean (at least the declaration and the getters and setters for your property), and the code where you try to access the property.
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77



Hi,

form bean class



jsp page

test.jsp


action class






Struts-config.xml



jsp page

test2.jsp





The problem is that I am not able to get the value of DOB field from the jsp page in this extended dispatch action class.

But if I use normal action class then it works fine..



thanks

zeet


Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Are you sure test3 is getting called? It looks like your initial request needs to have a parameter named "parameter" with the value "test3" in it for the test3 method to get called. Maybe put some logging statements into test3 to see if its actually being run.
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Yes,

My html link is <html:link page="/xyz.do?parameter=test3">test3 </html:link>

Thanks,

zeet
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
That link doesn't look to me like its going to send a value for the DOB property to your server when a user clicks on it. That would seem to explain why you can't get the value in your next jsp. Am I just missing how your are sending the DOB to the server?
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Hi Tom,

Thanks a lot for your time .

Could you tell me how I can get the DOB value in the test3 method in the xyz DispatchAction class .

zeet
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Is there a reason that you want to use a link for this? The problem is that you will need to update that URL of the link to reflect the DOB that was entered. My inclination would be to use a button and in the javascript run by the button set the value of a hidden input field named "parameter" to "test3" and then submit the html form. You could probably also do this through javascript on that html:link tag, or try to update the url when the tag gets clicked on(I'm not sure what events you can use on that tag).
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

Before that I was using a button . But problem is that around 4/5 buttons are there on the whole jsp page and post action is only one i.e. action="/xyz" .

In the onclick event of the button I can call the same url but in that dispatch action class doesn't get the DOB parameter. it gets DOB and all other parameters as NULL .

If I use a normal action class instead of a dispatch action class that works fine..


Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
In the javascript run by the onclick event, were you setting the value of a hidden input field named "parameter" to "test3"? And were you submitting the html form? If your are doing that I would think it should work. Can you post the javascript that was executed that was failing?
Satchidananda Mohanty
Ranch Hand

Joined: Mar 12, 2008
Posts: 77

yes,

I am doing the same ,but unfortunately it is not working.





If I send the DOB value in the url ,that works ,but that is not safe . Any enduser can modify that value in the URL.

Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
In your javascript function, this:

var url='xyz.do?parameter=test3';

isn't going to do anything I don't think. The action of your submit will be xyz.do, but thats because its what you have set up as the action in your form tag. However, that parameter attribute still won't we sent. As I said earlier, I think you need to create a hidden input field named parameter and set its value to test3 in your javascript method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the field details from one jsp page in struts dispatchaction action class