Re: Login page + post login page .... OR Getting a page from a dispatcher
Hi Uli et al, Is there a neater way to tidier way to extract the activation context parameters from the Request than the way I'm doing it below? It assumes I've already extracted the pageName from the Request path. String path = request.getPath(); String[] activationContextParams = path.substring(pageName.length() + 1).split(); for (int i = 0; i activationContextParams.length; i++) { if (activationContextParams[i].length() 0) { activationContextParams[i] = activationContextParams[i].substring(1); } } Link pageAfterLoginLink = pageRenderLinkSource.createPageRenderLinkWithContext(pageName, (Object[]) activationContextParams); Cheers, Geoff On 30/10/2009, at 5:53 AM, Ulrich Stärk wrote: That's weird. It's exactly how I'm doing it: PageCallbackContainer login = (PageCallbackContainer) componentSource.getPage(Login.class); login.setCallback(new PageCallback(pageName, pageActivationContext, linkSource)); Link link = linkSource.createPageRenderLink(Login.class); response.sendRedirect(link); PageCallbackContainer is the interface implemented by the Login page class. I'm calling it from inside a ComponentRequestFilter but that shouldn't matter. Are you sure that Login really implements ILogin? Cheers, Uli Am 29.10.2009 15:41 schrieb Gunnar Eketrapp: Hum ... your advice seemed quite straighforward By some reason I can't cast to the interface either ... Weirdo ... I have rebuild the project and restarted the APP since i thought that the old Login.class could spoke me ... java.lang.ClassCastException com.tellpoker.pages.Login cannot be cast to com.tellpoker.pages.ILogin Stack trace - com.tellpoker.services.ProtectedPageGateKeeper.checkAccess(ProtectedPageGateKeeper.java:147) - com.tellpoker.services.ProtectedPageGateKeeper.dispatch(ProtectedPageGateKeeper.java:64) - $Dispatcher_124a0b9d291.dispatch($Dispatcher_124a0b9d291.java) - $Dispatcher_124a0b9d286.dispatch($Dispatcher_124a0b9d286.java) - org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245) - com.tellpoker.services.AppModule$1.service(AppModule.java:144) - $RequestFilter_124a0b9d285.service($RequestFilter_124a0b9d285.java) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:778) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:767) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:81) - org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - $RequestHandler_124a0b9d27c.service($RequestHandler_124a0b9d27c.java) - org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:197) - org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53) - $HttpServletRequestHandler_124a0b9d27e.service($HttpServletRequestHandler_124a0b9d27e.java) - org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62) - $HttpServletRequestFilter_124a0b9d27b.service($HttpServletRequestFilter_124a0b9d27b.java) - $HttpServletRequestHandler_124a0b9d27e.service($HttpServletRequestHandler_124a0b9d27e.java) - org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:726) - $HttpServletRequestHandler_124a0b9d27e.service($HttpServletRequestHandler_124a0b9d27e.java) - $HttpServletRequestHandler_124a0b9d279.service($HttpServletRequestHandler_124a0b9d279.java) - org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:127) 2009/10/29 Gunnar Eketrapp gunnar.eketr...@gmail.com Thanks a lot !!! 2009/10/29 Ulrich Stärk u...@spielviel.de Have your page implement an interface that provides methods for setting the desired information and cast the result from componentSource.getPage() to that interface. The reason behind this is that the thing returned from componentSource
Re: [T5] Adding/removing entries to messages
Sorry, I missed the point, my solution only works for labels used in grids etc On 06.02.2010 13:51, Nuno Ferreira wrote: I'll definitely try that. And using a cache I could give my users the functionality to change at runtime the label translations, which I'm planning anyway since google translate isn't always perfect. On 6 February 2010 12:19, Alexander Muthmannamuthm...@dev-eth0.de wrote: Fast idea: You could override the existing provider for Message-Entries and add a function to look at google translate if the requestes label was not found. The service would be ComponentDefaultProvider and the needed method defaultLabel: public String defaultLabel(ComponentResources resources) { Defense.notNull(resources, resources); String componentId = resources.getId(); String key = componentId + -label; Messages containerMessages = resources.getContainerResources().getMessages(); if (containerMessages.contains(key)) return containerMessages.get(key); \\here you can check google translate return TapestryInternalUtils.toUserPresentable(componentId); } On the marked position you could add a new cache for already used labels... On 06.02.2010 13:12, Nuno Ferreira wrote: Hi, I would like to know if there is a way to programatically add and remove an entry from a messages catalog. The only way I see how to do this is to write to the file app_{locale}.properties, but I would like a cleaner way if there is one. I want to use google translate to automatically fill every catalog, and would love to hear there is something like messages.add(translation,locale) :) Thanks in advance, Nuno Ferreira - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Login page + post login page .... OR Getting a page from a dispatcher
There are several ways, depending on what you are doing. If inside a ComponentRequestHandler's handlePageRender() method, you can ask the PageRenderRequestParameters for getActivationContext(). If you are handling a component event in handleComponentEvent(), just ask the ComponentEventRequestParameters for getEventContext() or getPageActivationContext() (depending on what you need). PageRenderRequestParameters and ComponentEventRequestParameters are also available in a PageRenderRequestHandler or a ComponentEventRequestHandler. If you are not inside one of these handlers, try injecting the ContextPathEncoder service and call its decodePath() method. HTH, Uli Geoff Callender schrieb: Hi Uli et al, Is there a neater way to tidier way to extract the activation context parameters from the Request than the way I'm doing it below? It assumes I've already extracted the pageName from the Request path. String path = request.getPath(); String[] activationContextParams = path.substring(pageName.length() + 1).split(); for (int i = 0; i activationContextParams.length; i++) { if (activationContextParams[i].length() 0) { activationContextParams[i] = activationContextParams[i].substring(1); } } Link pageAfterLoginLink = pageRenderLinkSource.createPageRenderLinkWithContext(pageName, (Object[]) activationContextParams); Cheers, Geoff On 30/10/2009, at 5:53 AM, Ulrich Stärk wrote: That's weird. It's exactly how I'm doing it: PageCallbackContainer login = (PageCallbackContainer) componentSource.getPage(Login.class); login.setCallback(new PageCallback(pageName, pageActivationContext, linkSource)); Link link = linkSource.createPageRenderLink(Login.class); response.sendRedirect(link); PageCallbackContainer is the interface implemented by the Login page class. I'm calling it from inside a ComponentRequestFilter but that shouldn't matter. Are you sure that Login really implements ILogin? Cheers, Uli Am 29.10.2009 15:41 schrieb Gunnar Eketrapp: Hum ... your advice seemed quite straighforward By some reason I can't cast to the interface either ... Weirdo ... I have rebuild the project and restarted the APP since i thought that the old Login.class could spoke me ... java.lang.ClassCastException com.tellpoker.pages.Login cannot be cast to com.tellpoker.pages.ILogin Stack trace - com.tellpoker.services.ProtectedPageGateKeeper.checkAccess(ProtectedPageGateKeeper.java:147) - com.tellpoker.services.ProtectedPageGateKeeper.dispatch(ProtectedPageGateKeeper.java:64) - $Dispatcher_124a0b9d291.dispatch($Dispatcher_124a0b9d291.java) - $Dispatcher_124a0b9d286.dispatch($Dispatcher_124a0b9d286.java) - org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245) - com.tellpoker.services.AppModule$1.service(AppModule.java:144) - $RequestFilter_124a0b9d285.service($RequestFilter_124a0b9d285.java) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:778) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:767) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:81) - org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - $RequestHandler_124a0b9d27c.service($RequestHandler_124a0b9d27c.java) - org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:197) - org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53) - $HttpServletRequestHandler_124a0b9d27e.service($HttpServletRequestHandler_124a0b9d27e.java) - org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62) - $HttpServletRequestFilter_124a0b9d27b.service($HttpServletRequestFilter_124a0b9d27b.java) - $HttpServletRequestHandler_124a0b9d27e.service($HttpServletRequestHandler_124a0b9d27e.java) -
Re: T4: forward browser to an external web site
Yes I had already tought of a solution like taht but I was hoping for a clean tapestry solution like the you suggested me with the link. Thanks anyway. Would instead be possible with T5? Martin Strand ha scritto: For POST requests, your initial idea is the way to go: Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. So you'll render a form (no need to use the Form component for this) form action=http://www.example.com/; id=myForm method=post input type=hidden name=someParameter value=someValue/ /form If you want to submit the form automatically without having your user click anything, hide the form with CSS and use a script similar to this at the bottom of your page: ... ... script document.getElementById(myForm).submit(); /script /body /html On Sat, 06 Feb 2010 19:30:21 +0100, Ivano Luberti lube...@archicoop.it wrote: Thanks Martin: it worked. But what I could do in case I had to submit a form accepting only POST method in the form? Ivano Luberti ha scritto: I will try that: for whatever reason I was convinced that I had to submit a form and not simply a link. But checking twice the docs of the web site I have to forward to, I see I can use a link. Thanks for now Martin Strand ha scritto: If you just want to redirect the client to another URL, return an ILink from your form listener: public ILink formSubmitListener() { // Do work // ... return new StaticLink(http://www.example.com/;); } Martin On Wed, 03 Feb 2010 10:39:23 +0100, Ivano Luberti lube...@archicoop.it wrote: Hello, I'm trying to solve the following problem using T4.1.6. I want to have the user submit a form , perform some operation in the page class and then forward the user to an external web site. Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. I have tried using a service and HttpClient package but it return and HttpResponse and I'm not able to convert it to a WebResponse. Any suggestion? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- == dott. Ivano Mario Luberti Archimede Informatica societa' cooperativa a r. l. Sede Operativa Via Gereschi 36 - 56126- Pisa tel.: +39-050- 580959 tel/fax: +39-050-9711344 web: www.archicoop.it == - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T4: forward browser to an external web site
This has nothing to do with Tapestry, it's how the HTTP protocol works. There's just no response you can send which tells the client to POST data to another URL. Instead you send a short program which performs the POST and hope your client executes that program - that's the script solution. On Sun, 07 Feb 2010 18:37:15 +0100, Ivano Luberti lube...@archicoop.it wrote: Yes I had already tought of a solution like taht but I was hoping for a clean tapestry solution like the you suggested me with the link. Thanks anyway. Would instead be possible with T5? Martin Strand ha scritto: For POST requests, your initial idea is the way to go: Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. So you'll render a form (no need to use the Form component for this) form action=http://www.example.com/; id=myForm method=post input type=hidden name=someParameter value=someValue/ /form If you want to submit the form automatically without having your user click anything, hide the form with CSS and use a script similar to this at the bottom of your page: ... ... script document.getElementById(myForm).submit(); /script /body /html On Sat, 06 Feb 2010 19:30:21 +0100, Ivano Luberti lube...@archicoop.it wrote: Thanks Martin: it worked. But what I could do in case I had to submit a form accepting only POST method in the form? Ivano Luberti ha scritto: I will try that: for whatever reason I was convinced that I had to submit a form and not simply a link. But checking twice the docs of the web site I have to forward to, I see I can use a link. Thanks for now Martin Strand ha scritto: If you just want to redirect the client to another URL, return an ILink from your form listener: public ILink formSubmitListener() { // Do work // ... return new StaticLink(http://www.example.com/;); } Martin On Wed, 03 Feb 2010 10:39:23 +0100, Ivano Luberti lube...@archicoop.it wrote: Hello, I'm trying to solve the following problem using T4.1.6. I want to have the user submit a form , perform some operation in the page class and then forward the user to an external web site. Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. I have tried using a service and HttpClient package but it return and HttpResponse and I'm not able to convert it to a WebResponse. Any suggestion? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T4: forward browser to an external web site
I know, but a was hoping for some kind of forward to external web site mechanism. It shouldn't be impossible to build something like that using HttpClient or some similar package Martin Strand ha scritto: This has nothing to do with Tapestry, it's how the HTTP protocol works. There's just no response you can send which tells the client to POST data to another URL. Instead you send a short program which performs the POST and hope your client executes that program - that's the script solution. On Sun, 07 Feb 2010 18:37:15 +0100, Ivano Luberti lube...@archicoop.it wrote: Yes I had already tought of a solution like taht but I was hoping for a clean tapestry solution like the you suggested me with the link. Thanks anyway. Would instead be possible with T5? Martin Strand ha scritto: For POST requests, your initial idea is the way to go: Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. So you'll render a form (no need to use the Form component for this) form action=http://www.example.com/; id=myForm method=post input type=hidden name=someParameter value=someValue/ /form If you want to submit the form automatically without having your user click anything, hide the form with CSS and use a script similar to this at the bottom of your page: ... ... script document.getElementById(myForm).submit(); /script /body /html On Sat, 06 Feb 2010 19:30:21 +0100, Ivano Luberti lube...@archicoop.it wrote: Thanks Martin: it worked. But what I could do in case I had to submit a form accepting only POST method in the form? Ivano Luberti ha scritto: I will try that: for whatever reason I was convinced that I had to submit a form and not simply a link. But checking twice the docs of the web site I have to forward to, I see I can use a link. Thanks for now Martin Strand ha scritto: If you just want to redirect the client to another URL, return an ILink from your form listener: public ILink formSubmitListener() { // Do work // ... return new StaticLink(http://www.example.com/;); } Martin On Wed, 03 Feb 2010 10:39:23 +0100, Ivano Luberti lube...@archicoop.it wrote: Hello, I'm trying to solve the following problem using T4.1.6. I want to have the user submit a form , perform some operation in the page class and then forward the user to an external web site. Of course I can return to the new user a new page with a form that has an action that points to the web site, but it would be far better to have my page class. I have tried using a service and HttpClient package but it return and HttpResponse and I'm not able to convert it to a WebResponse. Any suggestion? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- == dott. Ivano Mario Luberti Archimede Informatica societa' cooperativa a r. l. Sede Operativa Via Gereschi 36 - 56126- Pisa tel.: +39-050- 580959 tel/fax: +39-050-9711344 web: www.archicoop.it == - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Login page + post login page .... OR Getting a page from a dispatcher
Thanks, I'll give that a try. BTW, the code I posted earlier doesn't work, but this seems to: String path = request.getPath(); String[] activationContextParams = path.substring(pageName.length() + 2).split(\\/); Link pageAfterLoginLink = pageRenderLinkSource.createPageRenderLinkWithContext(pageName, (Object[]) activationContextParams); Still, I'd prefer to have Tapestry figure out the activation context rather than me. On 07/02/2010, at 10:27 PM, Ulrich Stärk wrote: There are several ways, depending on what you are doing. If inside a ComponentRequestHandler's handlePageRender() method, you can ask the PageRenderRequestParameters for getActivationContext(). If you are handling a component event in handleComponentEvent(), just ask the ComponentEventRequestParameters for getEventContext() or getPageActivationContext() (depending on what you need). PageRenderRequestParameters and ComponentEventRequestParameters are also available in a PageRenderRequestHandler or a ComponentEventRequestHandler. If you are not inside one of these handlers, try injecting the ContextPathEncoder service and call its decodePath() method. HTH, Uli Geoff Callender schrieb: Hi Uli et al, Is there a neater way to tidier way to extract the activation context parameters from the Request than the way I'm doing it below? It assumes I've already extracted the pageName from the Request path. String path = request.getPath(); String[] activationContextParams = path.substring(pageName.length() + 1).split(); for (int i = 0; i activationContextParams.length; i++) { if (activationContextParams[i].length() 0) { activationContextParams[i] = activationContextParams[i].substring(1); } } Link pageAfterLoginLink = pageRenderLinkSource.createPageRenderLinkWithContext(pageName, (Object[]) activationContextParams); Cheers, Geoff On 30/10/2009, at 5:53 AM, Ulrich Stärk wrote: That's weird. It's exactly how I'm doing it: PageCallbackContainer login = (PageCallbackContainer) componentSource.getPage(Login.class); login.setCallback(new PageCallback(pageName, pageActivationContext, linkSource)); Link link = linkSource.createPageRenderLink(Login.class); response.sendRedirect(link); PageCallbackContainer is the interface implemented by the Login page class. I'm calling it from inside a ComponentRequestFilter but that shouldn't matter. Are you sure that Login really implements ILogin? Cheers, Uli Am 29.10.2009 15:41 schrieb Gunnar Eketrapp: Hum ... your advice seemed quite straighforward By some reason I can't cast to the interface either ... Weirdo ... I have rebuild the project and restarted the APP since i thought that the old Login.class could spoke me ... java.lang.ClassCastException com.tellpoker.pages.Login cannot be cast to com.tellpoker.pages.ILogin Stack trace - com.tellpoker.services.ProtectedPageGateKeeper.checkAccess(ProtectedPageGateKeeper.java:147) - com.tellpoker.services.ProtectedPageGateKeeper.dispatch(ProtectedPageGateKeeper.java:64) - $Dispatcher_124a0b9d291.dispatch($Dispatcher_124a0b9d291.java) - $Dispatcher_124a0b9d286.dispatch($Dispatcher_124a0b9d286.java) - org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245) - com.tellpoker.services.AppModule$1.service(AppModule.java:144) - $RequestFilter_124a0b9d285.service($RequestFilter_124a0b9d285.java) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:778) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:767) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:81) - org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85) - org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103) - $RequestHandler_124a0b9d287.service($RequestHandler_124a0b9d287.java) - $RequestHandler_124a0b9d27c.service($RequestHandler_124a0b9d27c.java) -
Updating Hibernate Entites
Hello List, i'm trying to update an Hibernate-Object but alway get an a different object with the same identifier value was already associated with the session: Exception. My Form-Code looks like: @Inject private ConfigurationDAO configDAO; @Persist @Property private Configuration config; void onSuccessFromConfigForm(){ config.setEditDate(new Date()); configDAO.doSave(config); } void onActivate(Long configId){ config=configDAO.doRetrieve(configId,false); } void onActivate(){ configs = configDAO.findAll(); if(config==null) config=new de.leomedia.leotipp.model.Configuration(); } can anyone give me a lead into the right direction? thanks, Dominik