parameter passing from child page to parent component
Hi, I am new to Tapestry and to version 5. I am trying to use a page to pass in the parameter string to my layout component. Example, passing in a title from my page to my layout component. Also, trying to do this without using injection. Let me know if this is feasible. Thanks, - Bryant -- Bryant Castaneda Computer Scientist - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: t5: @Inject hibernate Session into a service?
Your logic is fine with regard to the ApplicationStateManager. I wanted to mention the difference with the HibernateSessionManager for the sake of anyone else that happens upon this thread. All the best, lasitha. On 9/23/07, Chris Lewis <[EMAIL PROTECTED]> wrote: > Let me restate - I do NOT need the HibernateSessionManager, but I DO > need an ASO. ASOs are per client/request/thread, so I will have to > figure this part out as my service is a Singleton (and I'm not convinced > it needs to be per thread). So... couldn't I just inject a reference to > the ApplicationStateManager into my Dispatcher, and then use it to grab > ASOs? As long as the ApplicationStateManager accesses the current > thread, this should work. I haven't yet put much thought into this, but > I'm reading up now. Does my logic appear flawed? > > lasitha wrote: > > AFAIK, @Inject only works on pages and components. Services are > > injected into via their constructors, without need of any annotations. > > > > Services are singletons by default, but you can use the @Scope > > annotation to make them per-thread. > > > > If however you want the dispatcher to be a singleton, you've got a > > little more work to do :) > > > > This recent thread about getting an ASO into a singleton service might > > give you some ideas: "T5 - Inject an Application State Object into a > > Service" (Sep 12) [1] > > > > In your case, you need to create something similar to the > > ApplicationStateManager to get a hold of the Session for the current > > thread. Unfortunately, the HibernateSessionManager [2] service won't > > work because its also per-thread. > > > > Take a look at 'Shadow Services' [3] in the ioc. I think you could > > create a service that shadows the HibernateSessionManager.getSession() > > method and have this injected into your dispatcher. Your dispatcher > > and shadow service remain singletons. > > > > I'm afraid i don't have time to test it out, but it seems to work in my > > head :) > > > > Cheers, > > lasitha. > > > > [1] > > http://mail-archives.apache.org/mod_mbox/tapestry-users/200709.mbox/[EMAIL > > PROTECTED] > > > > [2] > > http://tapestry.apache.org/tapestry5/tapestry-hibernate/apidocs/index.html?org/apache/tapestry/hibernate/HibernateSessionManager.html > > > > [3] http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html > > > > > > On 9/22/07, Chris Lewis <[EMAIL PROTECTED]> wrote: > > > >> Hi all, > >> > >> I'm implementing an access control service as a Dispatcher, and > >> contributing it to the MasterDispatcher service. This dispatcher runs > >> just before PageRender... and ComponentAction..., so that it can check > >> if the user is allowed to access the page/resource. This seems to be a > >> very "T5" way of doing things and completely removes the task of access > >> control from the pages (ie i don't have to extend a base page that > >> implements control logic). > >> I want this service to use a database and am already using > >> tapestry-hibernate in this project. I figured I could just @Inject the > >> session into my service just like I would a page or component, but that > >> doesn't work. In a way that makes sense; services are singletons if I'm > >> not mistaken (which makes sense), and Sessions exist (and possibly > >> injected?) per-thread. Being that my service will be started in a > >> different thread than any request, I think @Inject is ignored. > >> > >> So my question is, how should I go about getting access to my database > >> from my service? I'd like to use the blinding simplicity of of IoC just > >> giving it to me, but I;m not sure that's an option. Any ideas? > >> > >> thanks, > >> chris > >> > >> - > >> 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]
Re: t5: @Inject hibernate Session into a service?
Let me restate - I do NOT need the HibernateSessionManager, but I DO need an ASO. ASOs are per client/request/thread, so I will have to figure this part out as my service is a Singleton (and I'm not convinced it needs to be per thread). So... couldn't I just inject a reference to the ApplicationStateManager into my Dispatcher, and then use it to grab ASOs? As long as the ApplicationStateManager accesses the current thread, this should work. I haven't yet put much thought into this, but I'm reading up now. Does my logic appear flawed? lasitha wrote: AFAIK, @Inject only works on pages and components. Services are injected into via their constructors, without need of any annotations. Services are singletons by default, but you can use the @Scope annotation to make them per-thread. If however you want the dispatcher to be a singleton, you've got a little more work to do :) This recent thread about getting an ASO into a singleton service might give you some ideas: "T5 - Inject an Application State Object into a Service" (Sep 12) [1] In your case, you need to create something similar to the ApplicationStateManager to get a hold of the Session for the current thread. Unfortunately, the HibernateSessionManager [2] service won't work because its also per-thread. Take a look at 'Shadow Services' [3] in the ioc. I think you could create a service that shadows the HibernateSessionManager.getSession() method and have this injected into your dispatcher. Your dispatcher and shadow service remain singletons. I'm afraid i don't have time to test it out, but it seems to work in my head :) Cheers, lasitha. [1] http://mail-archives.apache.org/mod_mbox/tapestry-users/200709.mbox/[EMAIL PROTECTED] [2] http://tapestry.apache.org/tapestry5/tapestry-hibernate/apidocs/index.html?org/apache/tapestry/hibernate/HibernateSessionManager.html [3] http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html On 9/22/07, Chris Lewis <[EMAIL PROTECTED]> wrote: Hi all, I'm implementing an access control service as a Dispatcher, and contributing it to the MasterDispatcher service. This dispatcher runs just before PageRender... and ComponentAction..., so that it can check if the user is allowed to access the page/resource. This seems to be a very "T5" way of doing things and completely removes the task of access control from the pages (ie i don't have to extend a base page that implements control logic). I want this service to use a database and am already using tapestry-hibernate in this project. I figured I could just @Inject the session into my service just like I would a page or component, but that doesn't work. In a way that makes sense; services are singletons if I'm not mistaken (which makes sense), and Sessions exist (and possibly injected?) per-thread. Being that my service will be started in a different thread than any request, I think @Inject is ignored. So my question is, how should I go about getting access to my database from my service? I'd like to use the blinding simplicity of of IoC just giving it to me, but I;m not sure that's an option. Any ideas? thanks, chris - 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: t5: @Inject hibernate Session into a service?
Oh, you snuck in while i was typing :) Please test whether your solution works - i don't think it will... The HibernateSessionManager is a per-thread service, and the current implementation creates a session on construction. So your AccessController constructor will be handed the HibernateSessionManager (and thereby the Session) for the first thread that accesses the AccessController. All subsequent threads will get the very same HibernateSessionManager and Session instances. If i'm not getting this all muddled, i think you have to use a shadow to get a different session per thread from your service (see my previous post). Cheers. On 9/22/07, lasitha <[EMAIL PROTECTED]> wrote: > AFAIK, @Inject only works on pages and components. Services are > injected into via their constructors, without need of any annotations. > > Services are singletons by default, but you can use the @Scope > annotation to make them per-thread. > > If however you want the dispatcher to be a singleton, you've got a > little more work to do :) > > This recent thread about getting an ASO into a singleton service might > give you some ideas: "T5 - Inject an Application State Object into a > Service" (Sep 12) [1] > > In your case, you need to create something similar to the > ApplicationStateManager to get a hold of the Session for the current > thread. Unfortunately, the HibernateSessionManager [2] service won't > work because its also per-thread. > > Take a look at 'Shadow Services' [3] in the ioc. I think you could > create a service that shadows the HibernateSessionManager.getSession() > method and have this injected into your dispatcher. Your dispatcher > and shadow service remain singletons. > > I'm afraid i don't have time to test it out, but it seems to work in my head > :) > > Cheers, > lasitha. > > [1] > http://mail-archives.apache.org/mod_mbox/tapestry-users/200709.mbox/[EMAIL > PROTECTED] > > [2] > http://tapestry.apache.org/tapestry5/tapestry-hibernate/apidocs/index.html?org/apache/tapestry/hibernate/HibernateSessionManager.html > > [3] http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html > > > On 9/22/07, Chris Lewis <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I'm implementing an access control service as a Dispatcher, and > > contributing it to the MasterDispatcher service. This dispatcher runs > > just before PageRender... and ComponentAction..., so that it can check > > if the user is allowed to access the page/resource. This seems to be a > > very "T5" way of doing things and completely removes the task of access > > control from the pages (ie i don't have to extend a base page that > > implements control logic). > > I want this service to use a database and am already using > > tapestry-hibernate in this project. I figured I could just @Inject the > > session into my service just like I would a page or component, but that > > doesn't work. In a way that makes sense; services are singletons if I'm > > not mistaken (which makes sense), and Sessions exist (and possibly > > injected?) per-thread. Being that my service will be started in a > > different thread than any request, I think @Inject is ignored. > > > > So my question is, how should I go about getting access to my database > > from my service? I'd like to use the blinding simplicity of of IoC just > > giving it to me, but I;m not sure that's an option. Any ideas? > > > > thanks, > > chris > > > > - > > 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: t5: @Inject hibernate Session into a service?
AFAIK, @Inject only works on pages and components. Services are injected into via their constructors, without need of any annotations. Services are singletons by default, but you can use the @Scope annotation to make them per-thread. If however you want the dispatcher to be a singleton, you've got a little more work to do :) This recent thread about getting an ASO into a singleton service might give you some ideas: "T5 - Inject an Application State Object into a Service" (Sep 12) [1] In your case, you need to create something similar to the ApplicationStateManager to get a hold of the Session for the current thread. Unfortunately, the HibernateSessionManager [2] service won't work because its also per-thread. Take a look at 'Shadow Services' [3] in the ioc. I think you could create a service that shadows the HibernateSessionManager.getSession() method and have this injected into your dispatcher. Your dispatcher and shadow service remain singletons. I'm afraid i don't have time to test it out, but it seems to work in my head :) Cheers, lasitha. [1] http://mail-archives.apache.org/mod_mbox/tapestry-users/200709.mbox/[EMAIL PROTECTED] [2] http://tapestry.apache.org/tapestry5/tapestry-hibernate/apidocs/index.html?org/apache/tapestry/hibernate/HibernateSessionManager.html [3] http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html On 9/22/07, Chris Lewis <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm implementing an access control service as a Dispatcher, and > contributing it to the MasterDispatcher service. This dispatcher runs > just before PageRender... and ComponentAction..., so that it can check > if the user is allowed to access the page/resource. This seems to be a > very "T5" way of doing things and completely removes the task of access > control from the pages (ie i don't have to extend a base page that > implements control logic). > I want this service to use a database and am already using > tapestry-hibernate in this project. I figured I could just @Inject the > session into my service just like I would a page or component, but that > doesn't work. In a way that makes sense; services are singletons if I'm > not mistaken (which makes sense), and Sessions exist (and possibly > injected?) per-thread. Being that my service will be started in a > different thread than any request, I think @Inject is ignored. > > So my question is, how should I go about getting access to my database > from my service? I'd like to use the blinding simplicity of of IoC just > giving it to me, but I;m not sure that's an option. Any ideas? > > thanks, > chris > > - > 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: t5: @Inject hibernate Session into a service?
why implementing an access control service ? ^_^ maybe = a wery "T5" way? Chris Lewis-5 wrote: > > Hi all, > > I'm implementing an access control service as a Dispatcher, and > contributing it to the MasterDispatcher service. This dispatcher runs > just before PageRender... and ComponentAction..., so that it can check > if the user is allowed to access the page/resource. This seems to be a > very "T5" way of doing things and completely removes the task of access > control from the pages (ie i don't have to extend a base page that > implements control logic). > I want this service to use a database and am already using > tapestry-hibernate in this project. I figured I could just @Inject the > session into my service just like I would a page or component, but that > doesn't work. In a way that makes sense; services are singletons if I'm > not mistaken (which makes sense), and Sessions exist (and possibly > injected?) per-thread. Being that my service will be started in a > different thread than any request, I think @Inject is ignored. > > So my question is, how should I go about getting access to my database > from my service? I'd like to use the blinding simplicity of of IoC just > giving it to me, but I;m not sure that's an option. Any ideas? > > thanks, > chris > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/t5%3A-%40Inject-hibernate-Session-into-a-service--tf4501533.html#a12838907 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: t5: @Inject hibernate Session into a service?
I've made a bit of progress. First of all, I realized that I don't need database access for my AccessController (Dispatcher) since it will simply need to check a User object for roles, etc. This object would be created/destroyed by a login page. I did figure out an acceptable way to get at the Session at any rate, so here's what I did. tapestry-hibernate provides the "HibernateSessionManager" service, which is represented by an interface of the same name. So in my AppModule I have a builder method that basically does this: public Dispatcher buildAccessController(@Inject HibernateSessionManager sessionManager) { return new AccessControllerImpl(sessionManager); } The builder is provided with the tapestry-ioc HibernateSessionManager service, which then passes this instance to my AccessController. According to the source of HibernateSessionManager, the implementation provides a Session for the current thread via: HibernateSessionManager#getSession So now that my AccessController has this service, it can simply call getSession() anytime it needs a Session. I'm now dealing with a different (architectural) issue, but that's for another message ;). I hope someone finds this useful! sincerely, chris Chris Lewis wrote: Hi all, I'm implementing an access control service as a Dispatcher, and contributing it to the MasterDispatcher service. This dispatcher runs just before PageRender... and ComponentAction..., so that it can check if the user is allowed to access the page/resource. This seems to be a very "T5" way of doing things and completely removes the task of access control from the pages (ie i don't have to extend a base page that implements control logic). I want this service to use a database and am already using tapestry-hibernate in this project. I figured I could just @Inject the session into my service just like I would a page or component, but that doesn't work. In a way that makes sense; services are singletons if I'm not mistaken (which makes sense), and Sessions exist (and possibly injected?) per-thread. Being that my service will be started in a different thread than any request, I think @Inject is ignored. So my question is, how should I go about getting access to my database from my service? I'd like to use the blinding simplicity of of IoC just giving it to me, but I;m not sure that's an option. Any ideas? thanks, chris - 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]
T5 chained select box + ajax
I am trying to build 2 chained select boxes with Tapestry 5 and Ajax. So the idea is to make the values of the second select box dependent of the first select box. But till now, no success. Does anyone has an example of how to use T5 with Ajax? All help is welcome, Thanks! JP
t5: @Inject hibernate Session into a service?
Hi all, I'm implementing an access control service as a Dispatcher, and contributing it to the MasterDispatcher service. This dispatcher runs just before PageRender... and ComponentAction..., so that it can check if the user is allowed to access the page/resource. This seems to be a very "T5" way of doing things and completely removes the task of access control from the pages (ie i don't have to extend a base page that implements control logic). I want this service to use a database and am already using tapestry-hibernate in this project. I figured I could just @Inject the session into my service just like I would a page or component, but that doesn't work. In a way that makes sense; services are singletons if I'm not mistaken (which makes sense), and Sessions exist (and possibly injected?) per-thread. Being that my service will be started in a different thread than any request, I think @Inject is ignored. So my question is, how should I go about getting access to my database from my service? I'd like to use the blinding simplicity of of IoC just giving it to me, but I;m not sure that's an option. Any ideas? thanks, chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] How to replace a service that is used by Automatic Dependency Resolution
Thanks, I know that that sentiment has been put out there. The challenge is that I have a couple of pages that I want to email. They are very close to existing web-pages so I'd like to be able to take advantage of my tapestry templates. I have contemplated just using a UrlConnection and grabbing the bytes that way, but that doesn't sit well... Josh On 9/22/07, Chris Lewis <[EMAIL PROTECTED]> wrote: > > It's been suggested that using T5 rendering core as a generic templating > system is bad. Using a different system designed for this was the > suggested solution (something like velocity). My guess is that won't sit > well with you, being that you've progressed as far as you have. At any > rate, good luck and share your experience! > > Josh Canfield wrote: > >> Service interface org.apache.tapestry.services.Environment is matched > by 2 > >> services: Environment, MyEnvironment. Automatic dependency resolution > >> requires that exactly one service implement the interface. > >> > >> > > > > It appears that I can't Alias Environment with my own implementation > because > > I can't bind MyEnvironment since it implements the Environment interface > > (the above error). > > > > I've poked around a lot and I'm not finding a solution. > > > > I'd like to render 2 pages in one request, one for sending an email, and > one > > to reply to the http request. Environment has a perthread scope, so when > my > > email page renders it clears the environment and now my form from my > html > > page tries to use the environment and fails. > > > > Thoughts? > > > > Josh > > > > > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.
Re: Request Parameters
It's not clear to me what exactly is your goal if it is, as I think, dinamically generate a tapestry url inside a javascript you should then look at one of the IEngineService (depending on the type of "service" your link will be bound to): http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/engine/IEngineService.html in particular the getLink method. In fact I think there is a lack of documentation in tapestry about how to properly generate url. The most common case (action/listener links for forms or not) you should look at DirectService http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/engine/DirectService.html and the Object passed to the getLink method (even though not documented) should be of type DirectServiceParameter (http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/engine/DirectServiceParameter.html) You can see the types of parameters that can be passed reading DirectLink component documentation (http://tapestry.apache.org/tapestry4.1/components/link/directlink.html) Hope this can be of some help. Martino On 9/21/07, mogulwraith <[EMAIL PROTECTED]> wrote: > > From Javascript I try to build a link something like: > > var link = "${requestlink}" + "?firstparam=" + paramA + "&secondparam=" + > paramB; > > But when this gets back to the server the only parameter available with > request.getParameter is the first one. How can I accomplish this? > > -- > View this message in context: > http://www.nabble.com/Request-Parameters-tf4498661.html#a12830070 > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > 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]
get labels and error messages from pagename.properties
First question: Is it possible to get the for in a label component from the pagename.properties file? like this: : Because I get the following Exception: Failure reading parameter for of component product/View:label Could not find a coercion from type java.lang.String to type org.apache.tapestry.Field. The product object is located in the tapestry.data package Second question: How do I customize the error messages of the textfield, because it has a t:validate="required" what kind of label do I have to add in the pagename.properties file? I want to change both the "You must correct the following errors before you may continue." message and the "must provide a value for Title" message.
get label from page.properties error
Is it possible to get the for in a label component from the page.propertiesfile, like this: : Because I get the following Exception: Failure reading parameter for of component product/View:label Could not find a coercion from type java.lang.String to type org.apache.tapestry.Field. The product object is located in the tapestry.data package
Re: user access control
Ok I realize this thread has been dormant for a while, but I'm back to the issue again. First of all I neglected to mention the first time that I'm using T5. Siddhartha, I dug into MasterDispatcher after finding it and thinking this was how it could be done, but I haven't figured it out yet. I've contributed to it, but the problem is that its configuration is ordered. So what happens is any Dispatcher I contribute doesn't get called until after all the rest (PageRender, ComponentAction, etc). UPDATE As I'm writing this I looked at TapestryModule again and notice that there is an argument allowing me to manipulate where my dispatcher gets inserted! I have to run, but if you could expand on your implementation (assuming you can't provide code), that would be great! Either way, thanks! Siddhartha Argollo wrote: I think so too. My solution was to contribute to MasterDispatcher with a SecurityDispatcher, that is responsible to verify if the user is authenticated, before he has access to a page. It is a request filter, but inside the tapestry framework, not a servlet filter. Chris Lewis wrote: I apologize for being vague. I don't mean a servlet filter, I mean a filter/filtering system with in the tapestry framework. Something that might allow me to supply access logic before page rendering, so that I don't have to require pages to know about the access control system used. I know this can be implemented in pages and simplified by subclassing, but I'm wondering if there is a cleaner way, a more 'separation of concerns' oriented way (a page is page, not an access controller). - 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: [T5] Page with same name as package
I'm afraid I don't understand your example: com.mydomain.myapp.pages.package1.Package1 then visit - www.mydomain.com/myapp/package1 Of course this won't work, since 'package1' is not a page name. However 'package1/package1' should. As for your trailing slash issue, I've not seen that one and it certainly should never occur. Do your tests again just to be sure, and if you still get them then there may need to be a bug report. If this is happening its likely a server issue (im using jetty and have never seen that). chris patrick whalen wrote: Strangely, this only works if there's another class in the same package, and you visit that page first. If you don't visit that page first, you get a 404 error. If you do, it works. After that, you can delete that other class and it will continue to work, even if you restart the application. To summarize: create - com.mydomain.myapp.pages.package1.Package1 then visit - www.mydomain.com/myapp/package1 returns a 404 error, unless you create - com.mydomain.myapp.pages.package1.TemporaryClass then visit - www.mydomain.com/myapp/package1/temporaryclass you will then be able to visit - www.mydomain.com/myapp/package1 without getting a 404 error. patrick whalen wrote: I see now that it does work to put a class of the same name as the package, inside the package. The redundant name is then filtered out.
Re: [T5] How to replace a service that is used by Automatic Dependency Resolution
It's been suggested that using T5 rendering core as a generic templating system is bad. Using a different system designed for this was the suggested solution (something like velocity). My guess is that won't sit well with you, being that you've progressed as far as you have. At any rate, good luck and share your experience! Josh Canfield wrote: Service interface org.apache.tapestry.services.Environment is matched by 2 services: Environment, MyEnvironment. Automatic dependency resolution requires that exactly one service implement the interface. It appears that I can't Alias Environment with my own implementation because I can't bind MyEnvironment since it implements the Environment interface (the above error). I've poked around a lot and I'm not finding a solution. I'd like to render 2 pages in one request, one for sending an email, and one to reply to the http request. Environment has a perthread scope, so when my email page renders it clears the environment and now my form from my html page tries to use the environment and fails. Thoughts? Josh