Conversation
ViewAction are registered in ViewConfigStore. Limitation due to ViewConfigStore storing only Annotation. I need to store at least AnnotatedMethod otherwise I won't be able to know which method to call if 2 methods have been annotated with exactly the same annotation (same attribute values I think).
@ViewAction and @ViewActionBindingType usage are as per https://issues.jboss.org/browse/SEAMFACES-147 @ViewController usage is like MyFaces CODI's @PageBean (https://cwiki.apache.org/confluence/display/EXTCDI/JSF+Usage#JSFUsage-PageBeans) Sample usage in seam-faces-example-viewconfig application
Those where shortcut annotations duplicating @Before/@after @RenderResponse
And removed usage of @Before/@after and phase annotation with @ViewAction. Attribute usage is more explicit here.
|
Hello, Thought a bit about the bugs and code redundancy part. I had an idea but it would require a bit of refactoring. Here's the idea :
ViewActionHandler will represents all actions executed during the view processing lifecycle. ViewAction will contain :
There will be 3 implementations of ViewActionHandler. One of them will be itself generic - a la Hibernate Validator. First one : SecurityBindingTypeHandlerThis will execute a code similar to the actual SecurityPhaseListener. With this handler there will be a SecurityBindingTypeExtension which will scan all SecurityBindingType annotations and add them to the corresponding ViewConfig#viewActionHandlers. Second one : ViewActionBindingTypeHandlerSame thing but for ViewActionBinding annotations. Third one : ViewActionHandler - a la Hibernate ValidatorFor this one, we need an additional interface : ViewActionHandlerProvider, and an additionnal meta-annotation @ViewAction. public interface ViewActionHandlerProvider<V extends ViewAction> {
List<ViewActionHandler> getActionHandlers();
void initialize(X annotation);
}There will be one viewActionHandlerProvider per annotation (with a ViewAction binding type annotation) appearing on a view enum. Sample usage : creating a @BeginConversation view action. @ViewConfig
public interface MyAppViewConfig {
static enum Pages {
@ViewPattern("/item.xhtml")
@BeginConversation
ITEM
}@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ViewAction(BeginConversationHandler.class)
@Begin @ApplyRequestValues
public @interface BeginConversation {
}public class BeginConversationHandler implements ViewActionHandler<ElViewAction> {
@Inject
private Conversation conversation;
boolean handles(PhaseInstant phaseInstant) {...}
void initialize(ElViewAction annotation) {...}
public Object execute() {
conversation.begin();
return null;
}
}And with a similar logic, we have our ElViewAction (donno how to better name all these interfaces / classes) What's next ?My implementation notes are available here : https://gist.github.com/1356107 If you're interested by this approach I can work on it the next or the following week and make another pull request. |
viewAction functionnality in 3 flavors :
@viewconfig
public interface ApplicationViewConfig {
static enum View1 {
@ViewPattern("/item.xhtml")
@ViewAction("#{bean.doSomething()}")
VIEW_ITEM;
}
}
@viewconfig
public interface ApplicationViewConfig {
static enum View1 {
@ViewPattern("/item.xhtml")
VIEW_ITEM;
}
}
public class ItemAction {
@ViewAction(VIEW_ITEM)
public void loadItem() {
...
}
}
Just annotate your view enum with a @controller pointing to a CDI managed-bean.
The managed bean lifecycle methods will automatically be called during this view lifecycle.
@viewconfig
public interface ApplicationViewConfig {
static enum View1 {
@ViewPattern("/item.xhtml")
@controller(ItemController.class)
VIEW_ITEM;
}
}
public class ItemController {
@before
@RenderResponse
public void loadItem() {
...
}
}
Unit tests and sample application provided.
Functionnality missing in my opinion :
This annotation would be called before a JSF action (whether immediate or not).
Not 100% sure about its usefulness though.
Bugs / code redundancy :