cancel
Showing results for 
Search instead for 
Did you mean: 

How to close main window ?

Former Member
0 Kudos

Hello all,

I have an application that attempts to read user info from the backend (based on employee id) and display it in a table. In the event that the employee id is not found in the backend, the application will close and re-divert to another web dynpro application. Unfortunately, whenever I try to close the "parent" window, I get an exception saying that "instance of interface view controller does not exist." A fellow forumer suggested that I need to create an external window beofre I can close the first one but the error is still the same. I am posting my code below and any help will be greatly appreciated.

// ========================

IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();

String deployableObjectName = wdComponentAPI.getDeployableObjectPart().getDeployableObjectName();

Map urlParameters = new HashMap();

// Prepearing the parameters to be sent over as part of the URL string

try{

WDDeployableObjectPart deployableObjectPart =

WDDeployableObject.getDeployableObjectPart(deployableObjectName,

"Approval",WDDeployableObjectPartType.APPLICATION);

String urlToApproverInboxApp = WDURLGenerator.getApplicationURL(deployableObjectPart,urlParameters);

IWDWindow exitWindow = wdComponentAPI.getWindowManager().createExternalWindow(urlToApproverInboxApp,"",false);

exitWindow.open();

wdThis.wdGetTripApprovalCompInterfaceViewController().wdFirePlugApproverInbox("javascript:void(window.close())");

}catch (WDURLException e){

messageMgr.reportException(e.getLocalizedMessage(),false);

}catch (WDDeploymentException ex){

messageMgr.reportException(ex.getLocalizedMessage(),false);

}

// ========================

from

Kwok Wei

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Kwok,

a) As Radha suggested, opening the new application in the same window would be better for you. To achieve this :

try{

WDDeployableObjectPart deployableObjectPart =

WDDeployableObject.getDeployableObjectPart(deployableObjectName,

"Approval",WDDeployableObjectPartType.APPLICATION);

String urlToApproverInboxApp = WDURLGenerator.getApplicationURL(deployableObjectPart,urlParameters);

<b>/*IWDWindow exitWindow = wdComponentAPI.getWindowManager().createExternalWindow(urlToApproverInboxApp,"",false);

exitWindow.open();*/ Comment this part</b>

wdThis.wdGetTripApprovalCompInterfaceViewController().wdFirePlugApproverInbox(<b>urlToApproverInboxApp</b>);

//Make sure that the outbound plug 'ApproverInbox' is an exit plug.

}

This will automatically exit the parent application & open the new application in the same window

b) If you are very much particular about opening the application in a new window, this is what you can try:

1) create an attribute of type integer, for eg: 'delayAttr'

2) In layout, create a 'TimedTrigger' UI element and bind it's 'delay' property to the new attribute i.e 'delayAttr'

3) create an action for the 'onAction' event of the 'TimedTrigger' and arrange your code accordingly:

.

.

.

IWDWindow exitWindow = wdComponentAPI.getWindowManager().createExternalWindow(urlToApproverInboxApp,"",false);

exitWindow.open();

<b>wdContext.currentContextElement().setdealyAttr(1);</b>

<b>// Inside the action handler for the TimedTrigger</b>

wdThis.wdGetTripApprovalCompInterfaceViewController().wdFirePlugApproverInbox("javascript:void(window.close())");

This will open the new application in a new window and then close the parent window after 1 second. But when we try to close the browser window through program, we get a default dialog message warning us about this action. This might confuse the user.

Hope this helps,

Best Regards,

Nibu.

Message was edited by: Bertram Ganz

Passing JavaScript-Code within exit plug URL-parameters is blocked by the Web Dynpro Java Runtime in NW 04 SP 16.

Former Member
0 Kudos

Hi,

save the javascript in mimes->components folder and try calling it

Hope this helps you

Regards

Rohit

Former Member
0 Kudos

Hello Nibu,

You suggestion was exactly what I did before going on to experiement with createExternalWindow etc ... But whatever option I chose, it still gave me the "Instance of interface view controller TripApprovalCompInterfaceView does not exist."

from

Kwok Wei

Former Member
0 Kudos

Kwok Wei ,

If i understand correctly,one of the solution would be to

fire exit plug from your main application to your new URL.

Former Member
0 Kudos

The exit plug is already in place. I am able to navigate away to another application but unable to close the main window. Thus in the end, I am left with 2 windows on my screen.

It seems that the closing of the main window is only possible after the view is initiated on the screen. Hence examples of navigating away from the click of a button is possible (I have tried and it works). However, if I want my application to <b>automatically close</b> the main window and launch another application based on program logic (eg :and this happens in the component controller), I will either end up with 2 windows or the exception "instance of the view controleer does not exist."

from

Kwok Wei

Former Member
0 Kudos

Why don't you try to open the other application in the same window (i.e. fire the exit plug to the other application)? Why do you want to try to close the current window and open a new window?

RK

Former Member
0 Kudos

Kwok,

If you have already exit plug, then point it to the following HTML:


<html>
  <head><title>Exit MyApp</title></head>
<body onload="self.top.close()">
</body>
</html>

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hello Valery,

May I trouble you to elaborate more on how can I accomplish using your method ? I am not very familiar with html. Are you suggesting that I add in the statement that you have highlighted in red ?

from

Kwok Wei

Former Member
0 Kudos

Kwok,

1. Place this code in file with *.html extension

2. Save this file somewhere in src/mimes/<component-name>

3. Get url to this html in "Exit" action handler and use as parameter to exit plug

VS

Former Member
0 Kudos

Hi VS,

I tried your method but whenever it tries to close, a pop up window appears asking for conformation to close the window. Is it possible to close the window directly without any other user intervention as it can be quite confusing. Thanks.

from

KWok Wei

Former Member
0 Kudos

No,

This is unavoidable -- any browser will produce this message for browser windows that users open himself (i.e. window that is not pop-up from other page).

VS

Former Member
0 Kudos

Hi Valery,

hmmm... So in another words, there is no way I can close the main application and re-launch another WD application WITHOUT any user intervention in the event that the backend is not able to find the user id ?

from

Kwok Wei

Former Member
0 Kudos

Kwok,

Please explain, what do you really need? Close window or launch other application in same window?

If later, then try either exit plug or WDClientUser.forceLogoff<*>(url);

VS

Former Member
0 Kudos

Hi Valery,

As mentioned in the initial post, I am sending an employee id to the backend with in turnm will return the user info and display it in a table. In the event that the userid is not found or the backend is not available, it should terminate the application and launch another WD application (designed for a generic situation when userid does not returns any information).

So far, my attempts to do the above only got as far as opening 2 windows whereby the first window will dosplay an empty table (since no info is retrieved) and the other is the newly launched WD application. My ultimate aim is to have only the second window opened, the first window (main application window) should ideally be closed since data cannot be retrieved or the backend is down.

My apologies if the initail description is not clearly described.

from

Kwok Wei

Former Member
0 Kudos

Kwok,

Then (instead of 2 windows) why not simply use

WDClientUser.forceLogoffClientUser(<url>) or exit plug with <url>, where <url> is URL of another application?

VS

Former Member
0 Kudos

Hello Valery,

That was exactly what I initially attempted but was given the "Instance of view controller does not exist." exception. The only way that I am able to circumvent the exception is to use createExternalWindow which is not really what I wanted.

Here is the piece of code that I originally used :

wdThis.wdGetTripApprovalCompInterfaceViewController().wdFirePlugApproverInbox(urlToApproverInboxApp);

from

KwoK Wei

Former Member
0 Kudos

Kwok,

Strange error.

Did you really mark "ApproverInbox" plug as "exit"???

VS

Former Member
0 Kudos

Hi Valery,

I can confirm and guarantee !!!! If only I can do a screen capture and paste it here.

This has been a bugging problem for me since day 1 and the only way to circumvent it is to end up with 2 windows whereby the first window will load the application with NO user data and the second window will be the exit page/another application. Any attemots to close the main application (1st window) will always result in a "Instance of view controller does not exist."

It will be fine however, if the view is first displayed and then an action were to trigger the verification process. This way, I will be able to close the main application and re-launch another application.

from

Kwok Wei

Former Member
0 Kudos

Kwok,

Could you download and run <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/tutorial%20on%20inter-application-navigation%20-%2015.htm">Inter-Application Navigation</a> tutorial?

If it runs ok, check what is wrong with your code and how it differs from tutorial code.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Message was edited by: Valery Silaev

Message was edited by: Valery Silaev

Former Member
0 Kudos

Thanks Valery! This was the very first tutorial that started me off with passing parameters over url I guess I need to dig deeper to find out whats the cause of the problem and will post the solution should I manage to find one.

from

Kwok Wei

Former Member
0 Kudos

Hi,

You have done it for a outbound plug ? Yes

Outbound Bound Plug is of type Exit ? Yes

It has a parameter of tyep string ? Yes

Whats the name of the String parameter of the Exit plug ?

Its "Url" of type string right ?

And you have one line in the inital post .. somewindow name.open().. YOu are not using it at present ..Are you ?

Regards

Bharathwaj