Skip to Content
avatar image
Former Member

Dynamic Creation of Buttons and Actions HELP

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);

}"

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Aug 26, 2004 at 08:56 AM

    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

    Add comment
    10|10000 characters needed characters exceeded