Author |
Message |
06/09/2012 15:09:15
|
bthalheim
Power User
Joined: 05/04/2012 11:45:24
Messages: 72
Offline
|
Hi,
I have a Text field which represents a searchbox above a Grid (so it simply uses #{d.SearchBarUI.grid.textSearcher.text}, where SearchBarUI is a PageBean and properly initialized with a reference on the grid it shall search in).
What I want now is that the cursor is set into the field when I push Ctrl+F.
t:field does not have a hotkey attribute, otherwise that would probably do the job.
Which possibilities do I have to achieve what I want?
Thanks,
Björn
|
|
|
06/09/2012 19:57:35
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5555
Offline
|
Hi,
there are two issues you have to bring together:
1. hotkey management via popupmenu definition. Define a POPUPMENU with a POPUPMENUITEM holding ctrl-f as hotkey. Assign the popupmenu to the outest level of your page scenario.
2. explicit server driven focus setting via REQUESTFOCUS attribute.
Both issues are documented + examples are available in the demo workplace. - ...if you there are further questions: of course continue to ask in this thread!
Regards, Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
07/09/2012 14:14:35
|
bthalheim
Power User
Joined: 05/04/2012 11:45:24
Messages: 72
Offline
|
Hi,
OK, that works almost perfectly.
I define a Popup Menu in outmost position:
Code:
<t:popupmenu id="FOCUSMENU" >
<t:menuitem id="g_61" actionListener="#{d.VorgangsEditorUI.searchBarUI.focusSearchField}" hotkey="ctrl-70" text="focusMe!" />
</t:popupmenu>
If I now use popupmenu=FOCUSMENU in my rowbodypane than I can use crtl-F whenever I have focus anywhere in my application and it does what I want.
My problems are now:
1. I would rather not do this popupmenu=FOCUSMENU (so the definition of the popupmenu is fine for my, but I don't want to use it in any concrete component explicitly), because I then need to provide an ActionListener which I don't need.
2. I need to make the popupmenu invisible, but I cannot use rendered=false, because then nothing works.
Do you have any Ideas how to tackle these problems?
Thanks,
Björn
|
|
|
07/09/2012 14:45:45
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5555
Offline
|
...ad 1. the MENUITEM has two action listeners: it has an own one and it invokes the actionListener of the currently assigned component. So you do not need an actionListener everywhere, but only for the specific MENUITEM.
...ad 2. there is an option MENUITEM-HOTKEYONLY. In this case the item is not shown as popup menu.
Regards, Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
07/09/2012 16:54:44
|
bthalheim
Power User
Joined: 05/04/2012 11:45:24
Messages: 72
Offline
|
Hi,
ad2: Thanks, that is the hint I needed.
ad1: Right, and I do already exactly as you write. Problem is, I need to _use_ the popupmenu somewhere, so I use it in my rowbodypane. But if I do that, the Dev tools critisize me for not providing an actionListener on that rowbodypane, which, as you wrote, is unnessecary because we use the actionListener on the MenuItem.
In code:
Code:
<t:rowbodypane ... popupmenu="FOCUSMENU" ... >
The Dev Tools Logic says that if there is a popupmenu, there needs to be an actionlistener too, but you and I know better. Is there a way to convince the dev tools of our opinion? Or would you suggest a different place to _use_ out Popupmenu?
Thanks,
Björn
|
|
|
07/09/2012 19:18:51
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5555
Offline
|
...OK, here the dev tool is a bit too pessimistic! ;-)
Regards, Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
07/09/2012 22:45:39
|
bthalheim
Power User
Joined: 05/04/2012 11:45:24
Messages: 72
Offline
|
...OK, here the dev tool is a bit too pessimistic! ;-)
So I just ignore that and maybe the Dev Tools will be smarter sometime in the future (to check all menuitems if they have an actionListener already)?
This is some weird habit of me to feel incomfortable whenever I need to ignore warnings of my tools ;-)
Thanks for your help, I got my Shortcut-Focus now quite well done.
Cheers,
Björn
|
|
|
12/09/2012 10:23:56
|
bthalheim
Power User
Joined: 05/04/2012 11:45:24
Messages: 72
Offline
|
Hi,
in order to suppress this warning, I did this (plus used the method here to bind it where the Dev Tools force me to):
Code:
@CCGenClass(expressionBase = "#{d.DummyUI}")
public class DummyUI extends WorkpageDispatchedBean implements Serializable {
private static final long serialVersionUID = 1L;
public DummyUI(IWorkpageDispatcher workpageDispatcher) {
super(workpageDispatcher);
}
public void onThisDoNothing(ActionEvent event) {
}
}
This way I suppress these false positive warnings.
Cheers,
Björn
|
|
|
|