on 10-26-2006 3:26 PM
Hello!
I am very new to the subject of web dynpro programming, and i faced a problem while programming a menu navigation.
I have two views, located in a view Container- one is for my navigation (MenuBar), which should load dynamically different views in my "contentContainer", corresponding to the MenuActionItem Text, which is chosen in the Menu.
The different MenuActionItems have individual texts, but trigger the same event, on which my contentView listens.
How can I find out in wdDoModifyView(), which item has been chosen in the Menu? I think I have to put somehow the "text"-property of the menuActionItem in the parameter of the event? How can this be done?
Thanx in advance for your help!
Ilona Seifert
You ust work with ViewSet and navigation link:
Look this tutorial
View Set 2 | 4 | 13 | 14
Plug, inbound, outbound 1 | 2 | 15 | 40
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ilona,
don't use wdDoModifyView() at all for this. Either create different actions for the menu items or add a constant event parameter to identify the caller of the action.
In newer IDE versions, you can do this with the parameter mapping editor, in older versions, you have to write some code.
Using different actions is probably easiest here (menu action items even inherit text and icon from the assigned action).
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ilona,
if you need something more dynamic, you can go the following route.
You need an event handler method in the view controller. This must be created at designtime.
You can also use a common action "MenuItemSelected" with a parameter "itemID" for all menu items. In that case, you can use a constant event parameter for dispatching which item triggered the action.
Example code:
String[] items = {"DoThis", "DoThat"};
void wdDoModifyView(...)
{
if (<menu must be recreated>)
{
IWDMenu menu = (IWDMenu) view.getElement("menuID");
menu.destroyAllItems();
for (int ix = 0; ix < items.length; ++ix)
{
IWDMenuActionItem menuItem = (IWDMenuActionItem) view.createElement(IWDMenuActionItem.class, null);
menu.addItem(menuItem);
menuItem.setText(items[ix]);
menuItem.setOnAction(wdThis.wdGetOnMenuItemSelectedAction());
menuItem.mappingOfOnAction().setString
(
"itemID", /* name of action parameter */
items[ix] /* text of menu item, better use an ID */
)
}
}
}
void wdOnMenuItemSelected(..., String itemID)
{
if ("DoThis".equals(itemID))
{
/* do this */
}
else if ("DoThat".equals(itemID))
{
/* do that */
}
}
Armin
Hello Armin!
Thanks a lot for your answer! This is exactly what I need. My last problem now is, how to set the different event parameters, according to the menu item which has been clicked. In your case it is the Parameter "itemID", how do I get it, according to the different items?
I have one event in the Controller Interface, which I call by the following source code in my "menu view":
public void onActiongoToContainer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String name ) {
//@@begin onActiongoToContainer(ServerEvent) wdThis.wdGetTrwInterfaceController().wdFireEventNavigationEvent(name);
//@@end
}
Now I need to set the parameter "name", according to the "text"-Attribute of my MenuActionItem or the ID. How do I get it?
Kind Regards
Ilona
Ilona,
Armin already provided an answer, just apply it to your variables/method names:
instead of
menuItem.setOnAction(wdThis.wdGetOnMenuItemSelectedAction());
menuItem.mappingOfOnAction().setString
(
"itemID", /* name of action parameter */
items[ix] /* text of menu item, better use an ID */
)
use
menuItem.setOnAction(wdThis.wdGetOnActiongoToContainer());
menuItem.mappingOfOnAction().setString
(
"name", /* name of action parameter */
items[ix] /* text of menu item, better use an ID */
)
I just replaced action handler name and name of parameter.
So your action handler onActiongoToContainer will get parameter "name" as items[idx] automatically.
VS
For each Menu Item you must have specific Action and OutBoundPlug.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The onAction event of MenuActionItem does not send back any parameters from the client side. So it would not be possible to find out which actionItem has been selected by the user.
The best thing in your case would be to have different event handlers for different actions.
Regards,
Satyajit.
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 | |
9 | |
7 | |
6 | |
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.