Skip to content

Commit 14afe49

Browse files
committed
First try to fix @parameter to support query parameters
1 parent a8a597a commit 14afe49

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/handler/ParameterHandler.java‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.ocpsoft.rewrite.annotation.spi.FieldAnnotationHandler;
2525
import org.ocpsoft.rewrite.bind.Binding;
2626
import org.ocpsoft.rewrite.config.Condition;
27+
import org.ocpsoft.rewrite.config.ConditionBuilder;
2728
import org.ocpsoft.rewrite.config.Or;
2829
import org.ocpsoft.rewrite.config.True;
2930
import org.ocpsoft.rewrite.config.Visitor;
@@ -72,12 +73,17 @@ public void process(FieldContext context, org.ocpsoft.rewrite.annotation.Paramet
7273
context.getRuleBuilder().accept(visitor);
7374
if (!visitor.isFound())
7475
{
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
7685
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);
8187

8288
Assert.assertTrue(fallback.isFound(),
8389
"The parameter [" + param + "] bound to Field [" + field.getDeclaringClass().getName() + "."

0 commit comments

Comments
 (0)