Skip to content

Commit

Permalink
Merge pull request #809 from volosied/MYFACES-4695-3.0
Browse files Browse the repository at this point in the history
MYFACES-4695: Allow searching for ids with separator character [3.0]
  • Loading branch information
volosied authored Nov 22, 2024
2 parents 7d96849 + 14c04c2 commit 2c7faef
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form id="form1">
<h:outputText id="one" value="1" />
<h:outputText id="two" value="2" />
</h:form>
<h:form id="form2">
<h:commandButton type="submit" id="submit">
<f:ajax render="form1:one" />
</h:commandButton>
</h:form>
</h:body>
</html>

0 comments on commit 2c7faef

Please sign in to comment.