From fcfbb22fd404454a5551a9958d9eaa4df21d221c Mon Sep 17 00:00:00 2001 From: Volodymyr Siedlecki Date: Wed, 20 Nov 2024 16:25:45 -0500 Subject: [PATCH 1/2] MYFACES-4695: Allow searching for ids with separator character Update per Thomas' comment --- .../myfaces/component/search/SearchExpressionHandlerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/impl/src/main/java/org/apache/myfaces/component/search/SearchExpressionHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/component/search/SearchExpressionHandlerImpl.java index c5dbddbf9..3aea7b8f8 100644 --- a/impl/src/main/java/org/apache/myfaces/component/search/SearchExpressionHandlerImpl.java +++ b/impl/src/main/java/org/apache/myfaces/component/search/SearchExpressionHandlerImpl.java @@ -535,8 +535,8 @@ public void invokeContextCallback(FacesContext context, UIComponent target) // At this point if the algorithm hasn't returned and the topExpression does not have any separator char // we need to do the search backward using findComponent. if (target == null - && searchExpressionContext.getSource() == previous - && (topExpression.indexOf(separatorChar) == -1) ) + && searchExpressionContext.getSource() == previous + && (topExpression.indexOf(separatorChar + "@") == -1) ) // updated for MYFACES-4695 { UIComponent baseNC = previous.getNamingContainer(); if (baseNC != null && baseNC.getParent() != null) From 957f574a68e15bda4c2a52ead48d87329003f5fd Mon Sep 17 00:00:00 2001 From: Volodymyr Siedlecki Date: Wed, 20 Nov 2024 18:43:40 -0500 Subject: [PATCH 2/2] Add test for MYFACES-4695 --- .../search/SearchExpressionImplTest.java | 18 +++++++++ .../myfaces/component/search/search2.xhtml | 38 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 impl/src/test/resources/org/apache/myfaces/component/search/search2.xhtml diff --git a/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java b/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java index abdcc6193..7fedce82f 100644 --- a/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java +++ b/impl/src/test/java/org/apache/myfaces/component/search/SearchExpressionImplTest.java @@ -410,6 +410,24 @@ public void testIsPassthroughExpression() throws Exception Assert.assertFalse(handler.isPassthroughExpression(searchContextWithAjaxResolve, "@form:@child(0)")); } + @Test + public void testMyFaces4695() throws Exception + { + startViewRequest("/search2.xhtml"); + processLifecycleExecute(); + executeBeforeRender(); + executeBuildViewCycle(); + + SearchExpressionContext searchContext = + SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot().findComponent("form2:submit")); + + SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); + + Assertions.assertEquals("form1:one", handler.resolveClientId(searchContext, "form1:one")); + + processRemainingPhases(); + } + /* @Test public void testCompositeComponentExpression() throws Exception diff --git a/impl/src/test/resources/org/apache/myfaces/component/search/search2.xhtml b/impl/src/test/resources/org/apache/myfaces/component/search/search2.xhtml new file mode 100644 index 000000000..187be74d0 --- /dev/null +++ b/impl/src/test/resources/org/apache/myfaces/component/search/search2.xhtml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + +