cancel
Showing results for 
Search instead for 
Did you mean: 

To change view property during runtime

Former Member
0 Kudos

Hi,

I have a scenario where we have 2 views embedded in a window.

First View's property is set to True and second View's property is set to false.

We have a button say "show view" in first view and now we want to change the second view's property to True on click of that button i.e we want to change the view proerties to True during runtime.

We are unabelt o achieve this thruogh plugs are first view is in another DC and second view is in other DC.

Is there any other way to through which we can achieve this?

Any help is this regard is highly appreciated.

Regards,

Richa Sinha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I did not get your question clearly.

I will try to replicate your requriment. Correct me if i am wrong.

You have two views (View1, View2) in one Window.

Initiallly View1 will be displayed by default in Window.

When you click on a buttion (Show View) in View1, then View2 should be displayed in the same window.

If this is the case, then the solutions are as below:

If both the views are in the same WebDynpro Component:

You need to create outbound plug to View1 and inbound plug to View2 and connect these two plugs. And when user clicks on that button(Show View), you need to fire the outbound plug of View1 which will navigate to View2.

If both the views are in different WebDynpro Components Comp1 & Comp2(different DCs does not matter):

First embed the interface view of Comp2 in Comp1

Create an outbound plug to View1 in Comp1 and an inbound plug to InterfaceView of Comp2(Or you can use default plug). Now connect both the plugs.you need to fire the outbound plug of View1 which will navigate to View2 in Comp2.

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

Thanks for your promt reply.

However in my case i am embedding interface view of Comp2 in Comp1 hence want to create OUTBOUND plug from Comp2 .But getting a default inbound plug there and unable to create an Outbound plug.

We are embedding views in this manner because of many parameters associated with Comp1.

So we are looking for another way to achieve visisbity of views instead of via plugs.

Can we change the "Default" properties of the view to TRUE in run time through code and achieve the same?

Currently, i have created context(type Visibility) for both the views and have mapped the contexts with the root UI element property Visible of both the views. However in this case even the functionality is nt achieved on click of the button. the fisrt view is getting disappeared but the second view is not visible hence its a blank window on click on the button.

Regards,

Richa Sinha

Former Member
0 Kudos

Hi,

Sorry still i am confused.

Please post your requirement clearly.

What and all Comps & Views you have and how they should be displayed to the user.

Eventhough there is so much context , we can share through interface controller. So having more parameters is not at all a problem.

And we can use ViewContainerUIElements also ...

Give your requirement clearly..

And as per my knowledge it is not possible to change the default property(true/false) of views in window.

Regards,

Charan

Former Member
0 Kudos

Hi,

Sorry for a confusing Post.

Requirement is:

1) DC1 with Component1 with View1

2) Make DC1 as used DC so that it can be used in another DC

3) DC2 with Component2 and a window Window1 with 2 views (View2 and interface view i.e View1 of used DC)

4) View1 default property is set to true and View2 dafault property is set to False

5) => View1 is visible in Window1 and View2 is invisible.

6) On click on a button in View1, View2 should become visible and View1 should become invisible

Difficulties faced:

1) View1 is interface view hence is having a default inbound plug and i am unable to create an outbound plug. hence unable to navigation to views via plugs and achieve the functionality.

2) Have created 2 context :Context1 Context2.

Context 1 is mapped to RootUIElement of View1 and Context2 is mapped to RootUIElement of View2.

On button's action i have written the code

wdContext.currentContextElement().setContext1(WDVisibility.BLANK);

wdContext.currentContextElement().setContext2(WDVisibility.VISIBLE);

However on click of the button the window is blank without any view.

Regards,

Richa Sinha

Former Member
0 Kudos

Hi,

I got your requirement,

Yes if you want navigate back to source view, the problem is you cannot add the the Comp2 again in Comp1 as used comp. This will give cyclic dependancy error.

Try like this.

In Comp2, create an additional view like NavigationView (for example).

In NavigationView create two ViewContainerUIElements (ViewContainerUIElement1 & ViewContainerUIElement2).

Embed this NavigationView into Comp2Window and remove View1's Inteface view & View2 from this window. Change the NavigationView property to true.

And go the Comp2Window Navigation Modeler, embed View1's Inteface view in ViewContainerUIElement1 & View2 in ViewContainerUIElement2.

Now create two context attributes View1Visibility & View2Visibilty in NavigationView and modify the type property to WDVisibility.

Bind these two attributes to corresponding ViewContainerUI elements.

Now in Navigation view, You can create one button and in that button action you can control the visibility of these views.

Hope this info helps. If you need more clarification or info please let me know.

Regards,

Charan

Former Member
0 Kudos

Hi Richa,

I'll try to explain what I have understood, you have two Web Dynpro DCs, DC1 and DC2.

1) DC1 is a used DC in DC2.

2) The View in DC1 is the default view in DC2 window.

3) You should be able to navigate from the View in DC1 to the View in DC2.

Now if the above is your requirement then it can be achieved through plugs.

You have done 1 and 2. For 3 click on the InterfaceView of DC1. You will see a tab for Plugs. Create an outbound plug. Write the code in the view to call the method to fire the plug on click of the button. Build your DC1.

Then go to DC2, and click on the window. There you will see the outbound plug in the InterfaceView, create the navigation link between the InterfaceView and View in DC2. Build and run it.

Similarly, if you want to navigate again to the view in DC1 create an inbound plug there and build. But, the navigation links will be created in DC2.

You can map the context attributes to share the values across the DCs.

Regards,

Kartikaye

Former Member
0 Kudos

Hi,

Yes, As "Kartikaye Gomber" said, you can create an outbound plug to Comp1InterfaceView and you can invoke this plug in View1 on button action. This works fine. Better to use this approach.

I hope whatever approach i suggested (ViewContainerUIElement) also works well.

Regards,

Charan

Former Member
0 Kudos

Hi Kartikaye and Charan,

Thanks for your replies.

1) Solution suggested by Karthikaye:

"For 3 click on the InterfaceView of DC1. You will see a tab for Plugs. Create an outbound plug. Write the code in the view to call the method to fire the plug on click of the button. Build your DC1"

I already tried this approach.However under InterfaceView we have windows and inside the window we have views.

In my case, the window used is default window of DC2.Hence in interface view we have that window with the inteface view embedded. Hence cannot create outbound plug in the inteface view.

2) Solution suggested by Charan:

"To create navigation views"

Here, even we create navigation view or directly embedded the views(View2 and interface view) in the Window1 of DC2, we can control the view's visibility only through context.

As mentioned earlier, I tried the following piece of code on button's action code:

wdContext.currentContextElement().setContext1(WDVisibility.BLANK);

wdContext.currentContextElement().setContext2(WDVisibility.VISIBLE);

However on click of the button the window is blank without any view.

Former Member
0 Kudos

Hi,

You did not get my approach clearly.

You need to create ViewContainerUIElement ( it is a UI element) for both the views in a sepearte NavigationView in Comp2. And then in window embed these two views in those view container ui elements. Then control the visibility of these ViewContainerUI elements throgh context attributes.

And regarding plugs approach. I tested it. Its working fine. I think you are missing some thing.

You can create an standard outbound plug to Comp1IInterfaceView.

Please create a sample project and try to replicate both the approaches carefully as the procedure give by me (for ViewContainerUIElements ). I think both the approaches works without any issues.

Regards,

Charan

Former Member
0 Kudos

Hi Richa,

Lets go throught the development components details:

DC1 (To be shared)

Create a separate Window and InterfaceView for your navigation to another DC.

- InterfaceView : this has the outbound and inbound plug. The new InterfaceView, it will not have a default inbound plug. Make inbound plug in it say "fromDC2" and outbound plug "toDC2"

- Window: This is the new window.

- View : This the view you want to access, embed it in the window. Fire the outbound plug "toDC2" on the necessary event.

DC2 (has DC1 as used DC)

- InterfaceView : Default. Nothing to be done

- Window: Add the InterfaceView of DC1. Create navigation to the DC1 InterfaceView and back. That is, a navigation link to "fromDC2" and "toDC2".

- Component: in WdInit fire the outbound plug to DC1 (navigation link to "fromDC2").

- View : With the functionality as required. Fire the outbound plug to DC1 on the necessary event.

Dont use the default Window and InterfaceView in DC1. Create a new set and check.

Regards,

Kartikaye

Former Member
0 Kudos

Thanks Charan and Kartikaye. The issue is now resolved.

I didnt add the interface controller as used component and hence was not getting the fireoutplug in the code.

Added the interface and was able to navigate successfully and achieve the requirement.

Thanks for your help.Points rewarded

Regards,

Richa Sinha

Answers (0)