From b536dfe6d0693103bd4617eb11bce9fc1f0bc711 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Wed, 16 Mar 2011 15:17:10 +0000 Subject: [PATCH] Fixed UIFocus to deal with duplicating IDs in different forms. --- pom.xml | 2 +- src/main/java/org/richfaces/component/UIFocus.java | 10 +++++----- src/main/java/org/richfaces/renderkit/html/HtmlFocusRenderer.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 3f67205..7fa0b9a 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ - lemur + bernard.labno.pl MyCo Internal Repository http://bernard.labno.pl/artifactory/libs-snapshot-local diff --git a/src/main/java/org/richfaces/component/UIFocus.java b/src/main/java/org/richfaces/component/UIFocus.java index 4387e7b..ca2922c 100644 --- a/src/main/java/org/richfaces/component/UIFocus.java +++ b/src/main/java/org/richfaces/component/UIFocus.java @@ -19,19 +19,19 @@ public abstract class UIFocus extends UIComponentBase { public static final String FOCUS_MODIFIER_FACET_NAME = "focusModifier"; - public Integer getDefaultPriority() { + public Integer getDefaultPriority(FacesContext context) { UIComponent parentForm = getParent(); while (parentForm != null && !(parentForm instanceof UIForm)) { parentForm = parentForm.getParent(); } if (parentForm != null) { - return getUIInputChildrenCount(parentForm, getTargetComponentId()); + return getUIInputChildrenCount(parentForm, getTargetComponentId(context)); } else { return Integer.MAX_VALUE; } } - public String getTargetComponentId() { + public String getTargetComponentId(FacesContext context) { String aFor = getFor(); if (aFor != null && !"".equals(aFor)) { @@ -44,9 +44,9 @@ public abstract class UIFocus extends UIComponentBase { allowedClientIds.add(clientIdsWithMessages.next()); } UIComponent component = getFirstInput(getParentForm(this), allowedClientIds); - return component == null ? null : component.getId(); + return component == null ? null : component.getClientId(context); } else { - return getParent().getId(); + return getParent().getClientId(context); } } } diff --git a/src/main/java/org/richfaces/renderkit/html/HtmlFocusRenderer.java b/src/main/java/org/richfaces/renderkit/html/HtmlFocusRenderer.java index 2e61367..e76078d 100644 --- a/src/main/java/org/richfaces/renderkit/html/HtmlFocusRenderer.java +++ b/src/main/java/org/richfaces/renderkit/html/HtmlFocusRenderer.java @@ -69,11 +69,11 @@ public class HtmlFocusRenderer extends HeaderResourcesRendererBase { checkValidity(clientId, uiFocus.getName(), uiFocus.getTiming()); Integer priority = uiFocus.getPriority(); if (priority == null) { - priority = uiFocus.getDefaultPriority(); + priority = uiFocus.getDefaultPriority(context); } String targetClientId = uiFocus.getTargetClientId(); if (targetClientId == null || "".equals(targetClientId)) { - String targetComponentId = uiFocus.getTargetComponentId(); + String targetComponentId = uiFocus.getTargetComponentId(context); String suffix = uiFocus.getSuffix(); if (targetComponentId == null || "".equals(targetComponentId)) { return; -- libgit2 0.24.0