on 03-13-2009 10:35 AM
hi,
I have few menuactionitem UI elements in a menu UI elem. I have bound the same Action to all the menuactionitem's OnAction property. I have created a parameter in this action. This parameter is to identify at runtime which menuactionitem has been clicked.
When I click on the menuaction item at runtime, it throws ClassCastException.
Does anyone has any idea wht is the problem ?
The type of parameter that I am using with the action is IWDMenuActionItem. Do I need to change the type of parameter. If yes, then wht shud be its type. The purpose is to get handle of the menuactionitem that has been clicked by the user.
Any help is greatly appreciated !
Thankyou !
Edited by: codenoob on Mar 13, 2009 11:35 AM
Edited by: codenoob on Mar 13, 2009 11:36 AM
Hi
What is the parameter for this?
MenuActionItem require parameter of type nodeElement (IWDNodeElement) so pass this error will resolve.
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
thankyou satish for fast reply. I shall change the type of parameter to IWDNodeElement and try.
I am not able to make any change in the code due to some other process running in NWDS.
can you tell me how do we come to know that what shud be the type of parameter for various UI elements ?
Like if the action is bound to a button UI elm and I want to pass a parameter to identify which button is clicked then wht shud be type of parameter in the associated action ? similarly for other UI elem on which action can be applied like link to action, link to URL etc..
Regards,
Codenoob.
satish,
I tried using String also, but the parameter of string type does not carry the ID of the menuactionitem.
It simply is null string.
When the type of parameter is String, In parameter mapping statement I am writing the following...
just have a look ..is it correct ?
IWDMenuActionItem mnuitem = (IWDMenuActionItem) view.getElement("mnu_Material");
mnuitem.mappingOfOnAction().addSourceMapping("nodeElement","attribute");
where attribute is the name of parameter.
Shud I use something else inplace of "nodeElement" ; the first parameter of addSourceMapping() method ?
Edited by: codenoob on Mar 13, 2009 12:28 PM
Hi,
Following is a way to use it
public void wdDoModifyView(com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime)
{
for (int index = 0;index < 10;index ++)
{
IWDMenuActionItem menuItem = (IWDMenuActionItem)view.createElement(IWDMenuActionItem.class);
menuItem.setOnAction(wdThis.wdGetMyActionAction()); // This action "MyAction" Should be existing
menuItem.mappingOfOnAction().setInt("Index", index);
}
}
//@@end
}
//@@end
public void onActionMyAction(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int Index )
{
//@@begin onActionMyAction(ServerEvent)
//Use index to find the respective button pressed
//@@end
}
Regards
Ayyapparaj
I want the ID of element at runtime. I have declared action and its parameter at design time.
I have bound this action to all the menuactionitems in the menu.
Now when I click on menuaction item, the control goes to eventhandellar of the action defined and bound to this menuactionitem. In this eventhandellar, I want to get the ID of menuaction item ...that has been clicked by the user .
Add an action parameter "menuItemId" of type "string" to the action (and its event handler method).
Define a parameter mapping that fills the "menuItemId" for each menu item. This can either be done at design-time using the parameter mapping editor ("fixed parameter") or using code like this:
wdDoModifyView(...)
{
if (firstTime)
{
IWDMenu menu = (IWDMenu) view.getElement("menu_id");
for (Iterator items = menu.iterateItems(); items.hasNext(); )
{
IWDMenuItem item = (IWDMenuItem) items.next();
if (item instanceof IWDMenuActionItem)
{
((IWDMenuActionItem) item).mappingOfOnAction().addParameter("menuItemId", item.getId());
/* in newer releases use setString(...) */
}
}
}
}
Armin
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.