• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,

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

Thanks,

zeet
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic