cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Creation of Buttons and Actions HELP

Former Member
0 Kudos

Hi there,

I have got a problem (or maybe even two) with the dynamic Creation of buttons. The code below creates the buttons.

My main problem is, that the parameter created for the button's action isn't propagated to the assigned event handler. I get a null, though the name of the parameter in the event handler and the name of the parameter added to the action are the same.

Could it also be that I'm always using the same action? I.e. does wdThis.wdGetAddElementAction() always return the same action instance? If yes, how can I create individual actions for each button?

Any help is appreciated!

Cheers,

Heiko

" for(int i=rootContainer.getChildren().length; i<wdContext.nodeFeature().size();i++)

{

IPrivateVCT_Feature.IFeatureElement featureElement = wdContext.nodeFeature().getFeatureElementAt(i);

IWDTray featureTray = (IWDTray) view.createElement(IWDTray.class, featureElement.getName());

IWDCaption header = (IWDCaption) view.createElement(IWDCaption.class, featureElement.getName()+"_Header");

header.setText(featureElement.getName());

featureTray.setHeader(header);

featureTray.setExpanded(false);

rootContainer.addChild(featureTray);

IWDButton button = (IWDButton) view.createElement(IWDButton.class, featureElement.getName()+"_Button_AddElement");

IWDAction actionAddElement = wdThis.wdGetAddElementAction();

actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());

button.setOnAction(actionAddElement);

button.setText("Add Element");

featureTray.addChild(button);

}"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Heiko,

You have done everything correctly....except for 1 line

in the code...

Replace the following line in your code:

actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());

Replace the above line with this code:

button.mappingOfOnAction().addParameter("featureIndex",i);

Actually in your code, you are not associating the parameter with the button...

Note that addParameter(...) comes with two signatures: addParameter(String param, String value) and addParameter(String param, int value). You can use any of them based on yuor need.

Hope it helps,

Thanks and Regards,

Vishnu Prasad Hegde

Answers (0)