[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Event reaction on MENUITEM level  XML
Forum Index -> Development
Author Message
levy

Power User

Joined: 12/03/2008 16:38:22
Messages: 308
Location: XpertCenter
Offline

Hi,

In the developers guide, it is written that on MENUITEM level, the event that is passed is of type BaseActionEventInvoke. But I have found out that it is of type BaseActionEventSelect.

In the demo workplace, it is written that each popup menu item is associated with a command. In the editor, I have typed a just casual string in the command attribute of the menu item. But the event passes the string "select". Looking at the help for the command attribute, it seems that it is reserved for use with ActiveX.

Should we avoid the command attribute when using the popup menu item in a "normal way" (with no ActiveX involved)?

Regards, Daniel
[WWW]
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi Daniel,

"Select" <==> "Invoke": yes, the documentation is referencing the wrong event, it is BaseActionEventSelect. Thanks for telling us, the docu is updated with the next update. (I just checked + am glad to tell that the event-field in the layout editor below the attributes shows the right Select-event...).

"command":
...the F1 docue is mis-leading: the documentation internally is plugged to the attribute name - "command" is both used in the MENUITEM and in the ACTIVEX component. We now updated the docu in the way "If used with MENUITEM: ...., if used with ACTIVEX ....".
The usage of the command in the (popup-) MENUITEM is the following: there are two action listeners called: the one of the MENUITEM itself (this is the usual BaseActionEventSelect) and the one of the component referencing the popup menu. In this component the BAseActionEventPopupMenuItem-event is passed, and this one is the one to check for the command. For all other events "getCommand()" is passing back the internal String that is held for the event-type (e.g. "select" for BaseActionEventSelect), but for the BAseActionEventPopuMenuItem it holds the command of the referenced menu item.

Why are there two action listeners called with the popup menu item? Because one and the same POPUPMENUT definition may be referenced from different components. If you define a popup menu "Translate, Clear" and refer to it from different FIELD components, then you need to know which FIELD was the one on which the user executed e.g. "Translate". So the FIELD's action listener is called with BaseActionEventPopupMenuItem, passing the command of the MENUITEM that was executed.

Björn

Björn Müller, CaptainCasa GmbH
bthalheim

Power User

Joined: 05/04/2012 11:45:24
Messages: 72
Offline

Hi Björn,

i have read over and over over that thing with the Command and I still don't understand it.
Could you provide a coding example?

My scenario is the following:
I would like to create a dynamic (via ROWDYNAMICCONTENT) hierarchic ButtonMenu where all items reference the same action listener which can receive a payload (in my case: an entity ID) and adapt its behaviour.

In my ideal world, things look like this:
Code:
 <buttonmenu> ...
   <menuitem command="id1" actionListener="{d.UIBean.onSelectMenuItem} ... />
   <menuitem command="id2" actionListener="{d.UIBean.onSelectMenuItem} .../>
 ...
 

My UI Bean Code would look like this:
Code:
 ...
   public void onSelectMenuItem(ActionEvent event) {
     // Command in {id1, id2}
     callBusinessLogicMethod(event.getCommand());
     ...
   }
 ...
 


Thanks,

Björn
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi,

in your example:

Create the MENUITEM Hierarchy with DYANMICCONTENT, assign one action listener to all items and assign a separate REFERENCE attribute to each item.

In the action-processing you can then ask for the reference by using BaseActionEvent.getSrcReference().

The COMMAND is used for POPUPMENU management (this is the original background of this thread.)

Regards, Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team