cancel
Showing results for 
Search instead for 
Did you mean: 

How to open new window with results on button press?

Former Member
0 Kudos

Hello,

I hava a DynPro application that contains search filed and a button. Pushing the button opens a result table which resides in another view below the search filed.

I would like that pressing the searcg button will open this result view in an independent window. Is it possible and how do I do that?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Roy,

Create another window and place the result view inside it.

On click of teh button In the action of teh button write the code to open teh result window.

IWDWindowInfo winInfo = wdComponentAPI.getComponentInfo().findInWindows(strCommentsWindow);

IWDWindow window = wdComponentAPI.getWindowManager().createWindow(winInfo, true);

wdContext.currentVnWindowDetailsElement().setVaCommentsWindow(window);

window.setWindowPosition(WDWindowPos.CENTER);

window.setWindowSize(windowWidth,windowHeight);

window.open();

Regards,

Sowjanya.

Former Member
0 Kudos

Hey Sowjanya,

Your code seems to be what I am looking for but I don't really understands it. Can you please give me more concrete example?

Former Member
0 Kudos

At which place do I write my View name in your code above?

Former Member
0 Kudos

Hi,

On the action of ur Button write the above code .

Specify ur windowname as parameter(strCommentWindow).Store the instance of the window(IwdWindow) so that u can destroy the window at a later point of time.(say on click of a button in ur popup window call another another method to destroy the window.)

IWDWindow window = wdContext.currentVnWindowDetailsElement().getVaCommentsWindow();

window.close();

window.destroy();

Regards,

Sowjanya.

Former Member
0 Kudos

Hi

If u require Sowjanya Code then u have to write the same in a method and call that method onAction of Button.

if it is Another Component then write the same code in the interface Controller and use it in Used DCS and call that Method onAction of the Parent Component

Former Member
0 Kudos

Hey Sowjanya,

Well I got it but I have a problem though:

The window is being opened inside the current one.

I would like to open in a new Browser completley

(Line _BLANK...)

Former Member
0 Kudos

That means u have to use CreateExternalWindow Only

With Parameters

URL for WebDynpro Application and Title and Boolean false

create a Application holding as a result window and use this Application URL as a URL Paramteter

Message was edited by: krish kanth

Former Member
0 Kudos

And this means I need to write the results in a new application?

Former Member
0 Kudos

Yes U have to

Former Member
0 Kudos

OK, 10x you guys

Former Member
0 Kudos

Hi

If u want to open a external window u have to use

IWDWindow window = wdComponentAPI.

getWindowManager().createExternalWindow("URL", "Title",false);

Follow the below steps

1.Create a different application(application2) and component(component2) linking to the window2 in the same project

2.Deploy the application2.

3.Go to ur view implementation in the window 1 .

4.write the below code snippet to get the url

String applicationURL = WDURLGenerator.getApplicationURL(“ProjectName”, “Application2”);

5.Open external window using

IWDWindow window = wdComponentAPI.

getWindowManager().createExternalWindow(applicationURL, "Title<< For ur Window>>",false);

window.open();

Now ur window 2 will be opened in the new I.E

Hope this solves ur problem

Former Member
0 Kudos

Hey krish,

The problem that there is a Context mapping between the Result View and other views in component1. When I transfer the View to window2 at application2 this mapping will be lost. My guess is to transfer the parameters through URL instead of mapping but how Do I do that using your code?

Former Member
0 Kudos

Hi

I think Mappings Are not POssible

but u can append the required Paramters to the URl and say that as a QueryString like http://.....?Name=krish

Now

u can read that URL in the Other Application Using wdWebContextAdapter and request the Parameter and get the VAlue

WDWebContextAdapter web = null;

String Name = web.getWebContextAdapter().getRequestParameter("Name");

then U will get the Value as krish.

Former Member
0 Kudos

Hey krish,

Are you sure about

getApplicationURL's parameter, I receive an exception that it failed to generate URL for this app and I created Application2 and deployed it, as an independent app it is working but not when I try to generate URL for it from Application1

Former Member
0 Kudos

Hi

u can use this Link to know abt URL Generator

http://help.sap.com/saphelp_nw04/helpdata/en/9e/a073001903c9419592b14c2aa63669/frameset.htm

WDURLGenerator.getApplicationURL("local/<<ProjectName>>","<<Application Name");

Former Member
0 Kudos

10X krish, I didn't use the "local/" prefix, it's working!

Former Member
0 Kudos

Hi,

Following this thread, how can I pass back a parameter from the new window that was opened back to the "main" window?

Thanks in advance,

Aviad

Former Member
0 Kudos

Hi Aviad,

What you can do is pass the context element (IWDNodeElement) to the child component. Before closing the window, set the data to the context of the parent component.

Hope this solves your problem.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

Thanks for your replay. This is what I was looking for.

Can you please add some code examples of how to pass the context element to the child node and how to set the context of the parent from the child window.

Thanks again,

Aviad

Former Member
0 Kudos

Hi Aviad,

1. Create a value attribute (eg.vaParentContext) of type IWDNodeElement in the interface controller of your pop-up component.

2. Create one more attribute (eg. vaParentAttrName) of type String.

3. Write a method in the interface controller to open the pop-up window (eg. openWindow).

4. Use this component in your parent component and add the interface controller to the parent component's controller.

5. Bind the attributes to your component controller.

6. Before invoking the "openWindow()" write the following line of code

  wdContext.currentContextElement().setVaParentContext(wdContext.current<<Value Node name>>Element());
  wdContext.currentContextElement().setVaParentAttrName(<<attribute to which the data to be set back>>);

7. In the close event handler of the pop-up window, write the following code.

//getting the context element
IWDNodeElement nodeElt = wdContext.currentContextElement.getVaVaParentContext();
//setting the data to the parent context element
nodeElt.setAttributeValue(wdContext.currentContextElement.getVaParentAttrName(), "the value you want to set");

Hope this is clear for you.

Regards,

Santhosh.C

Answers (6)

Answers (6)

former_member214651
Active Contributor
0 Kudos

Dear All,

I have followed the same steps for which the solution works, but the same is not working in my case. The window, View and the application which i have created in WebDynpro exists in the same component, however i am unable get any value which has been binded to the controller.

I Tried sending the values through URL which works fine, but After all the Code is executed and the window.open() executes, a new window opens, but a nullpointer exception is displayed, which i am unable to trace in any of the method's catch statement.

I am unable to know what has been missed out. Kindly let me know if any additional settings needs to be made in the code or the design of the Window. Or is there any session problem when a new window is opened?????

Regards,

Poojith MV

Former Member
0 Kudos

Hi Roy,

You dont have to create a external window. YOu have to create another window for your component.

Embed this view in that window and use createWindow option to open that window.

Regards

Bharathwaj

Former Member
0 Kudos

You need to write "Window" name not View Name

IWDWindowInfo winInfo = wdComponentAPI.getComponentInfo().findInWindows(strCommentsWindow);

Where you need give window name in "strCommentsWindow"

Regards, Anilkumar

Former Member
0 Kudos

If you place only result view in the Window by default it will open the view only.

Just makesure that the Default as true for the resultview

Regards, Anilkumar

Former Member
0 Kudos

Roy,

Did u mean that result view should open in another browser or in the same as popup?What I have written is only for popup.

Regards,

Sowjanya.

Former Member
0 Kudos

Hi

U can use wdComponentAPI.getWindowManager().createExternalWindow() with necessary parameters

The Parameters are URL , Title for the Window and true or false depending on the Modal Window.

The Above Code works only for Window which opens in new Browser

Former Member
0 Kudos

Hey,

But how do I "tell" the window which view to show?

This method receives URL as a parameter but my view resides at the same DynPro app. Does this mean that I need to take this view outside to new application?

Former Member
0 Kudos

No

It shuld Be new Application with different View