• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing JS values in struts-2

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a repeat of post in html/JS... I would request the moderators to delete there, as no one is answering there or move it to covenient position

I am not certain whether this should be here or be in struts, jsp forum but would proceed...

The application is in struts-2


I have 2 JSP's... The 1st JSP has a 5 column table... The values for the 4th and 5th columns are obtained from the next JSP...These values are currently residing in a JS variable prepared in JSP-2.

Scenario:-->

In 1st JSP, I select row1 and click on 'gotoNext' button to go to next JSP in order to prepare values for the 4th and 5th columns...

In JSP-2, I prepared the 2 values for that row using Javascript...

Now on click of back button in JSP2 I need to go back to JSP1 and set these 2 values in 2 empty fields of the row that I previously selected...


I don't know the correct way to do it and these are a few options circulating in my mind viz...

1)Should I send these values unsing an AJax call?
2)How to pass those 2 JS values from JSP-2 and set them in empty fields of that row of JSP1
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say you click the "Back" button on JSP2, do you mean the browser's back button or do you have an html button called "Back" button on your page? If you are using the browser's back button this won't work since you'll either get the cached version of the previous page or it will resubmit the request for the previous page, either way your selections on the second page will be ignored. If you have an html button that you created then you could use that to submit the form for page 2 to your app and then your app can take the data and and use it for the JSP for page 1.

Another option would be to launch JSP 2 by calling your action/jsp through window.showModalDialog, then the values selected on JSP 2 could be returned to JSP 1 in javascript and you could put javascript on page one to put the returned values in your table. Fair warning, I only use IE so if window.showModalDialog doesn't work for other browsers I won't know about it.

Hope this helps.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I have a html back button...

On click of back in JSP-2 am submitting it to the jsp-1..Now how will I transfer my JS values?(what should be done in jsp1 to ensure that the values are falling in right place when back is clicked on jsp2?

I would try that showModalDialog...



 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you can use javascript to add the values you want as request parameters to your call to jsp-1. Of course if you are submitting your entire form with the back button then you just need to move these js variables to hidden input fields and they will be sent with the rest of the form.

After that you just need to map the values from JSP2 to the fields you want them in in JSP1 in your action class. If you are just going straight to your JSP then you'll need to get them from the request object.
 
reply
    Bookmark Topic Watch Topic
  • New Topic