on 08-26-2004 9:37 AM
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);
}"
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.