Conditionally opening a new browser window from a JSP page

When the user clicks on a button in my JSP page, I'd like to launch a new browser and display certain things in that browser window while leaving the original browser window open. The new browser should only be displayed if certain conditions are met.
My thought was to invoke a javascript method in 'onLoad' which would determine if the new window needs to be launched.
This is kinda what my page looks like:
<jsp:root version="1.2" ................>
    <jsp:directive.page import="java.util.*, com.test.Configuration" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
     <ui:body binding="#{Page1.body1}" id="body1" onLoad="launchWindow();">     
     </ui:body>
   </f:view>
   <script type="text/javascript">
        function launchWindow(){
         if (Configuration.openWindow()) {
          window.open("hello.jsp", "newWindow", 'toolbar,width=400,height=400');            
    </script>     
</jsp:root>
My problem is that the call to "Configuration.openWindow()" does not resolve correctly. If I remove that call and simply make a call to "window.open()" all works. But once I put the condition in, nothing happens. I do not see an exception in my browser window but a new browser window does not open.
Is my syntax correct. Can I make a call to the static method 'openWindow()' in my class 'Configuration.java'.
I posted this same query on the JSF forum but received now replies. My question is more suited to the JSP forum and hence I'm posting this question here.
thanks,
tsc

I have made some changes so that I do not directly access the 'Configuration' class in my javascript.
I have a hidden field on my form and when the user clicks the button, in my back bean, I set a value for the hidden field. In the javascript function 'launchWindow()' I check if a value has been set for the hidden field and if yes, I open a new window.
<ui:body binding="#{Page1.body1}" id="body1" onLoad="launchWindow(document.forms[0]);">
<h:inputText id="hiddenField" value="#{formBean.hiddenValue}" />
<script type="text/javascript">
        function launchWindow(form){
            alert("in lw");
            var test = form["form1:hiddenField"].value;
            alert("got test");
            if (test !=  "")
                window.open("hello.jsp", "newWindow", 'toolbar,width=400,height=400');            
            alert ("done test");
</script>When my page is first loaded, the launchWindow() is called and all the alerts popup as expected.
When I click on the button (the back bean sets the value on the hidden field), my page is reloaded but this time its blank.
Any ideas as to why this maybe the case?
thanks,
tsc

Similar Messages

  • How to open a new browser window from a JSP page?

    Hi,
    I am picking up records from the database and displaying each record in a seperate text area field using the JSP code. I should be able to display the content ( available in the text area) in a seperate window if the user clicks on one icon.
    Is it possible to open a new browser window using JSP? If yes, how can I write information on the new browser window?
    Thanks in advance.

    Is it possible to open a new browser window using JSP?a JSP page is also an HTML page, this is client side stuff, you can do it with JavaScript.

  • Opening a new browser window from a JSP

    Hi,
    I have 2 buttons on my JSP. When the user clicks on them, they produce 2 reports. I would like to produce these results on a different browser window. Can anyone please tell me how to open a new window for the results?
    Thank you in advance.

    Use target="_blank" in your form declaration.<FORM METHOD=POST ACTION="someAction" TARGET="_blank">The _blank keyword tells the browser to load the results in a new window.
    If you need more control over your window (size, address bar, etc.) you'll need to use javascript.<SCRIPT>
    function submitForm(windowName){
       newWin = window.open("",windowName, "menubar=no,resizable=no,...");
       document.myForm.target = windowName;
       document.myForm.submit();
    </SCRIPT>
    <FORM NAME="myForm" METHOD=POST ACTION="some.jsp" TARGET="">
    <INPUT TYPE=BUTTON VALUE="Submit" onclick="submitForm();">
    </FORM>

  • How do I open a new browser window from Flash

    I wish to open a new browser window from Flash and when the new window closes to return to the location from whence I started.
    ThomasChen

    The command to open a new window would be the "_blank" part of a command to link to a web page in the code below.
    navigateToURL(new URLRequest("http://www.anothersite.com", "_blank"));
    As far as the new window closing and getting back to where you were in the original window, I don't understand where that original window might have gone to... You should be wherever you last left it.

  • How can I open a new browser window from UIX?

    I need to open a new browser window from an event handler. How that can be done? HELP!
    Thanks!
    Martin Patrici

    HTML doesn't really let you do this on the server side; the client is in charge
    of creating new windows, not the server.
    If you know that clicking a certain link/button, etc. will always raise a new window,
    then you should use Javascript or "targetFrame" accordingly.
    If the decision will only be made on the server side, then you could reload the current
    window, only this time use an "onLoad" on the <body> to raise a window.

  • Opening a new browser window from flash

    Does anyone know of a method fo opening a link in a new
    window in firefox from within flash that isn't blocked by the popup
    blocker. It seems like the security in FF 2.0.0.6 (I'm on 2.0.0.11)
    has been tightened to prevent any _blank or window.open calls from
    flash getting through. I've tried the standard getURL, fscommand
    and ExternalInterface call to a javascript window.open method.
    Nothing now works.
    I understand the need for the popup blockers, but this is a
    legitimate popup only invoked on user interaction (click) - the
    same window.open call in an onClick event outside of flash works
    fine and I guess it is blocked from within flash because there is
    no way of knowing if the call is invoked from user interaction or
    automatically - but seems a shame.
    So any other way of getting a new browser window to open from
    within flash in firefox?

    Use target="_blank" in your form declaration.<FORM METHOD=POST ACTION="someAction" TARGET="_blank">The _blank keyword tells the browser to load the results in a new window.
    If you need more control over your window (size, address bar, etc.) you'll need to use javascript.<SCRIPT>
    function submitForm(windowName){
       newWin = window.open("",windowName, "menubar=no,resizable=no,...");
       document.myForm.target = windowName;
       document.myForm.submit();
    </SCRIPT>
    <FORM NAME="myForm" METHOD=POST ACTION="some.jsp" TARGET="">
    <INPUT TYPE=BUTTON VALUE="Submit" onclick="submitForm();">
    </FORM>

  • Can I open a new browser window from a movie clickbox

    Hi,
    This is a last question from me, I hope. (I'm within a month
    of delivery, and my boss keeps saying 'a user's asked for this or
    that', but I'm meeting many of their requests with technical
    obstacles. Oh dear.)
    Here's the question: From a caption clickbox within a movie,
    can I link to a new browser window? (I have a Help button at the
    top of my movie and a user tester rightly pointed out that it
    breaks them out of their movie and they can't get back. So my only
    solution is to open it in a new browser window, but as I'm within
    the movie, I need to link to the new window from a caption or
    button, not an html page.)
    If a Javascript command would work, could I get the exact
    code to put in the box? I haven't been able to get any
    Javascripting to work through Captivate.
    If nothing works out, I'll have to scrub the Help button from
    every page, but I'd rather be sure before I do it.
    Thanks in advance,
    Kim

    Hi and thanks for both of the replies.
    Phew! I love it when there's a way out of my problem! Is it
    my imagination or are the options: Current, New, Parent and Top not
    described in the Captivate help? What is the Parent? I would have
    thought a window would have spawned a child. And I guess Top is a
    new window that's always on top? Is it described in the help
    anywhere beside the page I found that doesn't describe it? (I guess
    so far, I've been blindly and successfully using Current.)
    I assume I can't remove the toolbars on my new windw without
    going through an extra link? If that's the case, I can live with
    that. I wouldn't want to make the user click two links just for a
    help page.
    Thanks again,
    Kim
    PS. No wonder my Javascript never works if I can't even
    notice the options!

  • Open a new browser window from applet

    Anybody know how to open a new Netscape window by pressing a button in an applet? Which class handles it?
    Thanks a lot.
    wz

    http://forum.java.sun.com/thread.jsp?forum=54&thread=106906
    http://forum.java.sun.com/thread.jsp?forum=54&thread=272870
    http://forum.java.sun.com/thread.jsp?forum=54&thread=272829

  • How to open a new browser window from a link on the navigation bar

    Hi,
    I entered a URL in the 'URL Target' field for the Navigation Bar Entry. As expected when the I clicked on the link in the Navigation Bar my browser refreshed with the target URL.
    I want to be able to actually open a new window rather than refresh my current window. The help text says, and I quote ...
    "In the link generated for this icon include the following onClick javascript. Use of the onclick javascript could popup a help page in a new window (see example 1).
    Example 1:
    window.open('US/asfhhome.htm','Help','scrollbars=yes,resizable=yes,width=625,height=350,left=25,top=150');return false
    Set the Icon Target attribute to # if you are using OnClick JavaScript. Set the Image Alt Text attribute to the text the user will see to click on."
    So I created similar Javascript as to the example and placed in the 'OnClick Javascript' field, and placed a '#' in the 'URL Target' field.
    When I run it doesn't work, the '#' is picked up and the Javascript is ignored. Can somebody please tell me what I'm doing wrong.
    Thanks

    I had the same problem. I finally ended up just using the standard popupURL javascript. In the URL Target I have:
    javascript:popupURL('<link>')
    This opens a new window but since it is for popups the menus are missing. You may want to write your own javascript function to open the new window with your own settings.
    Search the forums for popupURL for more ideas.
    javascript:popupURL()
    --Jeff                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Openning a new browser window from a link in a portlet

    Hi,
    I have a link in a portlet which is to display iits content in a new window. But no matter what i try the address in the link is prefixed with the application URL making it useless.
    IE if my link i want to open is www.google.com when i cllick on the link in the new bowser I get http://localhost:7001/wepApp/www.google.com
    Does anyone know how to stop the http://localhost:7001/wepApp/ being added, before i throw myself out of the window.
    Thanks Chris

    Hi Chris
    I have same scenario on my side. I have Navigations Link Portlet that shows all our Corporate Web Sites links. This is stored in CMS System with one type. This is Pageflow based portlet. In Pageflow I get all Content for this links and store in request object. Then in JSP retrieve from request object and show them as links. Here is the jsp code snippet. Values are like http://www.msn.com, http://www.yahoo.com etc. I do have portlet for this pageflow that uses this jsp code snippet. So its from a Portlet.
    <lt;%
         Node linksNode = (Node) request.getAttribute("NEWS_LINKS_NODE");     
    %>gt;
    <lt;netui:html>gt;
         <lt;netui:form action="begin" enctype="multipart/form-data">gt;
    <lt;%
         if (linksNode != null && linksNode.hasChildren()) {
    %>gt;
              <lt;table>gt;
                   <lt;tr>gt;<lt;td>gt;<lt;b>gt;Links:<lt;/b>gt;<lt;/td>gt;<lt;/tr>gt;     
                   <lt;utility:forEachInArray array="<lt;%= linksNode.getChildren()%>gt;" id="eachContentItem" type="com.bea.content.Node">gt;
                        <lt;tr>gt;
                             <lt;td>gt;
                                  <lt;a href="<lt;cm:getProperty node="<lt;%=eachContentItem%>gt;" name="urlLink"/>gt;" target="_blank">gt;     
                                       <lt;cm:getProperty node="<lt;%=eachContentItem%>gt;" name="name"/>gt;
                                  <lt;/a>gt;
                             <lt;/td>gt;
                        <lt;/tr>gt;     
                   <lt;/utility:forEachInArray>gt;
              <lt;/table>gt;
    <lt;%
    %>gt;HTH
    Ravi Jegga

  • Open new browser window from Hyperlink in BIP PDF output report?

    Hello,
    Is there a way to open a new browser window from Hyperlink in PDF report?
    Thank you all in advance.
    MT

    Dear Friend,
    It is not supported for PDF Report. But below links helps you, to accombish this task in PDF report.
    [url http://oracleapps4u.blogspot.com/2011/03/open-hyperlink-in-new-browser-window.html]http://oracleapps4u.blogspot.com/2011/03/open-hyperlink-in-new-browser-window.html
    Thanks & Regards
    Ahamed Rafeeque Cherkala

  • Open new browser window from a JApplet

    Hi,
    I want to open a new browser window from a JApplet.My first thought was to use the Live Connect technology but it worked only with simple applets not with JApplets.Then i tried it by getting the Applet context (getAppletContext() method) but it still didn't work with JApplet...(it worked with Applet).I believe it has something to do with the applet security but i haven't yet figured it out.
    For example when i call the getAppletContext() method from a JApplet i get an java.security.AccessControlException ... .Thanks

    I must correct myself now :).
    The getAppletContext() method does work with JApplets too.Still , i have problems with the Live connection alternative.It seems that it by importing the netscape.javascript package i get the security eror that i mention above...

  • New browser window from uix

    How can I open a new browser window from an event handler in UIX?
    Thanks in advance,
    Martmn Patrici

    I just tried your suggestion. Unfortunately, it did not work. Here's the UIX code I used:
    <tableSelection>
    <singleSelection model="${bindings.MPOOrdersView1Iterator}" text="Select">
    <primaryClientAction>
    <firePartialAction targets="_uixState MplistsView11" source="MPOOrdersView10" event="select"/>
    </primaryClientAction>
    <contents>
    <submitButton formName="mlrhomeform" text="Print Lists" event="print" />
    <submitButton text="View Merge Reports" event="mergerpts" formName="mlrhomeform" targetFrame="_blank"/>
    </contents>
    </singleSelection>
    </tableSelection>
    The only difference from the original code is the addition of the targetFrame="_blank" in the submitButton.
    It had no effect. My redirected page showed up in the same browser window. This left me with an expired page when I press the Back button on the browser.
    My assumption is the response.sendRedirect() call wipes out the targetFrame setting.
    Does anyone know how the browser (Internet Explorer in this case) actually gets notified to open a new window? There's got to be something that the targetFrame="_blank" sets up to cause it.
    I know that Netscape supports a "Window-target:" header, but unfortunately IE doesn't. Is there some "standard" header that I can put in a response.addHeader() call that would tell all browsers to open a new window?
    Of course, a UIX solution would be preferrable!
    Any other ideas?

  • How to open a new browser window without toolbar, location, and menu bars from AIR?

    I have the following problem in my Flex+AIR application. I need to embed an ActiveX component that has JavaScript API inside my application. I tried to embed it inside <mx:HTML> component but unfortunately, AIR doesnot support plug-ins or ActiveX controls. So I've decided to open it in a new browser window. I tried navigateToURL(...) method but it has two problems - it is opening a new tab in the existing browser window and there is no way for me to configure the new browser window appearance, like removing toolbar, menu bar, location bar, etc. Then I tried to open a new window from JavaScript running inside <mx:HTML> component using window.open(...) API but it doesn't open a new window at all.
    Is there any way for me to open a new browser window without toolbar, location bar, etc. (which will run ActiveX control, so it cannot be AIR window) from inside AIR?
    Best regards,
    Arkady.

    Is it possible to open a new browser window using JSP?a JSP page is also an HTML page, this is client side stuff, you can do it with JavaScript.

  • I can open a new browser window, but not a new tab, neither by clicking the plus or selecting it from the menu. I have fully updated firefox and also restarted. what's going on?

    I can open a new browser window, but not a new tab, neither by clicking the plus or selecting it from the menu. I have fully updated firefox and also restarted. what's going on?

    I have the same problem with the right click and do not have the ask toolbar installed on my system?

Maybe you are looking for