Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This approach build on top of #64 :
Mechanism similar to Hibernate Validator custom annotations.
Abstract : ViewActionHandler / ViewConfigDescriptor / ViewConfigStore
ViewActionHandler
ViewActionHandler is the main interface. It encapsulate action execution.
order enable to have some viewAction executing before the others (handy for @SecurityBindingType annotations).
ViewConfigDescriptor
Describes a view (@ViewPattern).
It contains a list of ViewActionHandler applying to the view.
ViewConfigStore
This one already existed and is a registry of every ViewConfigDescriptor.
Note : I've added the notion of runtimeViewConfigDescriptor.
Non-runtime ViewConfigDescriptor are regexp based.
runtime are merged regexp ViewConfigDescriptor corresponding to a requested view-id.
Mostly for performance reason (and also for code simplicity).
Now : what is a viewAction ?
As in the previous post, 4 flavours : El based, Controller and ActionBindingType (meta-annotation), and SecurityBindingType (it's now just one more viewAction type).
I've added another layer El based annotation is built on the same logic as Hibernate Validator, so you could easily create your own view action annotations.
ElViewAction
Just executes an El method.
Sample usage :
ElViewAction accepts phase and before attributes. By default, ElViewAction is executed before RenderResponse (as the other page actions).
Controller
IMO, the best approach.
Sample usage :
And you annotated any controller method with @Before/After and any annotation from org.jboss.seam.faces.event.qualifier package :
Controller methods accept CDI injected parameters.
Meta-annotation ActionBindingType
You :
Sample :
Develop you own view action
As said earlier, I've used the same approach as Hibernate Validator, so you can create whatever annotation you want.
You'll just need to create the view action annotation (with meta-annotation @ViewAction) and a ViewActionHandlerProvider for the logic).
For instance :
And :