[Logo] OLD FORUM - Use new one: https://www.CaptainCasa.online/forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
menuitem and its attribute accessiblename  XML
Forum Index -> Development
Author Message
levy

Power User

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

Hi,

I am not able to get the attribute "accessiblename" from the BaseActionEventSelect related to a component of type t:menuitem.

Can anybody help?

Regards, Daniel
[WWW]
CaptainCasa

Power User
[Avatar]

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

Hi,

is it a POPUPMENU?

If so: there are two events:
(1.) the MENUITEM-ACTIONLISTENER receives an invoke-event
(2.) the control on which the menu item was selected receives a popupmenu-event

In case (1.) you can access the attibutes of the menu item, in (2.) you can access the attributes of the receiving control.

...why do you access the accessiblename? Do you "park" certain information with this attribute?

Regards, Björn

Björn Müller, CaptainCasa GmbH
levy

Power User

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

Hi,

It is a buttonmenu.

Instead of having a listening method per item
onActionItem1(ActionEvent), onActionItem2(ActionEvent),...

I wanted to have only one listening method onActionItem(ActionEvent). Within the method, I would recognize the selected item (by "parking" the "meaning" of the menuitem in the attribute accessiblename or reference or similar). Is this a good idea?

Regards, Daniel
[WWW]
CaptainCasa

Power User
[Avatar]

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

Hi,

first of all... it works exactly the way you describe. I jsut tested with BUTTONMENU and MENUTITEM + no problem! Maybe you made a typo in "accessiblename"? ;-) I added my code below.

But...: do not "mis-use" the attribute ACCESSIBLENAME...! I would strongly recommend to use the two attributes which are specially prepared for this: REFERENCE and COMMENT. For these attributes there are prepared methods in BaseActionEvent:

getSourceReference()
and getSourceComment()

Regards! Björn



Code:
     public void onAction(ActionEvent event)
     {
         BaseActionEvent e = (BaseActionEvent)event;
         Statusbar.outputAlert("Action: " + e.getSourceReference() + "/" + 
                               ((BaseComponent)e.getSource()).getAttributeString("accessiblename"));
     }
 

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