cancel
Showing results for 
Search instead for 
Did you mean: 

Setting visibility on UI Elements in different views

Former Member
0 Kudos

Hey!

I got to Views viewA og and viewB.

Between viewA and viewB i have a fireplug.

And in viewB there are some buttons (button1, button2).

Depending on what is choosen in viewA I want to set visibility to 'none' on button1 or button2 in the onActionGoToViewB.

The UI elements (inluded the button) is created with the "Layout" tool in Web Dynpro..

Can someone help me control the visibility true the code?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Follow tyhis steps to achieve ur scenario.

1) Create 2 views. View A and View B.

2) In view B lets say u have one button.

3) create a context in view B of type com.sap.ide.webdynpro.uielementdefenitions-->visibility.

4) click on the button properties.Set the visible property to the context that was created.

5) create another context att in view A of same visibility type.

6) Map the con att of view B to View A through comp.ctrller.

7) In the on action of the view A,set the visibility accordingly for the btn in view B.

Visibility can be set by the following codes,

wdcontext.currentcontextalment.set<att>(wdvisibility.none) or (wdvisibility.visible)

Hope it helps,

Regards,

Nagarajan.

Former Member
0 Kudos

Thanx man!

this really helped me out.

I tried what you said, and it works perfect!

i got another question too, but i'll open up a new thread.

Thanks again!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

This is my understanding of the problem:

On selection of something on View A you want to set the visibility of buttons in View B

Firstly create context attributes of type: <b>WDVisibility</b>.And associate these context attributes with the Visibility Property of Buttons.

Now, create a context attribute of type integer or string or anything in View A and name it "flag" and put that in component controller and also in View B. and do the context mapping . On firing the plug pass the value of flag to View B. Here create a method which reads this value of flag and change the visibility of buttons.

Hope this helps

Thanks

Srikant

Former Member
0 Kudos

Hi Kristoffer,

You can create an attribute of type com.sap.ide.webdynpro.uielementdefinitions.Visibility in the context, map this to the 'Visible' property of your UI element. Of course, since you want to control two UI elements and they can have different values you'll need two context attribtues.

Then in the your onAction method simply write the code that you desire:

wdContext.currentContextElement().setButton1Visible(WDVisibility.VISIBLE);
wdContext.currentContextElement().setButton2Visible(WDVisibility.NONE);

where Button1Visible and Button2Visible are your context attributes.

Since you want to control the behaviour across views, put these attributes in the component controllers' context. That way both views can access them, viewA to set them and viewB to map them to the UI elements.

I hope this helps,

Patrick.