Cumhur Ata
Cumhur Ata

Reputation: 809

openNewWindow in SSJS in XPages

I would like to open a new page then focus on the new window. After openening new window cursor i mean focus on the previous window. I must transfer values via scope Variables so I need to open the focus a new window :).

Please find what i tried below.

<xp:link escape="true" text="Statement" id="link51"
                styleClass="linkNew" target="_blank">

                <xp:eventHandler event="onclick" submit="true"
                    refreshMode="complete">
                    <xp:this.action><![CDATA[#{javascript:try 
{
    sessionScope.type1="Customer1";
    view.postScript("var tempwindow = window.open('xspFrmStatementA.xsp?action=newDocument', '_blank'); tempwindow.focus();");
}
catch(e) 
{
    e.toString();
}
 }]]></xp:this.action>
                </xp:eventHandler>
            </xp:link>

Upvotes: 0

Views: 107

Answers (2)

stwissel
stwissel

Reputation: 20384

When you open a link with target = _blank a browser follows that link, so you actually don't need to do anything. You just need to specify the target URL. I would recommend not to use a session variable - you might have undesired effects if a user opens multiple windows. Rather use a parameter in the url which would be specific to that one window.

Personally I don't like when an application decides for me to pop a new window (I prefer tabs anyway). If I want to open a link in a new window I shift-click. If the second window depends on the parent, consider a dialog box or unhiding some control

Upvotes: 0

Chris Richards
Chris Richards

Reputation: 705

I'm not too sure I understand the question fully? You do not need to give a window focus if you are using scoped variables.

If you set a sessionScope variable, it will be available to you from anywhere for the duration of your session, you just need to be careful about over writing its value in other places.

You could just use a requestScope, which will send one request from one xpage and get one response to another xpage with same request scope variable name.

I may be completely wrong with my suggestion though, as like I mentioned, I'm not sure I fully understand what you are trying to achieve.....

Upvotes: 1

Related Questions