[seam-dev] Re : SEAMFACES-147 viewActions

Jason Porter lightguard.jp at gmail.com
Fri Oct 28 22:02:45 EDT 2011


I think Brian is planning on issuing an in depth response in a day or two.
Thanks for your help!

On Thu, Oct 27, 2011 at 10:00, Adrian Gonzalez <adr_gonzalez at yahoo.fr>wrote:

> Additionnal thoughts :
>
> 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).
> So this is great for additionnal features.
>
> If we go for solution 4, Page/View will be typed and future extensions will
> be limited.
> We can however add a metadatas field in Page/View for extensions to store
> about anything in a view.
>
> 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...
>
>
> ________________________________
> De : Adrian Gonzalez <adr_gonzalez at yahoo.fr>
> À : "seam-dev at lists.jboss.org" <seam-dev at lists.jboss.org>
> Envoyé le : Jeudi 27 Octobre 2011 17h44
> Objet : [seam-dev] SEAMFACES-147 viewActions
>
> Hello,
>
> I'm working a bit on this issue.
>
> But I'm stuck now and would like to know the better way to continue (sorry
> to bother once more ;( ).
>
> For the moment I've :
> 1. registered all viewActionBindings into the viewConfigStore.
> 2. more or less replicated SecurityPhaseListener functionnality into
> a ViewActionPhaseListener.
>
> But... viewConfigStore can only store Annotations. I need to store
> AnnotatedMethod (have a link back to the Method I'll need to call).
>
> I see 4 possible solutions :
>
>  1 - Duplicate ViewConfigStoreImpl to store AnnotatedMethod elements.
>  Ugly, no ?
>  2 - Make ViewConfigStore manage all kind of AnnotatedElements with a
> wrapper interface like
> interface AnnotatedElement<T> {
> Annotation<T> annotation;
> Object value;
> }
> ViewConfigStore :
> public interface ViewConfigStore {
> public abstract void addAnnotationData(String viewId, AnnotatedElement
> annotation);
> public abstract AnnotatedElement<T> T getAnnotationData(String viewId,
> Class<T> type);
> public abstract List<AnnotatedElement<T>> getAllAnnotationData(String
> viewId, Class<T> type);
> public abstract List<AnnotatedElement> getAllQualifierData(String viewId,
> Class<? extends Annotation> qualifier);
> public <T extends Annotation> Map<String, Annotation>
> getAllAnnotationViewMap(Class<T> type);
> }
> 3 - ViewConfigStore could store Annotated elements instead of Annotations
>  This would make ViewConfigStore usage a little more complicated though.
> 4 - Have somes typed Page or View objects.
>  This need really more reflection since we need to know what is a View
> (security, view actions, ...).
> And it's a big impact on current code.
> The ViewConfigStore would be sthing like (really incomplete) :
> ViewConfigStore :
> public Map<String,ViewInfo> getView(String viewId);
> public List<View> getViews();
> }
> with for instance :
> class/interface View {
> List<Restriction> getRestrictions();
> List<ViewAction> getViewActions(); //or event List<Action>
> getAction(PhaseId)
> }
>
> WDYT ?
>
> P.S. Sorry for the rather long mail........
>
>
> More details on what I have done for now :
>
> As noted in the ticket, I can now create a viewAction annotation like this
> one :
>
>
> @ViewActionBindingType
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
> public @interface MyViewAction {
> MyAppViewConfig.Pages value();
> }
>
> MyAppViewConfig being the sample @ViewConfig annotated class in viewconfig
> sample.
>
> I can then use MyViewAction like this :
>
>
> @ViewScoped
> @Named
> public class PageController implements Serializable {
>     @MyViewAction(Pages.ITEM)
>     public void loadEntry() {
>     System.out.println("loadEntry called");
>     }
> }
>
> For the moment, my code doesn't call this method (I'll just need to copy
> Seam Security code for it ;) ).
>
>
> I've also created the following annotation that you can use to annotate
> your own viewAction annotation :
>  - @Condition(condition=String) -> not really type safe.....
>  - @Immediate(immediate=Boolean)
>  - @OnPostback(onPostback=boolean)
>  - @Phase(value=PhaseIdType)
>
> Also, if you need to customise those behaviour per-usage, you can add
> attributes into your viewAction annotation :
> @MyViewAction(Pages.ITEM, immediate=true, condition="#{myBean.eager}")
> public void loadEntry()
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>



-- 
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp

Software Engineer
Open Source Advocate
Author of Seam Catch - Next Generation Java Exception Handling

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20111028/3f17a938/attachment.html 


More information about the seam-dev mailing list