jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Struts 2: Prepopulating fields in a popup window. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2: Prepopulating fields in a popup window." Watch "Struts 2: Prepopulating fields in a popup window." New topic
Author

Struts 2: Prepopulating fields in a popup window.

Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Feb 13, 2009
Posts: 63
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

Joined: Sep 29, 2008
Posts: 12617

Have you verified that the JavaScript method is getting a correct, complete URL?
Alia Huss
Ranch Hand

Joined: Feb 13, 2009
Posts: 63
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

Joined: Feb 13, 2009
Posts: 63
It works! Thanks.
 
jQuery in Action, 2nd edition
 
subject: Struts 2: Prepopulating fields in a popup window.
 
Similar Threads
Problem in opening a popup window in struts 2
Opening popUp window in JSF
Referring to a child window?
Ajax not working on IE. Undefined error
struts 2 tags question, certain jsp code not being executed