Author: nbelaevski
Date: 2010-05-04 10:28:45 -0400 (Tue, 04 May 2010)
New Revision: 16882
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
root/framework/trunk/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java
Log:
https://jira.jboss.org/jira/browse/RF-7856 - NPE fixed
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-05-04
12:50:17 UTC (rev 16881)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-05-04
14:28:45 UTC (rev 16882)
@@ -93,20 +93,17 @@
private static UIComponent findRoot(UIComponent component) {
UIComponent c = component;
- while (c != null && !isRoot(c)) {
+ while (!isRoot(c)) {
c = c.getParent();
}
return c;
}
- private static UIComponent findContainerOrRoot(UIComponent component) {
+ private static UIComponent findContainer(UIComponent component) {
UIComponent c = component;
- while (c != null && c.getParent() != null) {
- if (c instanceof NamingContainer) {
- break;
- }
+ while (c != null && !(c instanceof NamingContainer)) {
c = c.getParent();
}
@@ -135,7 +132,7 @@
private String computeClientId(FacesContext context,
UIComponent topMatchComponent, String id) {
- UIComponent container = findContainerOrRoot(topMatchComponent.getParent());
+ UIComponent container = findContainer(topMatchComponent.getParent());
String containerClientId = null;
@@ -441,14 +438,14 @@
resolveId(rootNode, c, c);
if (hasUnresolvedIds()) {
- boolean resolutionResult = false;
-
- while (!isRoot(c) && !resolutionResult) {
- c = findContainerOrRoot(c);
-
- resolutionResult = findComponentsInContainer(c, rootNode, true);
-
- c = c.getParent();
+ UIComponent container = findContainer(c);
+ while (container != null && !isRoot(container)) {
+ boolean resolutionResult = findComponentsInContainer(container, rootNode,
true);
+ if (resolutionResult) {
+ break;
+ }
+
+ container = findContainer(container.getParent());
}
}
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java 2010-05-04
12:50:17 UTC (rev 16881)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java 2010-05-04
14:28:45 UTC (rev 16882)
@@ -182,6 +182,19 @@
}
@Test
+ public void testFindNonExistentWithContext() throws Exception {
+ ComponentIdResolver resolver = createComponentIdResolver();
+ resolver.addId("nonExistentId");
+ resolver.addId("xForm:nonExistentId");
+ resolver.addId(":ySubview:nonExistentId");
+
+ resolver.resolve(evaluateComponentExpression("#{testBean.table}"));
+
+ Set<String> resolvedIds = resolver.getResolvedIds();
+ assertEquals(asSet("nonExistentId", "xForm:nonExistentId",
"ySubview:nonExistentId"), resolvedIds);
+ }
+
+ @Test
public void testFindViaMetadataResolverInContext() throws Exception {
ComponentIdResolver resolver = createComponentIdResolver();
resolver.addId("@region");