-
1. Re: <a4j:support> conditional expression ???
ilya_shaikovsky Dec 14, 2009 10:20 AM (in response to swario)check a4j:jsFunction component. It will better fit your needs especially together with rich:hotKey -
2. Re: <a4j:support> conditional expression ???
user1234 Dec 15, 2009 5:19 AM (in response to swario)yes rich:hotkey will be solution where you can specify the key as enter, so that when enter will be pressed your code will be called. otherwise you can use javascript also with a4j:support.
onsubmit all a javascript to check event.keyCode or event.which if it is "13" only the return true, else return false,
if onsubmit return false then it will not excecute the action listner.
-
3. Re: <a4j:support> conditional expression ???
swario Dec 15, 2009 5:58 AM (in response to user1234)ok. well
my code is right this:
<h:inputText ... >
<a:support event="onkeydown" onsubmit="return event.keyCode==13" actionListener="#{my_bean.my_method()}"/></h:inputText>
but still not working...
-
4. Re: <a4j:support> conditional expression ???
ilya_shaikovsky Dec 15, 2009 6:06 AM (in response to swario)should be like this:
<h:inputText ... >
<a:support event="onkeydown" onsubmit="if (event.keyCode!=13) return false; " actionListener="#{my_bean.my_method()}"/></h:inputText>
in your case - you call return not conditionally but always - so ajax script added after onsubmit call never called.
-
5. Re: <a4j:support> conditional expression ???
user1234 Dec 15, 2009 6:07 AM (in response to swario)call something like this
<h:inputText ... >
<a4j:support event="onkeydown" onsubmit="if(!chkkeycode(event)){return false;}" actionListener="#{my_bean.my_method()}"/></h:inputText>
and js method
function chkkeycode(event){
if
(window.event) keycode = window.event.keyCode;
else if (event) keycode = event.which;
if (keycode==13) {
return true;
}else{
return false;
}
}
Please remeber , when you press enter on a filed the form will be submitted if you don't want to submit the page you have to prevent that submit event by java script
-
6. Re: <a4j:support> conditional expression ???
user1234 Dec 15, 2009 6:08 AM (in response to ilya_shaikovsky)thanx Iiya..you have already solved the problem correct way -
7. Re: <a4j:support> conditional expression ???
swario Dec 15, 2009 9:05 AM (in response to ilya_shaikovsky)Hi guys...your solution doesn't let me write in the inputText!
I can write in it only if i hold pressed a key few second...why??
-
8. Re: <a4j:support> conditional expression ???
ilya_shaikovsky Dec 15, 2009 9:33 AM (in response to swario)It happens because you used onkeydown.. And I've missed this when correcting the code..
But anyway I thinkk this will looks better
<a4j:jsFunction name="submission"></a4j:jsFunction> <h:inputText value="" id="idinput"> <rich:hotKey key="return" handler="submission()" disableInInput="false"/> </h:inputText>
-
9. Re: <a4j:support> conditional expression ???
swario Dec 16, 2009 4:31 AM (in response to ilya_shaikovsky)ok...i'm not sure have understood your idea! please be more specific
I need to fire a bean method !!!
....with these components (hotkey and jsFunction) it's possible to specify only javascript functions OR beans properties...
-
10. Re: <a4j:support> conditional expression ???
user1234 Dec 17, 2009 12:38 AM (in response to swario)You just have to give your action method in a4j:jsFunction , and can use reRender attribute if you want to reRender any component.
<a4j:jsFunction name="submission" action="#{bean.methodName}"></a4j:jsFunction>
<h:inputText value="" id="idinput">
<rich:hotKey key="return" handler="submission()" disableInInput="false"/>
</h:inputText> -
11. Re: <a4j:support> conditional expression ???
swario Dec 17, 2009 5:55 AM (in response to user1234)Yes! thank you guys!!!
Now it perfectly works!!