| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.teeda.core.config.faces.assembler.impl; |
| 17 | |
|
| 18 | |
import java.util.Iterator; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.seasar.teeda.core.application.navigation.NavigationCaseContext; |
| 22 | |
import org.seasar.teeda.core.application.navigation.NavigationContext; |
| 23 | |
import org.seasar.teeda.core.application.navigation.NavigationResource; |
| 24 | |
import org.seasar.teeda.core.config.faces.assembler.NavigationRuleAssembler; |
| 25 | |
import org.seasar.teeda.core.config.faces.element.NavigationCaseElement; |
| 26 | |
import org.seasar.teeda.core.config.faces.element.NavigationRuleElement; |
| 27 | |
import org.seasar.teeda.core.util.IteratorUtil; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
public class DefaultNavigationRuleAssembler extends NavigationRuleAssembler { |
| 33 | |
|
| 34 | |
public DefaultNavigationRuleAssembler(List navigationRules) { |
| 35 | 4 | super(navigationRules); |
| 36 | 4 | } |
| 37 | |
|
| 38 | |
protected void setupBeforeAssemble() { |
| 39 | 5 | for (Iterator itr = IteratorUtil.getIterator(getNavigationRules()); itr |
| 40 | 10 | .hasNext();) { |
| 41 | 5 | NavigationRuleElement rule = (NavigationRuleElement) itr.next(); |
| 42 | 5 | isAllSuitableJsfElement(rule.getNavigationCaseElements(), |
| 43 | 1 | NavigationCaseElement.class); |
| 44 | |
} |
| 45 | 5 | } |
| 46 | |
|
| 47 | |
public void assemble() { |
| 48 | 3 | for (Iterator itr = IteratorUtil.getIterator(getNavigationRules()); itr |
| 49 | 6 | .hasNext();) { |
| 50 | 3 | NavigationRuleElement rule = (NavigationRuleElement) itr.next(); |
| 51 | 3 | NavigationContextWrapper wrapper = new NavigationContextWrapper( |
| 52 | |
rule); |
| 53 | 3 | NavigationResource.addNavigationContext(wrapper); |
| 54 | |
} |
| 55 | 3 | } |
| 56 | |
|
| 57 | |
public static class NavigationContextWrapper extends NavigationContext { |
| 58 | |
|
| 59 | 4 | public NavigationContextWrapper(NavigationRuleElement navigationRule) { |
| 60 | 4 | String fromViewId = navigationRule.getFromViewId(); |
| 61 | 4 | if (fromViewId != null) { |
| 62 | 3 | setFromViewId(fromViewId); |
| 63 | |
} |
| 64 | 4 | toNavigationCaseContext(navigationRule); |
| 65 | 4 | } |
| 66 | |
|
| 67 | |
private void toNavigationCaseContext( |
| 68 | |
NavigationRuleElement navigationRule) { |
| 69 | 4 | List navigationCases = navigationRule.getNavigationCaseElements(); |
| 70 | 4 | for (Iterator itr = IteratorUtil.getIterator(navigationCases); itr |
| 71 | 8 | .hasNext();) { |
| 72 | 4 | NavigationCaseElement caseElement = (NavigationCaseElement) itr |
| 73 | |
.next(); |
| 74 | 4 | addNavigationCaseContext(new NavigationCaseContextWrapper( |
| 75 | |
caseElement)); |
| 76 | |
} |
| 77 | 4 | } |
| 78 | |
|
| 79 | |
} |
| 80 | |
|
| 81 | |
public static class NavigationCaseContextWrapper extends |
| 82 | |
NavigationCaseContext { |
| 83 | |
public NavigationCaseContextWrapper(NavigationCaseElement element) { |
| 84 | 5 | super(element.getFromAction(), element.getFromOutcome(), element |
| 85 | |
.getToViewId(), element.isRedirect()); |
| 86 | 5 | } |
| 87 | |
} |
| 88 | |
} |