I think Brian is planning on issuing an in depth response in a day or two. Thanks for your help!<br><br><div class="gmail_quote">On Thu, Oct 27, 2011 at 10:00, Adrian Gonzalez <span dir="ltr"><<a href="mailto:adr_gonzalez@yahoo.fr">adr_gonzalez@yahoo.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Additionnal thoughts :<br>
<br>
As I understand ViewConfigStore for now, any extension can use ViewConfigStore to store about any metadata (event if it's limited to Annotation for the moment).<br>
So this is great for additionnal features.<br>
<br>
If we go for solution 4, Page/View will be typed and future extensions will be limited.<br>
We can however add a metadatas field in Page/View for extensions to store about anything in a view.<br>
<br>
IMO, solution 4 would make the code easier to understand (more typed) - but breaks a lot of code, and since I'm a newbie here...<br>
<div class="hm"><br>
<br>
________________________________<br>
De : Adrian Gonzalez <<a href="mailto:adr_gonzalez@yahoo.fr">adr_gonzalez@yahoo.fr</a>><br>
À : "<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a>" <<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a>><br>
Envoyé le : Jeudi 27 Octobre 2011 17h44<br>
Objet : [seam-dev] SEAMFACES-147 viewActions<br>
</div><div><div></div><div class="h5"><br>
Hello,<br>
<br>
I'm working a bit on this issue.<br>
<br>
But I'm stuck now and would like to know the better way to continue (sorry to bother once more ;( ).<br>
<br>
For the moment I've :<br>
1. registered all viewActionBindings into the viewConfigStore.<br>
2. more or less replicated SecurityPhaseListener functionnality into a ViewActionPhaseListener.<br>
<br>
But... viewConfigStore can only store Annotations. I need to store AnnotatedMethod (have a link back to the Method I'll need to call).<br>
<br>
I see 4 possible solutions :<br>
<br>
1 - Duplicate ViewConfigStoreImpl to store AnnotatedMethod elements.<br>
Ugly, no ?<br>
2 - Make ViewConfigStore manage all kind of AnnotatedElements with a wrapper interface like<br>
interface AnnotatedElement<T> {<br>
Annotation<T> annotation;<br>
Object value;<br>
}<br>
ViewConfigStore :<br>
public interface ViewConfigStore {<br>
public abstract void addAnnotationData(String viewId, AnnotatedElement annotation);<br>
public abstract AnnotatedElement<T> T getAnnotationData(String viewId, Class<T> type);<br>
public abstract List<AnnotatedElement<T>> getAllAnnotationData(String viewId, Class<T> type);<br>
public abstract List<AnnotatedElement> getAllQualifierData(String viewId, Class<? extends Annotation> qualifier);<br>
public <T extends Annotation> Map<String, Annotation> getAllAnnotationViewMap(Class<T> type);<br>
}<br>
3 - ViewConfigStore could store Annotated elements instead of Annotations<br>
This would make ViewConfigStore usage a little more complicated though.<br>
4 - Have somes typed Page or View objects.<br>
This need really more reflection since we need to know what is a View (security, view actions, ...).<br>
And it's a big impact on current code.<br>
The ViewConfigStore would be sthing like (really incomplete) :<br>
ViewConfigStore :<br>
public Map<String,ViewInfo> getView(String viewId);<br>
public List<View> getViews();<br>
}<br>
with for instance :<br>
class/interface View {<br>
List<Restriction> getRestrictions();<br>
List<ViewAction> getViewActions(); //or event List<Action> getAction(PhaseId)<br>
}<br>
<br>
WDYT ?<br>
<br>
P.S. Sorry for the rather long mail........<br>
<br>
<br>
More details on what I have done for now :<br>
<br>
As noted in the ticket, I can now create a viewAction annotation like this one :<br>
<br>
<br>
@ViewActionBindingType<br>
@Retention(RetentionPolicy.RUNTIME)<br>
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})<br>
public @interface MyViewAction {<br>
MyAppViewConfig.Pages value();<br>
}<br>
<br>
MyAppViewConfig being the sample @ViewConfig annotated class in viewconfig sample.<br>
<br>
I can then use MyViewAction like this :<br>
<br>
<br>
@ViewScoped<br>
@Named<br>
public class PageController implements Serializable {<br>
@MyViewAction(Pages.ITEM)<br>
public void loadEntry() {<br>
System.out.println("loadEntry called");<br>
}<br>
}<br>
<br>
For the moment, my code doesn't call this method (I'll just need to copy Seam Security code for it ;) ).<br>
<br>
<br>
I've also created the following annotation that you can use to annotate your own viewAction annotation :<br>
- @Condition(condition=String) -> not really type safe.....<br>
- @Immediate(immediate=Boolean)<br>
- @OnPostback(onPostback=boolean)<br>
- @Phase(value=PhaseIdType)<br>
<br>
Also, if you need to customise those behaviour per-usage, you can add attributes into your viewAction annotation :<br>
@MyViewAction(Pages.ITEM, immediate=true, condition="#{myBean.eager}")<br>
public void loadEntry()<br>
<br>
_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br>
_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jason Porter<br><a href="http://lightguard-jp.blogspot.com" target="_blank">http://lightguard-jp.blogspot.com</a><br><a href="http://twitter.com/lightguardjp" target="_blank">http://twitter.com/lightguardjp</a><br>
<br>Software Engineer<br>Open Source Advocate<br>Author of Seam Catch - Next Generation Java Exception Handling<br><br>PGP key id: 926CCFF5<br>PGP key available at: <a href="http://keyserver.net" target="_blank">keyserver.net</a>, <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>