Skip to content

Commit 7d2689f

Browse files
committed
Add bindings only to Parameterized instances that support that parameter (first try)
1 parent fbbfaa4 commit 7d2689f

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

‎annotations/src/main/java/org/ocpsoft/prettyfaces/annotation/handlers/ParameterBindingHandler.java‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public void process(FieldContext context, Field field, ParameterBinding annotati
5050

5151
private static class AddBindingVisitor implements Visitor<Condition>
5252
{
53+
54+
private final Logger log = Logger.getLogger(AddBindingVisitor.class);
55+
5356
private final String param;
5457
private final FieldContext context;
5558
private final Field field;
@@ -90,12 +93,28 @@ else if (beforePhase != null && afterPhase == null) {
9093
+ ": You cannot use @" + BeforePhase.class.getSimpleName() + " and @"
9194
+ AfterPhase.class.getSimpleName() + " at the same time.");
9295
}
93-
94-
// add the parameter and the binding
95-
parameterized.where(param).bindsTo(deferredBinding);
9696

97-
// register the binding builder in the field context
98-
context.setBindingBuilder(elBinding);
97+
// the parameter may not exist in the Parameterized instance
98+
try {
99+
100+
// add the parameter and the binding
101+
parameterized.where(param).bindsTo(deferredBinding);
102+
103+
// register the binding builder in the field context
104+
context.setBindingBuilder(elBinding);
105+
106+
if (log.isDebugEnabled()) {
107+
log.debug("Added binding for parameter [{}] to: {}", param, parameterized);
108+
}
109+
110+
}
111+
112+
// TODO: does not work correct. Never thrown?
113+
catch (IllegalArgumentException e) {
114+
if (log.isTraceEnabled()) {
115+
log.trace("Parameter [{}] not found on: {}", param, parameterized);
116+
}
117+
}
99118

100119
}
101120
}

0 commit comments

Comments
 (0)