• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

send id from jsp to struts action

 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
i have problems in sendint the id of a html selected option to a struts action. i use javascript to get the parameter and show it in an alert. it shows the correct value.


the js code:

but now in the strut action action:


I don't get why on request the value() is null......
any ideas? thank you

 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have problems in sending the id of a html selected option to a struts action

This is a little confusing. Are you using an AJAX request to send request parameters, if yes, then show us the code for making the ajax request. Also as per what you said, the value is correct in JS but is null in the action, is it correct??
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you submitting the form? Maybe there is a submit button in another form, which gets submitted instead of this!
 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using just javascript to get the selected option.
this being a struts app, i have declared a bean in struts.xml that connects the action to the view. so from the action page i send data to the view page and when the user selects something i want to sent back a value on request.
this should have been as easy as that but something i am missing.
i first used a function(already tested in other examples) to get the value from request :


and so to get the value from the view i used:

This worked with a spring project.
and now here it does not.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to submit the form for the selected value to be available on the server side...
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i send data to the view page and when the user selects something i want to sent back a value on request.


Are you actually sending the value? In what way is the form getting submitted? Neither there seems to be any submit button nor there seems to be any ajax call?
 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


and on change in the form this function is called:" onchange="getNrRows(this);"
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the only form on your page..?
 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, where is the form getting submitted? What about the action??

 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your form is not getting submitted through submit click, so form action attribute is not going to help. You are submitting through js call, so here you need to specify the action.
 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i specified in the form the name of the action. "/test.do".
or you are saying something else?
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to specify the action url, whatever it is.
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my js code above

document.forms[0].action="url where the form is to be submitted"
 
bubu lina
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you were right. Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic