<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Thanks for the update</div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">I'm enjoying my weekend - no developement - so no need to hurry ;)<br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">Also, I was wondering if it wouldn't be nice to add some Page or Controller notion to viewActions (similar to CODI PageBean notion : <a href="https://cwiki.apache.org/EXTCDI/jsf-usage.html#JSFUsage-PageBeans">https://cwiki.apache.org/EXTCDI/jsf-usage.html#JSFUsage-PageBeans</a>).</div><div style="font-family: arial, helvetica, sans-serif;
font-size: 10pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; ">The end used would be able to choose between 3 possible use case :<br></div><div><div><span class="Apple-style-span" style="font-size: 14px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 14px;">1. Untyped approach (not so CDI like - but dead simple)</span></div><div><span class="Apple-style-span" style="font-size: 14px;">@ViewConfig</span></div><div><span class="Apple-style-span" style="font-size: 14px;">public interface </span><span class="Apple-style-span" style="font-size: 15px; ">ApplicationViewConfig </span><span class="Apple-style-span" style="font-size: 14px;">{</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> static enum View1 {</span></div><div><span class="Apple-style-span" style="font-size: 14px;">
@ViewPattern("/item.xhtml")</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> @ViewAction("#{bean.doSomething()}")</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> VIEW_ITEM;</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> }</span></div><div><span class="Apple-style-span" style="font-size: 14px;">}</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 14px;">2. Typed</span></div><div><span class="Apple-style-span" style="font-size: 14px;">@ViewConfig</span></div><div><span class="Apple-style-span" style="font-size: 14px;">public interface ApplicationViewConfig {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> static enum View1 {</span></div><div><span class="Apple-style-span"
style="font-size: 14px;"> @ViewPattern("/item.xhtml")</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> VIEW_ITEM;</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> }</span></div><div><span class="Apple-style-span" style="font-size: 14px;">}</span></div><div><span class="Apple-style-span" style="font-size: 14px;">public class ItemAction {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>@ViewAction(VIEW_ITEM)</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>public void loadItem() {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span> ...</span></div><div><span
class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>}</span></div><div><span class="Apple-style-span" style="font-size: 14px;">}</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><br></span></div><div><span class="Apple-style-span" style="font-size: 14px;">3. Page Controller</span></div><div><span class="Apple-style-span" style="font-size: 14px;">@ViewConfig</span></div><div><span class="Apple-style-span" style="font-size: 14px;">public interface ApplicationViewConfig {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> static enum View1 {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> @ViewPattern("/item.xhtml")</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> @Controller(ItemController.class)</span></div><div><span
class="Apple-style-span" style="font-size: 14px;"> VIEW_ITEM;</span></div><div><span class="Apple-style-span" style="font-size: 14px;"> }</span></div><div><span class="Apple-style-span" style="font-size: 14px;">}</span></div><div><span class="Apple-style-span" style="font-size: 14px;">public class ItemController {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>@BeforePhase(RENDER_RESPONSE)</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>public void loadItem() {</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span> ...</span></div><div><span class="Apple-style-span" style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">
        </span>}</span></div><div><span class="Apple-style-span" style="font-size: 14px;">}</span></div></div><div style="font-family: arial, helvetica, sans-serif; font-size: 10pt; "><br></div><div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">De :</span></b> Jason Porter <lightguard.jp@gmail.com><br><b><span style="font-weight: bold;">À :</span></b> Adrian Gonzalez <adr_gonzalez@yahoo.fr><br><b><span style="font-weight: bold;">Cc :</span></b> "seam-dev@lists.jboss.org" <seam-dev@lists.jboss.org><br><b><span style="font-weight: bold;">Envoyé le :</span></b> Samedi 29 Octobre 2011 4h02<br><b><span style="font-weight: bold;">Objet :</span></b> Re: [seam-dev] Re : SEAMFACES-147 viewActions<br></font><br><div id="yiv2019407603">I think
Brian is planning on issuing an in depth response in a day or two. Thanks for your help!<br><br><div class="yiv2019407603gmail_quote">On Thu, Oct 27, 2011 at 10:00, Adrian Gonzalez <span dir="ltr"><<a rel="nofollow" ymailto="mailto:adr_gonzalez@yahoo.fr" target="_blank" href="mailto:adr_gonzalez@yahoo.fr">adr_gonzalez@yahoo.fr</a>></span> wrote:<br>
<blockquote class="yiv2019407603gmail_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="yiv2019407603hm"><br>
<br>
________________________________<br>
De : Adrian Gonzalez <<a rel="nofollow" ymailto="mailto:adr_gonzalez@yahoo.fr" target="_blank" href="mailto:adr_gonzalez@yahoo.fr">adr_gonzalez@yahoo.fr</a>><br>
À : "<a rel="nofollow" ymailto="mailto:seam-dev@lists.jboss.org" target="_blank" href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a>" <<a rel="nofollow" ymailto="mailto:seam-dev@lists.jboss.org" target="_blank" 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 class="yiv2019407603h5"><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 rel="nofollow" ymailto="mailto:seam-dev@lists.jboss.org" target="_blank" href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/seam-dev">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br>
_______________________________________________<br>
seam-dev mailing list<br>
<a rel="nofollow" ymailto="mailto:seam-dev@lists.jboss.org" target="_blank" href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/seam-dev">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 rel="nofollow" target="_blank" href="http://lightguard-jp.blogspot.com">http://lightguard-jp.blogspot.com</a><br><a rel="nofollow" target="_blank" href="http://twitter.com/lightguardjp">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 rel="nofollow" target="_blank" href="http://keyserver.net">keyserver.net</a>, <a rel="nofollow" target="_blank" href="http://pgp.mit.edu">pgp.mit.edu</a><br>
</div><br><br></div></div></div></body></html>