| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.teeda.core.util; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.Iterator; |
| 20 | |
import java.util.List; |
| 21 | |
|
| 22 | |
import javax.faces.component.NamingContainer; |
| 23 | |
import javax.faces.component.UIComponent; |
| 24 | |
import javax.faces.context.FacesContext; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
public class StateManagerUtil { |
| 30 | |
|
| 31 | 0 | private StateManagerUtil() { |
| 32 | 0 | } |
| 33 | |
|
| 34 | |
public static boolean isSavingStateInClient(FacesContext context) { |
| 35 | 9 | return FacesContextUtil.getStateManager(context).isSavingStateInClient( |
| 36 | |
context); |
| 37 | |
} |
| 38 | |
|
| 39 | |
public static void assertComponentNoDuplicateId(UIComponent component) { |
| 40 | 4 | assertComponentNoDuplicateIdInternal(component, new ArrayList()); |
| 41 | 1 | } |
| 42 | |
|
| 43 | |
private static void assertComponentNoDuplicateIdInternal( |
| 44 | |
UIComponent component, List idList) { |
| 45 | 9 | String id = component.getId(); |
| 46 | 9 | if (id != null && idList.contains(id)) { |
| 47 | 2 | throw new IllegalStateException("Component id:" + id |
| 48 | |
+ " has same id in view tree."); |
| 49 | |
} |
| 50 | 7 | idList.add(id); |
| 51 | 7 | for (Iterator itr = component.getFacetsAndChildren(); itr.hasNext();) { |
| 52 | 6 | UIComponent child = (UIComponent) itr.next(); |
| 53 | 6 | if (component instanceof NamingContainer) { |
| 54 | 1 | assertComponentNoDuplicateId(child); |
| 55 | |
} else { |
| 56 | 5 | assertComponentNoDuplicateIdInternal(child, idList); |
| 57 | |
} |
| 58 | |
} |
| 59 | 3 | } |
| 60 | |
|
| 61 | |
} |