on 05-23-2007 4:23 PM
Hi,
I am dynamically creating a bunch of LinkToAction UIElements. I would like to bind these linktoactions to a single action with an integer parameter. Is it possible? If so, could somebody give a code sample?
Thanks
Hi,
One possible way could be the following:
In your wdDoModifyView(presumably that's where you are creating these UI elements dynamically), use the following code
//say you are within a loop and index is your looping index
IWDLinkToAction link = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,"link_"+index);
link.setOnAction(wdThis.wdGetGenericAction()); //GenericAction is the name of the action that all links point to.
link.mappingOfOnAction().addParameter("commandId",index);
Create a new action called GenericAction. Write your generic action like the following:
public void onGenericAction (IWDCustomEvent wdEvent , int commandId )
{
//@@begin onGenericAction(ServerEvent)
switch(commandId)
{
case 0: ExecuteCommand_1();
break;
case 1: ExecuteCommand_2();
break;
// ...
}
}
Regards,
Satyajit.
Message was edited by:
Satyajit Chakraborty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
U r Awesome....It worked. The statement that I was missing is link.mappingOfOnAction().addParameter("commandId",index);
Thanks a ton.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.