cancel
Showing results for 
Search instead for 
Did you mean: 

DYNAMIC ViewContainer

Former Member
0 Kudos

Hi all,

I have one component with a parent view containing a ViewContainerUIElement. I have a child view embedded in that ViewContainer and I have a couple of buttons in the parent view. On clicking these buttons, I want to switch the embedded child with another one.

How can I do that dynamically? I know how to do it using plugs!

Regards,

Motaz

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

No solution found.

Thread closed.

Former Member
0 Kudos

Hi all,

Nobody has any idea why I cant switch view usage outside the wdDoInit method?

Regards,

Motaz

Former Member
0 Kudos

Hi Sudhir,

I do not want to create UI elements, I only want to switch the DefaultViewUsage to another one with a different view or set the view in the current DefaultViewUsage to another view.

I have code that works and does this, but this code does not work except in the wdDoInit.

Any ideas?

Regards,

Motaz

Former Member
0 Kudos

Hi All,

No one has any idea why code would work in the wdDoInit method and not in any other methods?

Regards,

Motaz

Former Member
0 Kudos

Hi ..

Before explaining i am using one concept of creating UI Element of Views.UI will created not only wdDoinit() but also it will created in wdDoModify() with firstTime..

when ever you will be triggering action/any butoon of any clicking event then most of method in controller are executing implicitly then it made the error due to instantiated the UI API every time so that instantiated every time means it makes the run time error.It can not make any reference with same Id .but it can not created with UI element thats why we will created UI Element using in method wdDoModify() with firstTime and wdDoinit().due to it will executed only once (in case of wdDoModify())

wdDomodify(.....................boolean firstTime..............)

{

if(firstTime){

//creattion UI Element

}

}

this piece of code executed only once.

Former Member
0 Kudos

Hi All,

Valery's code is working but only in wdDoInit(). How can I switch views from a button?

Regards,

Motaz

Former Member
0 Kudos

Hi Pravesh,

Thank You for answering quickly. However, I don't want to embed all children in the container and change their visibility, rather I only one embedded child and any more children I have to embed at runtime.

Any ideas how this could be done?

I used code provided by Valery in another thread. My main problem there is I can't get the target view as IWDAbstractViewInfo.

Here is the code I am using:

final IWDWindowInfo myWindow = wdComponentAPI.getComponentInfo().findInWindows("ViewContainerCompWindow");

final IWDViewUsageInfo VCUIMain = myWindow.getViewUsageByID("VCMain");

final IWDViewContainerAssignmentInfo VCAIMain = (IWDViewContainerAssignmentInfo)VCUIMain.getViewContainerAssignments().iterator().next();

final IWDViewUsageInfo VUInner = VCAIMain.createEmbeddedViewUsage();

final IWDViewUsageInfo Child = myWindow.getViewUsageByID("Child2");

VUInner.setView(Child.getView());

VCAIMain.setDefaultViewUsage(VUInner);

Child.getView() returns IWDAbstractViewInfo but it is not working.

Any ideas on how to get a view as IWDAbstractViewInfo?

Regards,

Motaz

Edited by: Motaz Abu Karat on Jul 16, 2009 12:49 PM

Former Member
0 Kudos

A solution:

you have child1View and child2View. On the parent view you have the button goChild2Button

now, define an event on the component controller: goChild2Event

define an event handler on chield1View with the event source: goChild2Event

then, you push the goChild2Button and this function calls a function on the controller wich launch the event goChild2Event. This event is caught on the event handler on child1View. Inside this event handler is fire the plug to child2View.

Regards

JC

you need to create navigation from child1View to child2View (a pair of plugs connected)

Edited by: Jean Carlo Abreu on Jul 16, 2009 1:15 PM

Former Member
0 Kudos

Hi Jean,

I need to do it without plugs now

Any other ideas?

Regards,

Motaz

pravesh_verma
Active Contributor
0 Kudos

Hi Motaz,

There is a visibility property of ViewContainer. You can use this property to manage the visibility of the container dynamically in your code. Please follow this approach:

1) Create as many number of Visibiltiy attributes as you have the View Containers. You can name them as Visibility1, Visibility2, etc.. You have to select the data type Visibility from Type-> Browse-> Simple Type -> com.sap.ide.webdynpro.uielementsdefinition -> Visibility.

2) In the view layout bind these visibility parameters with Visibility property of the view containers according to the number.

3) Write this code on the click of the button for a particular View container.


// I am assuming that you have created the attributes directly under the context node.
wdContext.currentContextElement().setVisibility1(WDVisibility.VISIBLE);
wdContext.currentContextElement().setVisibility2(WDVisibility.NONE);
wdContext.currentContextElement().setVisibility3(WDVisibility.NONE);

/*
// If the attributes are not directly under the context node then use this code.
wdContext.current<NODE_NAME>Element().setVisibility1(WDVisibility.VISIBLE);
wdContext.current<NODE_NAME>Element().setVisibility2(WDVisibility.NONE);
wdContext.current<NODE_NAME>Element().setVisibility3(WDVisibility.NONE);
*/

NOTE: Please note that you have to do this separately for each button click according to the view container. For first container set it VISIBLE for first visibiltiy attribute, rest all will be NONE as shown in the code above.. For second set the second attribute as VISIBLE and so on.

I hope this will solve your problem. Please revert back in case you need any further information on this.

Thanks and Regards

Pravesh