|
24 | 24 | import org.ocpsoft.rewrite.annotation.spi.FieldAnnotationHandler; |
25 | 25 | import org.ocpsoft.rewrite.bind.Binding; |
26 | 26 | import org.ocpsoft.rewrite.config.Condition; |
| 27 | +import org.ocpsoft.rewrite.config.ConditionBuilder; |
27 | 28 | import org.ocpsoft.rewrite.config.Or; |
28 | 29 | import org.ocpsoft.rewrite.config.True; |
29 | 30 | import org.ocpsoft.rewrite.config.Visitor; |
@@ -72,12 +73,17 @@ public void process(FieldContext context, org.ocpsoft.rewrite.annotation.Paramet |
72 | 73 | context.getRuleBuilder().accept(visitor); |
73 | 74 | if (!visitor.isFound()) |
74 | 75 | { |
75 | | - // Fall back to the Request parameter map by default |
| 76 | + // fall back to use request parameter map |
| 77 | + Condition requestParameter = RequestParameter.exists("{" + param + "}") |
| 78 | + .where(param).matches(param) |
| 79 | + .bindsTo(Request.parameter(param)); |
| 80 | + ConditionBuilder composite = context.getRuleBuilder().getConditionBuilder().and( |
| 81 | + Or.any(requestParameter, True.create())); |
| 82 | + context.getRuleBuilder().when(composite); |
| 83 | + |
| 84 | + // this visitor will find the condition added above |
76 | 85 | AddBindingVisitor fallback = new AddBindingVisitor(context, chain, param, field); |
77 | | - context.getRuleBuilder() |
78 | | - .getConditionBuilder().and(Or.any( |
79 | | - RequestParameter.exists("{param}").where(param).matches(param) |
80 | | - .bindsTo(Request.parameter(param)), new True())); |
| 86 | + context.getRuleBuilder().accept(fallback); |
81 | 87 |
|
82 | 88 | Assert.assertTrue(fallback.isFound(), |
83 | 89 | "The parameter [" + param + "] bound to Field [" + field.getDeclaringClass().getName() + "." |
|
0 commit comments