|
23 | 23 | import org.ocpsoft.rewrite.annotation.api.HandlerChain; |
24 | 24 | import org.ocpsoft.rewrite.annotation.spi.FieldAnnotationHandler; |
25 | 25 | import org.ocpsoft.rewrite.bind.Binding; |
| 26 | +import org.ocpsoft.rewrite.config.Condition; |
| 27 | +import org.ocpsoft.rewrite.config.ConditionBuilder; |
| 28 | +import org.ocpsoft.rewrite.config.Or; |
| 29 | +import org.ocpsoft.rewrite.config.True; |
26 | 30 | import org.ocpsoft.rewrite.el.El; |
27 | 31 | import org.ocpsoft.rewrite.param.ParameterBuilder; |
| 32 | +import org.ocpsoft.rewrite.servlet.config.RequestParameter; |
28 | 33 |
|
29 | 34 | public class ParameterHandler extends FieldAnnotationHandler<org.ocpsoft.rewrite.annotation.Parameter> |
30 | 35 | { |
@@ -78,47 +83,15 @@ public void process(FieldContext context, org.ocpsoft.rewrite.annotation.Paramet |
78 | 83 | Assert.notNull(enrichedBinding, "BindingBuilder was removed from the context"); |
79 | 84 | parameterBuilder.bindsTo(enrichedBinding); |
80 | 85 |
|
81 | | - // |
82 | | - // |
83 | | - // // add bindings to conditions by walking over the condition tree |
84 | | - // AddBindingVisitor visitor = new AddBindingVisitor(context, chain, param, field); |
85 | | - // context.getRuleBuilder().accept(visitor); |
86 | | - // if (!visitor.isFound()) |
87 | | - // { |
88 | | - // |
89 | | - // /* |
90 | | - // * Creates a condition that matches the query parameter we are looking for. |
91 | | - // * It also provides access to a parameter which is named like the parameter that |
92 | | - // * the AddBindingVisitor is expecting. |
93 | | - // */ |
94 | | - // |
95 | | - // // FIXME Commented out until this can be resolved via other means |
96 | | - // Condition requestParameter = RequestParameter.matches("{name}", "{" + param + "}"); |
97 | | - // // .where("name").matches(param); |
98 | | - // // FIXME End compilation comment-out |
99 | | - // |
100 | | - // /* |
101 | | - // * Add the query parameter condition to the condition tree. We must make sure that |
102 | | - // * the condition is evaluated even if the existing part of the tree evaluates to true. |
103 | | - // */ |
104 | | - // ConditionBuilder composite = context.getRuleBuilder().getConditionBuilder().and( |
105 | | - // Or.any(requestParameter, True.create())); |
106 | | - // context.getRuleBuilder().when(composite); |
107 | | - // |
108 | | - // /* |
109 | | - // * This new visitor will definitely find the expected parameter and add the binding. |
110 | | - // */ |
111 | | - // AddBindingVisitor fallback = new AddBindingVisitor(context, chain, param, field); |
112 | | - // context.getRuleBuilder().accept(fallback); |
113 | | - // |
114 | | - // Assert.assertTrue(fallback.isFound(), |
115 | | - // "The parameter [" + param + "] bound to Field [" + field.getDeclaringClass().getName() + "." |
116 | | - // + field.getName() + "] was not found in any condition."); |
117 | | - // |
118 | | - // } |
119 | | - // |
120 | | - // // continue |
121 | | - // chain.proceed(); |
| 86 | + /* |
| 87 | + * Add the query parameter condition to the condition tree that will capture a |
| 88 | + * corresponding query parameter. We must make sure that |
| 89 | + * the condition is evaluated even if the existing part of the tree evaluates to true. |
| 90 | + */ |
| 91 | + Condition requestParameter = RequestParameter.matches("{name}", "{" + param + "}"); |
| 92 | + ConditionBuilder composite = context.getRuleBuilder().getConditionBuilder().and( |
| 93 | + Or.any(requestParameter, True.create())); |
| 94 | + context.getRuleBuilder().when(composite); |
122 | 95 |
|
123 | 96 | } |
124 | 97 |
|
|
0 commit comments