cancel
Showing results for 
Search instead for 
Did you mean: 

how to get id of button from event

Former Member
0 Kudos

Hi all!

I want to use one action for several buttons in a view. When I hit one, I want to get the id of the button from the event. I know that it's not in the standard, anyway I found a post by Maksim Rashchynski who proposed to use wdDoModifyView like this:

final String id = element.getId();

final IWDButton button = (IWDButton)element;

button.mappingOfOnAction().addParameter( "actionID", id );

sounds nice, but what is element? Where can I get it from?

anybody?

thanks

stefan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos
wdDoModifyView()
{
  IWDButton button = (IWDButton) view.getElement("MyButton");
  button.mappingOfOnAction().addParameter("buttonID", button.getId());
}

(in more recent IDE versions this can be done in the view designer without code)

Action "A" assigned to button: Add parameter "buttonID" of type string.

Action handler:

onActionA(..., String buttonID)
{
  /* check button ID */
  if ("MyButton".equals(buttonID))
  {
  }
}

Armin

Former Member
0 Kudos

wdDoModifyView()

{

IWDButton button = (IWDButton) view.getElement("MyButton");

button.mappingOfOnAction().addParameter("buttonID", button.getId());

}

is useless, as long as I don't know which id the button has, that is what I want to find out.

We use SP19 it had no effect to add the parameter to the action: buttonID is null.

Former Member
0 Kudos

This is not possible, a UI element ID is never NULL at runtime, even if you pass NULL in the createElement() call.

Is the action parameter name exactly the same as the string passed to the addParameter() method?

Armin

Former Member
0 Kudos

Hello Armin

What did you mean by "in more recent IDE versions this can be done in the view designer without code"?

We have NWDS 7.0.0 (Developer Workpace 2004s, SP4).

Is that recent enough?

What can I do and where in the layout view properties of a button?

As far as I know there is no other way to add parameters to an event other than by the wdDoModifyView() method.

Regards

Kilian

Former Member
0 Kudos

In the Outline view, right-click the button and check if there is a "Parameter Mapping" entry in the context menu.

Armin