cancel
Showing results for 
Search instead for 
Did you mean: 

Visibility of button in WDJ

former_member211107
Participant
0 Kudos

Hi experts,

I am trying to set the visibility of a button in my application. I am setting the visibility as "none" in the wdInit of a view. The visibility property of the button is binded to an attribute of JAVA native type "WDVisibility" or Dictionary simple type -> uielementdefinitions --> visibily...i.e i have tried both.

My application is dumping at exactly the same line were in am setting the visibility of the button as "NONE" in the wdInit. Dont know y is it happening. Please lte me know were m i going wrong in this.

Regards,

KM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The context attribute at design-time must be of DDIC type "Visibility", not Java native type "WDVisibility". At runtime it will be WDVisibility.

The most probable reason for your "dumb" (NullPointerException?) is that you access the attribute via the lead selection of its context node but the lead selection is not set or the node is empty.

Armin

Former Member
0 Kudos

Or, the visibility attribute is part of a node which has cardinality 0..1 or 0..n. If you've defined the visibility attribute in a node, make sure the cardinality of the node is 1..1.

Former Member
0 Kudos

This case (which most probably is the reason here) is included in my answer. Cardinality 1:1 and selection cardinality 1:1 will avoid the issue.

Armin

p330068
Active Contributor
0 Kudos

Hi KM,

Bernd is right...also adding the points

Create context attribute :

Name : btn_visibility

Type : com.sap.ide.webdynpro.uielementdefinitions.Visibility

Button UI Element :

Set property Visibility : btn_visibility

Code like :

if (CONDITION)

{

wdContext.currentContext().setBtn_visibility(WDVisibility.VISIBLE);

}else{

wdContext.currentContext().setBtn_visibility(WDVisibility.NONE);

}

If you are still facing the issue, then create the same context node like btn_visibility in component controller and bind them with view context and code in component controller.

Hope it helps

Regards

Arun

bernd_speckmann
Contributor
0 Kudos

Can you provide a detailed error message?

You should use the visibilty from uielementdefinitions.

In general:

1. Create context node and an attribute "buttonVisibilty" with simple type from uielementdefinitions "Visibility"

2. Bind the context attribute to your buttons visibility property

3. in wdDoInit you can set the visibility with wdContext.currentContextElement.setButtonVisibilty(WDVisibility.NONE);

Hope this helps.