[
https://issues.apache.org/jira/browse/MYFACES-4176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jay Sartoris reopened MYFACES-4176:
-----------------------------------
I am reopening this issue.
I pulled in the changes and ran some tests. I see a regression in one test.
If a page has an outputLabel with the "for" attribute set to a component that
does not match the id specified then a NPE is thrown.
Here is some sample text:
{code:java}
<f:view>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="MessageLabel" value="Message"></h:outputLabel>
<h:inputText value="#{jsfDriver.message}"></h:inputText>
</h:panelGrid>
</h:form>
</f:view>
{code}
The error I get is:
{noformat}
Caused by: javax.faces.component.search.ComponentNotFoundException: Cannot find
component for expression "MessageLabel" referenced from
"j_id_jsp_2075633134_1:j_id_jsp_2075633134_3".
at
org.apache.myfaces.component.search.SearchExpressionHandlerImpl.resolveClientId(SearchExpressionHandlerImpl.java:104)
at
org.apache.myfaces.renderkit.html.HtmlLabelRenderer.getClientId(HtmlLabelRenderer.java:253)
at
org.apache.myfaces.renderkit.html.HtmlLabelRenderer.encodeBegin(HtmlLabelRenderer.java:172)
at
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:597)
at
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:527)
at
org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:376)
at
org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:189)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:675)
at
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:555)
at
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:551)
at
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:551)
at
org.apache.myfaces.shared.view.JspViewDeclarationLanguageBase.actuallyRenderView(JspViewDeclarationLanguageBase.java:351)
at
org.apache.myfaces.shared.view.JspViewDeclarationLanguageBase.renderView(JspViewDeclarationLanguageBase.java:200)
at
org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:315)
at
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:117)
at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:266)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:206)
... 29 more
{noformat}
> Search expression fails to resolve 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
> Assignee: Thomas Andraschko
> Priority: Minor
> Fix For: 2.3.0
>
> 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.
> {panel:title=JSF 2.3}
> onclick="jsf.util.chain(this,
> event,'jsf.ajax.request(this,event,{*render:\'form1:testButton1
> \'*,\'javax.faces.behavior.event\':\'action\'})'); return false;"
> {panel}
> When this same scenario is tested on JSF 2.2, the render section is
> correct...pointing to the testOutput1 id.
> {panel:title=JSF 2.2}
> onclick="jsf.util.chain(document.getElementById('form1:testButton1'),
> event,'jsf.ajax.request(\'form1:testButton1\',event,{*render:\'testOutput1
> \'*,\'javax.faces.behavior.event\':\'action\'})'); return false;"
> {panel}
> 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)