IntelliJ Java IDE
The moose likes JSF and the fly likes Fire a method on key stroke [SOLVED] Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Fire a method on key stroke [SOLVED]" Watch "Fire a method on key stroke [SOLVED]" New topic
Author

Fire a method on key stroke [SOLVED]

Leigh Taylor
Greenhorn

Joined: Feb 19, 2008
Posts: 20
Hi,

I'm trying to include some functionality into my project with the following logic. For each press of a key in an input text field, trigger a java method.

Is it possible to do this using jsf with a4j?

You can call a javaScipt method on each key press so i'm sure the same is applicable for a java method.

I am using a <h:inputText> tag and tried using some a4j support but haven't had any luck.

Leigh
[ March 03, 2008: Message edited by: Leigh Taylor ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12513

You should. But the javascript key event handler would have to do an AJAX submit to the J2EE server each time and (presumably) handle the resulting response.

It's likely to be very sluggish, especially on the open Internet.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Leigh Taylor
Greenhorn

Joined: Feb 19, 2008
Posts: 20
Thanks Tim,

I have found a way to do and so far have only tested it with a one person load and it seems fast. Will be interesting to see how it goes under load. Will post results back up here when i do that.

<h:inputText id="IA_Lcly" value="#{searchUI.lclyName}">
<a4j:support event="onkeyup" limitToList="true"
action="#{searchUI.calculateMatchesOnTheFly}"
reRender="OA_Panel" />
</h:inputText>

Leigh
 
 
subject: Fire a method on key stroke [SOLVED]
 
Threads others viewed
Can you stop a method request by recalling the method?
How to identify which commandLink was clicked? [SOLVED]
a4j:jsFunction outcome redirect
Iteration using a4j without a collection
Jsf rerender using javascript
developer file tools