Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2: Prepopulating fields in a popup window.

 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

My current issue:
I have a link:


When the link is clicked it calls the function called UpdateUser().


All that is working fine, but I want to send along the id of the user who is logged in:



In the action class the the execute method calls the method getPersonById() (located in PersonService.java) and then sets the values of the forms attributes with the values from the Person object.
It works perfectly well when the link doesn't open a popup and looks like this:

I understand that the problem with the codesnippet that opens a popup is that there aren't any parameters being sent along.

Thus I've tried the following but now no popup is opened:
xxx.jsp

The above code has also been tried with '' instead of "".
When I surround the <s:url> tags with ' ' I get a popup, but there are no values in it. (The execute method isn't even called)
And changing the function to:


Any ideas?
Thanks
Alia
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to pass a session variable in a URL? It's in the session. Get it in the action.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, I concede, that was a poor example.

If I instead have a table, with columns:


Each column has it's own date and in each column there might be a reservation, which has it's own id.
I want the link to open a popup, while the parent window stays as it was before the link was clicked.
And I want the fields of the popup to be populated with the values sent along with the URL.

Better?
Thanks
Alia
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you verified that the JavaScript method is getting a correct, complete URL?
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should. If I put the whole <s:url> in the href of the <a> tag, it sends me to the correct page with the correct values preset.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works! Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic