Jay Sartoris created MYFACES-4176:
-------------------------------------
Summary: Ajax does not render component outside of form
Key: MYFACES-4176
URL: https://issues.apache.org/jira/browse/MYFACES-4176
Project: MyFaces Core
Issue Type: Bug
Affects Versions: 2.3.0-beta
Reporter: Jay Sartoris
Priority: Minor
Attachments: JSF23AjaxTest.war
There seems to be a bug in the
org.apache.myfaces.component.search.SearchExpressionHandlerImpl class when a
client id is specified in the render attribute that is outside of the form that
the f:ajax component resides.
For example:
{noformat}
<h:body>
<h:form id="form1">
<h:commandButton id="testButton1" value="GetResult"
action="#{testBean.test()}">
<f:ajax listener="#{testBean.ajaxListener}" render="testOutput1"/>
</h:commandButton>
</h:form>
<br/>
<h:outputText id="testOutput1" value="#{testBean.result}"/>
</h:body>
{noformat}
You can see that the commandButton and ajax components are within the form but
the render attribute specified is outside of it.
When the Ajax code is generated for the button, you can see that render section
is pointing to the commandButton id instead of the specified 'testOutput1' id
that is actually specified in the f:ajax render attribute.
JSF 2.3:
{noformat}
onclick="jsf.util.chain(this,
event,'jsf.ajax.request(this,event,{*render:\'form1:testButton1
\'*,\'javax.faces.behavior.event\':\'action\'})'); return false;"
{noformat}
When this same scenario is tested on JSF 2.2, the render section is
correct...pointing to the testOutput1 id.
JSF 2.2:
{noformat}
onclick="jsf.util.chain(document.getElementById('form1:testButton1'),
event,'jsf.ajax.request(\'form1:testButton1\',event,{*render:\'testOutput1
\'*,\'javax.faces.behavior.event\':\'action\'})'); return false;"
{noformat}
This scenario also works on Mojarra JSF 2.3.
I debugged the issue and it seems
org.apache.myfaces.component.search.SearchExpressionHandlerImpl.invokeOnComponent
method, the "expression" variable has the correct value that we want to render
("testOutput1") but it is unable to find this component because it only
searches within the form. My thought is that the code should try to iterate
through the parent.getParent to try to find the id it's looking for. The code
looks as though it's doing that (around line 163). However, in this scenario
the code path never drops in to that block of code. What ends up happening is
the client id of the commandButton is returned. Therefore, the testOutput1
component is not updated when the button is clicked.
I've attached a testcase to easily reproduce the scenario. This could
potentially be a high impact issue since partial request aren't updating
components outside of their immediate parent.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)