[
https://issues.jboss.org/browse/SEAMFACES-147?page=com.atlassian.jira.plu...
]
Dan Allen commented on SEAMFACES-147:
-------------------------------------
The easy way out is to use EL to bind actions to view config enums:
{code}
@ViewConfig
public interface ApplicationViewConfig {
static enum Views {
@ViewAction("#{bean.loadItem}")
VIEW_ITEM
}
}
{code}
However, that requires all sorts of named beans and it's just pretty off base from
what CDI is all about.
A far better solution is to use binding annotations, just like qualifiers and interceptor
bindings from CDI and security bindings from Seam Faces.
To make this as strongly typed as possible, we want to allow the developer to refer to the
view config in the value attribute of the binding annotation. Thus, they first define the
binding:
{code}
@ViewActionBindingType
@Retention(RUNTIME)
@Target(ElementType.METHOD)
public @interface ViewAction {
Views[] value();
}
{code}
Then, they annotate the method they want to call.
{code}
@ViewAction(VIEW_ITEM)
public void loadItem() {
...
}
{code}
The best part is, that method can have injected arguments. The injected argument could be
a bean populated by a PrettyFaces mapping, viewParam or a converted request parameter
(provided by Seam Servlet):
{code}
@ViewAction(VIEW_ITEM)
public void loadItem(@Selected Item item) {
...
}
{code}
or
{code}
@ViewAction(VIEW_ITEM)
public void loadItem(@RequestParam("id") Long id) {
...
}
{code}
If you needed the action for view and edit, you just do:
{code}
@ViewAction({VIEW_ITEM, EDIT_ITEM})
public void loadItem(@RequestParam("id") Long id) {
...
}
{code}
We should also allow view actions to be nested:
The only part that sucks is that the user has to create the @ViewAction annotation so that
it's linked to the view config enum (stupid Java). We could recommend adding this
annotation as part of the view config class file (or even have tooling generate it).
Page action in ViewConfig
-------------------------
Key: SEAMFACES-147
URL:
https://issues.jboss.org/browse/SEAMFACES-147
Project: Seam Faces
Issue Type: Feature Request
Reporter: Dupont Dupont
Be able to configure a page action with ViewConfig.
For instance :
{code:java}
@ViewConfig
public interface Pages {
static enum Pages1 {
@ViewPattern("/*")
@ViewAction("#{bean.doSomething()}")
ALL;
}
}
{code}
Prettyfaces can be a source of inspiration since it has this capability, and the added
bonus of specifying which phase you want this to occur.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira