Re: Annotations and ComponentRequestFilter Problem
Hi Taha, Hi Thiago, Thanks a lot for your reply, it's working perfectly! And besides, this surely gave me some more basic understanding on how tapestry works. Have a nice day, cheers, Sascha -- View this message in context: http://tapestry.1045711.n5.nabble.com/Annotations-and-ComponentRequestFilter-Problem-tp3232159p3235337.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
Can you share the code taha On Fri, Oct 22, 2010 at 5:55 PM, shinlang sascha.hinl...@gameforge.dewrote: Hi, i'm having a problem using custom annotations and a ComponentRequestFilter. I am defining my own class annotation (TestAnnotation) and a test class (Index) that uses this annotation. In my ComponentRequestFilter however, when i am checking the page class (via componentSource.getPage().getClass(), it doesn't have the annotation. However, When i try to read the annotation on the class itself (using Index.class), it's working. Therefore i assume this has something to do with class transformation in tapestry, it seems like the class annotation isn't present in the transformed class anymore. I have of course read the article at http://tapestryjava.blogspot.com/2009/12/securing-tapestry-pages-with.html , and i can't see any difference: Component page = componentSource.getPage(pageName); if (! page.getClass().isAnnotationPresent(RequiresLogin.class)) { return false; } is exactly what I'm using (except for the different variable names...), it just doesn't work. When i try Index.class.isAnnotationPresent(TestAnnotation.class) it returns true, just as expected. If anyone got a good idea, i'd be very thankful. Regards, Sascha -- View this message in context: http://tapestry.1045711.n5.nabble.com/Annotations-and-ComponentRequestFilter-Problem-tp3232159p3232159.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
On Fri, 22 Oct 2010 10:25:03 -0200, shinlang sascha.hinl...@gameforge.de wrote: Hi, Hi! I have of course read the article at http://tapestryjava.blogspot.com/2009/12/securing-tapestry-pages-with.html, and i can't see any difference: Component page = componentSource.getPage(pageName); if (! page.getClass().isAnnotationPresent(RequiresLogin.class)) { return false; } This doesn't work if you add the annotation after you started the application. Another way of doing that, which works well with live class reloading (you add, remove or change an annotation and it automatically works) is using a worker. This is the one which handles the @Secure annotation in Tapestry: public class SecureWorker implements ComponentClassTransformWorker { public void transform(ClassTransformation transformation, MutableComponentModel model) { Secure secure = transformation.getAnnotation(Secure.class); if (secure != null) model.setMeta(MetaDataConstants.SECURE_PAGE, true); } } You can get the ComponentModel of a given page or component instance using getComponentResources().getComponentModel(). -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
Hi taha, you can find an example project here: http://satansoft.de/tapestry/annotationtest.zip It uses a very simple setup to show the problem. In TestFilter.java in the annotationTest() method you can see that the upper test case is not working, but the lower case is working well. Regards, Sascha -- View this message in context: http://tapestry.1045711.n5.nabble.com/Annotations-and-ComponentRequestFilter-Problem-tp3232159p3232236.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
Hi Thiago, thanks for your reply. I will certainly give that a try, but i won't be in the office until monday. I'm not sure, if i stated my problem right (as i'm quite new to tapestry). I am not dynamically adding the annotation to the class, as far as i can see, so getting it from the component source should work, shouldn't it? There is a test project that desscribes the problem, it can be found at http://satansoft.de/tapestry/annotationtest.zip. In the TestFilter class you can see how i try to get the annotation from the page. Btw, i'm using Tapestry 5.2... Regards, Sascha -- View this message in context: http://tapestry.1045711.n5.nabble.com/Annotations-and-ComponentRequestFilter-Problem-tp3232159p3232277.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
Just move the annotation out of the pages package. Although I don't know the internals of tapestry that well but I think because pages and components packages have live reloading they may be loaded from different classloaders... regards Taha On Fri, Oct 22, 2010 at 7:19 PM, shinlang sascha.hinl...@gameforge.dewrote: Hi Thiago, thanks for your reply. I will certainly give that a try, but i won't be in the office until monday. I'm not sure, if i stated my problem right (as i'm quite new to tapestry). I am not dynamically adding the annotation to the class, as far as i can see, so getting it from the component source should work, shouldn't it? There is a test project that desscribes the problem, it can be found at http://satansoft.de/tapestry/annotationtest.zip. In the TestFilter class you can see how i try to get the annotation from the page. Btw, i'm using Tapestry 5.2... Regards, Sascha -- View this message in context: http://tapestry.1045711.n5.nabble.com/Annotations-and-ComponentRequestFilter-Problem-tp3232159p3232277.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and ComponentRequestFilter Problem
On Fri, 22 Oct 2010 12:10:38 -0200, Taha Hafeez tawus.tapes...@gmail.com wrote: Just move the annotation out of the pages package. This is one of the most common pitfalls Tapestry beginners fall: never never never put something in a pages, components or mixins package that isn't a page, component or mixin. Although I don't know the internals of tapestry that well but I think because pages and components packages have live reloading they may be loaded from different classloaders... Taha, you're absolutely correct. ;) -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Annotations and translators
SORRY Such a dumb I'm! The binding declaration was wrong... ;) Mael On 10/4/06, Mael Caldas [EMAIL PROTECTED] wrote: Hi, I wan to to declare a DatePicker component with annotations. I just passed the component from .page, to java the corresponding java class, but I got a parse exception, because of the translators bindings... Here is the code on .page: component id=date type=DatePicker binding name=value value=date/ binding name=displayName value=literal:Data/ binding name=validators value=validators:required[É necessário uma data!]/ binding name=translator value=translator:date,pattern=dd/MM/,message=Data Inválida!/ /component And with annotation: @Component(id=date, type=DatePicker, bindings= {value=date, displayName=literal:Data, validators={validators:required[É necessário uma data!]}, translator={translator:date,pattern=dd/MM/,message=Data Inválida!}}) public abstract DatePicker getDateComponent(); Does anybody know a way to declare the component with annotation, and make some complex bindings like these, without error? Thank you!
Re: Annotations and translators
Not dumb, that's what this list is for. :) On 10/4/06, Mael Caldas [EMAIL PROTECTED] wrote: SORRY Such a dumb I'm! The binding declaration was wrong... ;) Mael On 10/4/06, Mael Caldas [EMAIL PROTECTED] wrote: Hi, I wan to to declare a DatePicker component with annotations. I just passed the component from .page, to java the corresponding java class, but I got a parse exception, because of the translators bindings... Here is the code on .page: component id=date type=DatePicker binding name=value value=date/ binding name=displayName value=literal:Data/ binding name=validators value=validators:required[É necessário uma data!]/ binding name=translator value=translator:date,pattern=dd/MM/,message=Data Inválida!/ /component And with annotation: @Component(id=date, type=DatePicker, bindings= {value=date, displayName=literal:Data, validators={validators:required[É necessário uma data!]}, translator={translator:date,pattern=dd/MM/,message=Data Inválida!}}) public abstract DatePicker getDateComponent(); Does anybody know a way to declare the component with annotation, and make some complex bindings like these, without error? Thank you! -- Jesse Kuhnert Tapestry/Dojo/(and a dash of TestNG), team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
Re: Annotations and translators
hehehehe thanks! :) On 10/4/06, Jesse Kuhnert [EMAIL PROTECTED] wrote: Not dumb, that's what this list is for. :) On 10/4/06, Mael Caldas [EMAIL PROTECTED] wrote: SORRY Such a dumb I'm! The binding declaration was wrong... ;) Mael On 10/4/06, Mael Caldas [EMAIL PROTECTED] wrote: Hi, I wan to to declare a DatePicker component with annotations. I just passed the component from .page, to java the corresponding java class, but I got a parse exception, because of the translators bindings... Here is the code on .page: component id=date type=DatePicker binding name=value value=date/ binding name=displayName value=literal:Data/ binding name=validators value=validators:required[É necessário uma data!]/ binding name=translator value=translator:date,pattern=dd/MM/,message=Data Inválida!/ /component And with annotation: @Component(id=date, type=DatePicker, bindings= {value=date, displayName=literal:Data, validators={validators:required[É necessário uma data!]}, translator={translator:date,pattern=dd/MM/,message=Data Inválida!}}) public abstract DatePicker getDateComponent(); Does anybody know a way to declare the component with annotation, and make some complex bindings like these, without error? Thank you! -- Jesse Kuhnert Tapestry/Dojo/(and a dash of TestNG), team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
RE: annotations
You don't need an empty spec, but you do need to tell tapestry where to find your page/component classes. In your application file: application meta key=org.apache.tapestry.page-class-packages value=com.myco.web.page/ meta key=org.apache.tapestry.component-class-packages value=com.myco.web.component/ /application So, tapestry will look in those packages for pages/components. Hope that helps. James -Original Message- From: Alex Kartashev [mailto:[EMAIL PROTECTED] Sent: Friday, May 26, 2006 9:41 AM To: Tapestry users Subject: Re: annotations I believe you still you need to have a component spec, albeit an empty one. -Alex Dimitri Taranov wrote: I am trying to use annotations. To start, I deleted a very simple component specification and instead added an annotation @ComponentClass. Do I just add annotations compile and deploy or do I have to compile with Apt? When going with the first approach I get Component not found. When trying to Apt I get: warning: No annotation processors found but annotations present. These jars are in my classpath: commons-codec-1.3.jar ognl-2.6.7.jar commons-fileupload-1.1.jar oro-2.0.8.jar commons-io-1.1.jar tapestry-4.0.1.jar commons-logging-api-1.0.4.jar tapestry-annotations-4.0.1.jar hivemind-1.1.1.jar tapestry-contrib-4.0.1.jar hivemind-lib-1.1.1.jar tapestry-portlet-4.0.1.jar javassist-3.0.jar I can't find any additional info on the topic. Do I need some other jars? Dimitri - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: annotations
Thx, that worked -Original Message- From: James Carman [mailto:[EMAIL PROTECTED] Sent: Friday, May 26, 2006 9:44 AM To: 'Tapestry users' Subject: RE: annotations You don't need an empty spec, but you do need to tell tapestry where to find your page/component classes. In your application file: application meta key=org.apache.tapestry.page-class-packages value=com.myco.web.page/ meta key=org.apache.tapestry.component-class-packages value=com.myco.web.component/ /application So, tapestry will look in those packages for pages/components. Hope that helps. James -Original Message- From: Alex Kartashev [mailto:[EMAIL PROTECTED] Sent: Friday, May 26, 2006 9:41 AM To: Tapestry users Subject: Re: annotations I believe you still you need to have a component spec, albeit an empty one. -Alex Dimitri Taranov wrote: I am trying to use annotations. To start, I deleted a very simple component specification and instead added an annotation @ComponentClass. Do I just add annotations compile and deploy or do I have to compile with Apt? When going with the first approach I get Component not found. When trying to Apt I get: warning: No annotation processors found but annotations present. These jars are in my classpath: commons-codec-1.3.jar ognl-2.6.7.jar commons-fileupload-1.1.jar oro-2.0.8.jar commons-io-1.1.jar tapestry-4.0.1.jar commons-logging-api-1.0.4.jar tapestry-annotations-4.0.1.jar hivemind-1.1.1.jar tapestry-contrib-4.0.1.jar hivemind-lib-1.1.1.jar tapestry-portlet-4.0.1.jar javassist-3.0.jar I can't find any additional info on the topic. Do I need some other jars? Dimitri - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]