cancel
Showing results for 
Search instead for 
Did you mean: 

LinkToAction parameter mapping?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

U r Awesome....It worked. The statement that I was missing is link.mappingOfOnAction().addParameter("commandId",index);

Thanks a ton.