cancel
Showing results for 
Search instead for 
Did you mean: 

How can I bind a dynamically created button to a Context Element

felix_dukek2
Explorer
0 Kudos
50

Hi experts,

I am creating a few buttons dynamically (button1, button2 etc.).

I also have a context attribute (visBtn) with the type "Visibility".

Is it possible to bind the visibility attribute of each button to a element of the context attribute?

So button1 is bound to visBtn[1], button2 to visBtn[2] etc.

Thanks in advance

Felix

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Your question suggests (at least to me) that you want to bind the "visible" property of the given buttons to an attribute of a context node such that the first button is bound to the first context node element, the second to the second etc.

If that is your goal, it is not possible.

However you can bind the "visible" property of each button to a different context attribute which could be defined at the context root level or inside a common 1:1-cardinality value node.

The code to do that has already been described correctly.

Armin

Answers (4)

Answers (4)

felix_dukek2
Explorer
0 Kudos

Hi Armin,

that was exactly what I wanted to do.

But in this case I think I will try it they way, you are recommending.

Thanks and best regards

Felix

nikhil_bose
Active Contributor
0 Kudos

try this code


IWDAttributeInfo visattr = wdContext.getNodeInfo().getAttribute("visBtn");
if(firstTime){
 IWDButton button = (IWDButton) view.createElement(IWDButton.class, "button1");
 button.setText("Click");
 button.bindVisible( visBtn);
}

nikhil

PradeepBondla
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi,

Following is the code to do it



IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("visBtn");
	  IWDButton button =(IWDButton)view.createElement(IWDButton.class);
	  button.bindVisible(attributeInfo);

//Align this according to your context. I assume visBtn is under Root of the context

Regards

Ayyapparaj