cancel
Showing results for 
Search instead for 
Did you mean: 

Pass value from Pop up window to main window UI element

Former Member
0 Kudos

Hi all,

I want to open a pop up window for selection of text field in main window.

For example, I want to pick a customer from a list. I have a text field. I want to click a button with a company code parameter that pops up a window with customer list (in a table) specific to that company. I will select one of the customers and the text value is passed to customer text field in the main window.

Is this possible? If so

1. How to open a pop window with a attribute passed to filter the list.

2. What is the code to pass the selected value back to the main window.

I badly need to implement this functionality and I am new to Web Dynpro. Any help is appreciated.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ravi,

Assume you have 2 views named mainView and popUpView and a common component controller between the two views.

1. Create a value attribute between in your component controller that you need in both the views.

2. Open Data modeler and create a link from mainView to component controller and similarly from popupView to component controller for the context that you need to share in both the views.

3. Bind the same context to your Input UI element in mainView.

3. Now you can set the value of the context in popupView like this from the selected value in table:

wdContext.currentContextElement().set<attributename>(wdContext.node<tablenode>().get<tablenode>ElementAt(wdContext.node<tablenode>().getLeadSelection());

4. Now when you will return to mainView the value would be the one we set above.

Regards,

Murtuza

Former Member
0 Kudos

Thanks chaitanya and Murtuza, the explanations are really helpful. I will try the approach. I appreciate your help.

Ravi

Former Member
0 Kudos

Hi,

This is my approach which is somewhat generic.

Basically you create a controller which holds the set of values for user selection.

In which you have a service (aka method) for others to open up a popup and from which user select a value and this value is pass back to the caller.

The service , I call it , openSingleSelectWindow because you can also set it to be multiple select too. And it will capture the callback properties, i.e., what nodeelement I am dealing with and what attribute name I need to set when select is done. This openSingleSelectWindow delegates its work to openWindow. And when user select an option. The SelectCustomer will be called to set the callback value and close the window.

Hope I you will find it useful.

yung siu wai

public void openSingleSelectWindow( java.lang.String windowName, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement projectNodeElement, java.lang.String fieldName )

{

//@@begin openSingleSelectWindow()

ResetSearchFields();

wdContext.currentContextElement().setSelectionMode(WDTableSelectionMode.SINGLE);

wdContext.currentContextElement().setSelectbuttonvisible(WDVisibility.NONE);

this.nodeElement = projectNodeElement;

this.fieldName = fieldName;

openWindow(windowName);

//@@end

}

public void openWindow( java.lang.String windowName )

{

//@@begin openWindow()

IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows(windowName);

IWDWindow window = wdComponentAPI.getWindowManager().createModalWindow( windowInfo);

window.setWindowPosition(WDWindowPos.CENTER);

wdContext.nodeCust_List_Sel().setLeadSelection(-1);

window.show();

wdContext.currentPopupElement().setWindowInstance(window);

//@@end

}

public void SelectCustomer( )

{

//@@begin SelectCustomer()

// wdContext.currentContextElement().setCustomerID(wdContext.nodeCust_List_Sel().currentCust_List_SelElement().getKunnr());

// IWDWindow window = wdContext.currentPopupElement().getWindowInstance();

// window.hide();

if (wdContext.currentContextElement().getSelectionMode() == WDTableSelectionMode.SINGLE){

nodeElement.setAttributeValue(fieldName , wdContext.nodeCust_List_Sel().currentCust_List_SelElement().getKunnr());

ExitSelectCustomer();

}

//@@end

}

Former Member
0 Kudos

Thanks, I was able to create a test pop up with.

I have another basic question. We are finding the handle on window and we are passing the window name for poup up. What if I have multiple views in the Window, which one does it open. Is there a way to specify which view to open in a window.

OR

Do I have to create a new window for each pop up?

Thanks

Former Member
0 Kudos

Ravi,

I think the default view of the window will open.

Regards,

Murtuza

Former Member
0 Kudos

Thanks Murtuza.

So I assume, if I have multiple lookup views, I need to create one window for each lookup.

I think I can create multiple windows but Is there a way to dynamically set a default view for the window before I open the window so that I can just create all my lookup views under one window.

Ravi

Former Member
0 Kudos

Hi,

I don't know why you will have multiple views in a window for lookup.

I've over eight lookups so I put each in its own window.

In that way, you can have different methods in different controller to handle different situation.

It adheres to loosely couple and cohesion principle.

I do have a popup to edit a long text field which is genric. But to make it work for all and maintain it becomes a little bit trickier. So it is better to make thing simple.

yung siu wai.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

First of all <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/webdynpro/wd%20java/wd%20tutorials/dialog%20boxes%20in%20web%20dynpro%20applications.pdf">Try this Tutorial</a>

Consider this Scenario

1) Suppose your Node for popup window is <b>pop_up</b> and value attribute is cust_name

2) Node for main window is <b>main_win</b> and value attribute is name

wdContext.currentMain_win().setName(wdContext.currentPop_up.getCust_name());

Regards

Chaitanya.A