Details
Description
The code below doesn't work as expected. The element with id "one" should be updated. Instead, the submit is rendered when pressed.
<h:body> TEMPLATE <h:form id="cartForm"> CART IS HERE! <h:outputText id="one" value="1" /> <h:outputText id="two" value="2" /> </h:form> <h:form id="shoppingCartForm" name="shoppingCartForm"> <h:commandButton type="submit" value="Update" styleClass="commandExButton" id="updateButton"> <f:ajax execute="@form" render="cartForm:one" /> </h:commandButton> </h:form> </h:body> </f:view>
The generated code looks like:
<input id="shoppingCartForm:updateButton" name="shoppingCartForm:updateButton" type="submit" value="Update" onclick="faces.util.chain(this, event,function(event){myfaces.ab(this,event,'action','@form','shoppingCartForm:updateButton')}); return false;" class="commandExButton">
The ids for the render are the submit button itself: shoppingCartForm:updateButton
Note: Mojarra works as expected (element one is updated) when I tested the same facelet.
Note: 4.1.0-RC3 fails with the following exception (due to MYFACES-4624):
jakarta.servlet.ServletException: Cannot find component for expression "cartForm:one" referenced from "shoppingCartForm:updateButton". at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:239) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1266) at [internal classes] Caused by: jakarta.faces.component.search.ComponentNotFoundException: Cannot find component for expression "cartForm:one" referenced from "shoppingCartForm:updateButton". at org.apache.myfaces.component.search.SearchExpressionHandlerImpl.resolveClientIds(SearchExpressionHandlerImpl.java:179) at [internal classes] at org.apache.myfaces.renderkit.html.util.AjaxScriptBuilder.appendIds(AjaxScriptBuilder.java:278) at org.apache.myfaces.renderkit.html.util.AjaxScriptBuilder.build(AjaxScriptBuilder.java:205)
_____
The solution in my opinion is the let the search in the invokeOnComponent method call continue without regard of the separator character. The parent naming contains would be searched until the id is found (or not).
In other words, remove this line: https://github.com/apache/myfaces/blame/4.1.x/impl/src/main/java/org/apache/myfaces/component/search/SearchExpressionHandlerImpl.java#L538