It's not a secret anymore!
The moose likes Struts and the fly likes Working with a second window in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Working with a second window in Struts" Watch "Working with a second window in Struts" New topic

Working with a second window in Struts

Martin Riedl

Joined: Sep 06, 2003
Posts: 7
Let's see if i'm able to describe this correctly In German this would be much easier.
We are currently discussing possibilities to work with 2 different windows in our Struts-Application. What we went to do is: we have a Form in Windows1
where you can type in a search pattern for users and search for all matching users by submitting one button. The result of the search should be displayed as a List of differnet users in Windows2 with every single user as link. By clicking one of the users Windows2 should be closed and the TextBox of Windows one should be updated with the whole username.
I'm sure it can be achieved by using some JavaScript - but i'm not a friend of JavaScript.
Any suggestions or solutions? Maybe some of you already worked with different windows in Struts?
Thx in advance
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This cannot be achieved with struts. Struts (Java) is working only on server side. This means it doesn't know anything about different windows
on the client. When you look what happens when you submit a form you will
that. You submit the form, so your browser opens a connection to the webserver and transmits the data. The servlet is receiving the request, performs some actions and then returns the response. So you see how should the server know:
1. how much windows are open
2. how to contact the window
Uwe Barthel

Joined: Dec 16, 2003
Posts: 9
A bit OT.
Open your window's with JavaScript and give they names.
And within your links fill the 'taget=""' with the name of the 2. window.
The browser know the target and 'printed' the stream to this window-handle.
Uwe Barthel
[ December 16, 2003: Message edited by: Uwe Barthel ]

--<br />Sorry for my bad englich
Bruno Dery
Ranch Hand

Joined: Oct 05, 2003
Posts: 37
You could also probably force your second window to refresh at certain intervals using a simple html tag and that window would ask for the results of the search action... But then, it's a fixed time, so the search might fall in between this refresh time, which would make it look slower than it really is, not the mention the annoying 'click' noise when a window refreshes by itself
I'd say the only way to really make it dynamic is to use javascript... It can be evil, but using it carefully shouldnt cause problems.
Bruno Dery
Ranch Hand

Joined: Oct 05, 2003
Posts: 37
Actually in that second window you could have something like a progress bar, which basicly uses the refresh trick No javascript would then be needed, unless you progress bar thing uses javascript
I agree. Here's the link:
subject: Working with a second window in Struts
jQuery in Action, 3rd edition