Commit b536dfe6d0693103bd4617eb11bce9fc1f0bc711

Authored by bernard
1 parent 9b1f71c8

Fixed UIFocus to deal with duplicating IDs in different forms.

... ... @@ -64,7 +64,7 @@
64 64 </properties>
65 65 <distributionManagement>
66 66 <snapshotRepository>
67   - <id>lemur</id>
  67 + <id>bernard.labno.pl</id>
68 68 <name>MyCo Internal Repository</name>
69 69 <url>http://bernard.labno.pl/artifactory/libs-snapshot-local</url>
70 70 </snapshotRepository>
... ...
... ... @@ -19,19 +19,19 @@ public abstract class UIFocus extends UIComponentBase {
19 19
20 20 public static final String FOCUS_MODIFIER_FACET_NAME = "focusModifier";
21 21
22   - public Integer getDefaultPriority() {
  22 + public Integer getDefaultPriority(FacesContext context) {
23 23 UIComponent parentForm = getParent();
24 24 while (parentForm != null && !(parentForm instanceof UIForm)) {
25 25 parentForm = parentForm.getParent();
26 26 }
27 27 if (parentForm != null) {
28   - return getUIInputChildrenCount(parentForm, getTargetComponentId());
  28 + return getUIInputChildrenCount(parentForm, getTargetComponentId(context));
29 29 } else {
30 30 return Integer.MAX_VALUE;
31 31 }
32 32 }
33 33
34   - public String getTargetComponentId() {
  34 + public String getTargetComponentId(FacesContext context) {
35 35 String aFor = getFor();
36 36
37 37 if (aFor != null && !"".equals(aFor)) {
... ... @@ -44,9 +44,9 @@ public abstract class UIFocus extends UIComponentBase {
44 44 allowedClientIds.add(clientIdsWithMessages.next());
45 45 }
46 46 UIComponent component = getFirstInput(getParentForm(this), allowedClientIds);
47   - return component == null ? null : component.getId();
  47 + return component == null ? null : component.getClientId(context);
48 48 } else {
49   - return getParent().getId();
  49 + return getParent().getClientId(context);
50 50 }
51 51 }
52 52 }
... ...
... ... @@ -69,11 +69,11 @@ public class HtmlFocusRenderer extends HeaderResourcesRendererBase {
69 69 checkValidity(clientId, uiFocus.getName(), uiFocus.getTiming());
70 70 Integer priority = uiFocus.getPriority();
71 71 if (priority == null) {
72   - priority = uiFocus.getDefaultPriority();
  72 + priority = uiFocus.getDefaultPriority(context);
73 73 }
74 74 String targetClientId = uiFocus.getTargetClientId();
75 75 if (targetClientId == null || "".equals(targetClientId)) {
76   - String targetComponentId = uiFocus.getTargetComponentId();
  76 + String targetComponentId = uiFocus.getTargetComponentId(context);
77 77 String suffix = uiFocus.getSuffix();
78 78 if (targetComponentId == null || "".equals(targetComponentId)) {
79 79 return;
... ...
Please register or login to post a comment