/    Sign up×
Community /Pin to ProfileBookmark

from frames page invoke struts to go to another frames page

I have a page (with no frames) that opens a child window using JavaScript and struts, like this:

window.open(“aa.do”, “child”, “<parameters for the window…>”);

that works fine. The struts action ‘aa’ executes its server-side code, then presents a window with two frames. The top is a JSP with two buttons; the bottom is a PDF referred to by URL. This all works.

I want one of the buttons in the JSP portion to invoke another struts action; I want the action to produce another very similar two-frame page, with a one-button JSP (or html) on the top and a (different) PDF via url on the bottom.

If I do the same javascript as above to produce the 2nd window, like this:

window.open(“bb.do”, “child”, “<parameters…”);

it appears the server does not recognize “bb.do” as a struts action. It attempts to find “/pages/bb.jsp”, where “/pages” is the location of my JSP pages for the app, including the “mother” page that started things off and the JSP that contains the button that caused this 2nd window.open call.

I tried eliminating the javascript and just having the button submit the html form that is in the top JSP. This causes the 2nd two-frames ‘window’ to appear in the TOP window of the 1st two-frames window. I’ve written javascript that eliminates the bottom frame, but after that executes it does not seem to execute the script part that submits the form.

It is not sufficient for me to present HTML out of the 1st two-frame window — I need the struts action so that it can do database things.

Can someone please tell me how to open the 2nd two-frame window?

I suppose it is ok if the 2nd one appears in a NEW window, as long as I can then eliminate the 1st window and not make the user do it. I’m afraid I’m stuck with creating a child window for the 1st two-frame item; I’m duplicating functionality that already exists, and the users will expect it to work that way. If it had been me writing it originally, I’d’ve put the first two-frame job in the original browser window instead of opening up a child. Ah, well.

I find this a difficult thing to search for — “javascript frames struts” gives many many references in lots of places, but I haven’t found anything that really addresses this situation yet…

rc

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rcookauthorApr 05.2008 — I've found a way to do this, though there's a part of that I don't understand yet.

If I create an onload function and execute the following:

if (top.location != self.location) { top.location.replace(self.location) }

it does what I want. I can't get the back button hot key to work the way the book that gives this example implies that it would, but that's not important to me in this case.

If I don't put in the conditional, it loops -- I guess this invokes onload, and so it continually loops unless qualified.

rc
×

Success!

Help @rcook spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...