Skip to content

Commit e482226

Browse files
committed
Added phaseId attribute to @URLAction
1 parent c7dd3c3 commit e482226

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.ocpsoft.prettyfaces.annotation;
2+
3+
public enum PhaseId
4+
{
5+
6+
RESTORE_VIEW(javax.faces.event.PhaseId.RESTORE_VIEW),
7+
APPLY_REQUEST_VALUES(javax.faces.event.PhaseId.APPLY_REQUEST_VALUES),
8+
PROCESS_VALIDATIONS(javax.faces.event.PhaseId.PROCESS_VALIDATIONS),
9+
UPDATE_MODEL_VALUES(javax.faces.event.PhaseId.UPDATE_MODEL_VALUES),
10+
INVOKE_APPLICATION(javax.faces.event.PhaseId.INVOKE_APPLICATION),
11+
RENDER_RESPONSE(javax.faces.event.PhaseId.RENDER_RESPONSE);
12+
13+
private final javax.faces.event.PhaseId phaseId;
14+
15+
private PhaseId(javax.faces.event.PhaseId phaseId)
16+
{
17+
this.phaseId = phaseId;
18+
}
19+
20+
public javax.faces.event.PhaseId getPhaseId()
21+
{
22+
return phaseId;
23+
}
24+
25+
}

‎annotations/src/main/java/org/ocpsoft/prettyfaces/annotation/URLAction.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
@Retention(RetentionPolicy.RUNTIME)
1414
public @interface URLAction
1515
{
16+
17+
PhaseId phaseId() default PhaseId.RESTORE_VIEW;
1618
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import java.lang.reflect.AnnotatedElement;
44
import java.lang.reflect.Method;
55

6-
import javax.faces.event.PhaseId;
7-
86
import org.ocpsoft.prettyfaces.annotation.URLAction;
97
import org.ocpsoft.rewrite.annotation.api.ClassContext;
108
import org.ocpsoft.rewrite.annotation.spi.AnnotationHandler;
@@ -37,7 +35,7 @@ public void process(ClassContext context, AnnotatedElement element, URLAction an
3735

3836
// create Operation for executing this method
3937
Operation invocation = Invoke.binding(El.retrievalMethod(expression));
40-
Operation deferredInvocation = PhaseAction.enqueue(invocation).after(PhaseId.RESTORE_VIEW);
38+
Operation deferredInvocation = PhaseAction.enqueue(invocation).after(annotation.phaseId().getPhaseId());
4139

4240
// append this operation to the rule
4341
Operation composite = context.getRuleBuilder().getOperationBuilder().and(deferredInvocation);

‎annotations/src/test/java/org/ocpsoft/prettyfaces/annotation/basic/BasicMappingBean.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import org.ocpsoft.prettyfaces.annotation.ForwardTo;
77
import org.ocpsoft.prettyfaces.annotation.ParameterBinding;
8+
import org.ocpsoft.prettyfaces.annotation.PhaseId;
89
import org.ocpsoft.prettyfaces.annotation.URLAction;
910
import org.ocpsoft.prettyfaces.annotation.URLPattern;
1011

@@ -20,7 +21,7 @@ public class BasicMappingBean
2021

2122
private boolean actionInvoked = false;
2223

23-
@URLAction
24+
@URLAction(phaseId=PhaseId.RESTORE_VIEW)
2425
public void action()
2526
{
2627
actionInvoked = true;

0 commit comments

Comments
 (0)