Questions about a4j:support
romaintaz Oct 17, 2007 8:46 AMHi,
I am using RichFaces 3.1.2.
I have two questions about the component <a4j:support>:
1. Let's consider the following code:
<h:inputText value="#{myBean.inputValue}"> <a4j:support event="onchange" action="#{myBean.doChangeResult}" reRender="..."/> </h:inputText>
This code works correctly and generate the following HTML code:
<input type="text" name="myForm:j_id53" onchange="A4J.AJAX.Submit('_viewRoot','myForm',event,{'parameters':{'myForm:j_id54':'myForm:j_id54'} ,'actionUrl':'/.../todolist.jsf'} )"/>
Good. Now, I set an onchange attribute to my inputText:
<h:inputText value="#{myBean.inputValue}" onchange="alert('test');"> <a4j:support event="onchange" action="#{myBean.doChangeResult}" reRender="..."/> </h:inputText>
The generated HTML code is then:
<input type="text" name="myForm:j_id53" onchange="alert('test');" />
Why the a4j:status does not append its Javascript call to the existing onchange value?
In fact, I expected to have something like that:
<input type="text" name="myForm:j_id53" onchange="alert('test');A4J.AJAX.Submit('_viewRoot','myForm',event,{'parameters':{'myForm:j_id54':'myForm:j_id54'} ,'actionUrl':'/.../todolist.jsf'} )"/>
2. I have developed a component (called <my:validation/> that modifies the onchange and onblur attribute of its parent.
When I write this code:
<h:inputText value="#{myBean.inputValue}"> <a4j:support event="onchange" action="#{myBean.doChangeResult}" reRender="..."/> <my:validation/> </h:inputText>
it creates the following HTML code:
<input type="text" name="myForm:j_id53" onblur="return checkRequired(this, 'This field is required.');" onchange="hideAlarm(this);A4J.AJAX.Submit('_viewRoot',null,event,{'parameters':{'j_id54':'j_id54'} ,'actionUrl':'/.../mytodolist.jsf'} )"/>
What is strange is that the a4j:support creates the correct Javascript call, except that it does not found the form that contains my inputText. Then, the Ajax call is sent, but with errors, a4j:log shows me that:
debug[14:34:28,183]: NEW AJAX REQUEST !!! with form :null
Why does the <a4j:support> does not find the form?
For your information, my component modifies its parent's Javascript attribute when the method setParent (of my component) is called.