tapestry-spring lazy initialize everything?
Using Tapestry 4.0.2 and this is much more a hivemind question really, but I wonder if anybody has tried to lazy initialize Tapestry-Spring. Currently, if I don't initialize Spring context at the start-up, Tapestry-Spring fails on ClassCastException. The use case I have is that I'm using Hibernate and I'd like to deploy a new version of the web application using hibernate.hbm2ddl.auto=validate. If the validation fails I'd just show a status message like "Sorry, we are down for maintenance" until the schema is updated, which I can in principle do if I delay creating the Spring context and (re-)initialize it at some point later. However, ApplicationServlet initialization fails when it tries to construct Hivemind registry. The service point SpringApplicationInitializer has been marked private so I can't override it externally. What I'm trying to do is to avoid granting rights to modify the schema for the webapp's normal database access account, and only update the scema externally with a different user credentials (more detailed post about Hibernate validation from Spring's perspective at http://forum.springframework.org/showthread.php?t=35274). Suppose I could implement a wrapper/extension for ApplicationServlet to catch the exception and make it able to re-initialize, but then I'm already implementing a wrapper for Spring context initializer and doing some other tricks to get Acegi filters to initialize lazily, so overall I'm wondering if I'm just complicating the design for nothing. Maybe somebody already has a solution with schema validation or can see some completely different, but simpler way to get to the same end result? Kalle
Tap 4 - dynamic page caching?
Hi, Is there such a possibility or is it possible to cache the tapestry dynamically generated pages? I tried searching on the tapestry wiki, though was unable to turn up any leads... There is a project called OSCache which says it can cache JSP content, is there such a tool for Tapestry, or has anyone used this for Tapestry? Thanks, Josh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: onActivate error handling?
The onActivate(Object[]) solution works well, thanks. I've opened an enhancement request in JIRA to track this change, too: https://issues.apache.org/jira/browse/TAPESTRY-1295 On 2/23/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: Yes, this is tricky and I'm thinking I'm not happy with the way it currently works. Your best option is to implement onActivate(Object[]) and do any coercions from there. This will be invoked regardless of the number of values in the context (even zero). I'm thinking the change will be: a method will be invoked if the context has at least as many values as the method has parameters, and will silently skip those that request too many. Nope, that still doesn't handle it for the common case that you want to catch the "no activation context" scenario. On 2/23/07, D&J Gredler <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using the activate / passivate infrastructure in T5, and have a question > about it. I have the following methods on a search page: > > public String onPassivate() { > return this.jurisdiction; > } > > public void onActivate(String jurisdiction) { > this.jurisdiction = jurisdiction; > } > > This works for URLs of the form "http://www.host.com/search/atlanta";. > However, if a user ever goes to "http://www.host.com/search";, he will get an > ugly error page for an IllegalArgumentException, with a message like "Method > com.of.pages.AbstractJurisdictionPage.onActivate(java.lang.String) has more > parameters than there are context values for this component event." > > I'd like to be able to handle this condition myself, and thought I might be > able to do so if I added a parameter-less onActivate( ) method, but no > cigar: > > public void onActivate() { > // redirect to home page, or use a default jurisdiction > } > > What are my options here? > > Daniel > -- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: application state object instantiation
What's needed is the equivalent of T4's @InjectStateFlag which provides a boolean for whether the state already exists or not, just so you can avoid incidentally createing the ASO. There simply isn't a way to do this in 5.0.2. ApplicationStateManager doesn't have the necessary API. On 2/23/07, D&J Gredler <[EMAIL PROTECTED]> wrote: Hi, I may be using the @ApplicationState annotation incorrectly, but I have "secured" pages that should only be accessible once a user has logged in. These pages have a User instance variable annotated with @ApplicationState: @ApplicationState private User user; This instance variable is always accessed via a getUser( ) accessor, in which I check that the user is not null before returning it. If the user is null, that would mean that the user has not yet logged in, and I need to redirect to the login page: public User getUser() throws IOException { if (this.user == null) { response.sendRedirect("/"); } return this.user; } Unfortunately, the ApplicationStateManager is instantiating the user instance variable behind the scenes. Is there a way to turn this off? Do I need to wrap my user in another object? Thanks, Daniel -- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: onActivate error handling?
Yes, this is tricky and I'm thinking I'm not happy with the way it currently works. Your best option is to implement onActivate(Object[]) and do any coercions from there. This will be invoked regardless of the number of values in the context (even zero). I'm thinking the change will be: a method will be invoked if the context has at least as many values as the method has parameters, and will silently skip those that request too many. Nope, that still doesn't handle it for the common case that you want to catch the "no activation context" scenario. On 2/23/07, D&J Gredler <[EMAIL PROTECTED]> wrote: Hi, I'm using the activate / passivate infrastructure in T5, and have a question about it. I have the following methods on a search page: public String onPassivate() { return this.jurisdiction; } public void onActivate(String jurisdiction) { this.jurisdiction = jurisdiction; } This works for URLs of the form "http://www.host.com/search/atlanta";. However, if a user ever goes to "http://www.host.com/search";, he will get an ugly error page for an IllegalArgumentException, with a message like "Method com.of.pages.AbstractJurisdictionPage.onActivate(java.lang.String) has more parameters than there are context values for this component event." I'd like to be able to handle this condition myself, and thought I might be able to do so if I added a parameter-less onActivate( ) method, but no cigar: public void onActivate() { // redirect to home page, or use a default jurisdiction } What are my options here? Daniel -- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: application state object instantiation
Hi, I may be using the @ApplicationState annotation incorrectly, but I have "secured" pages that should only be accessible once a user has logged in. These pages have a User instance variable annotated with @ApplicationState: @ApplicationState private User user; This instance variable is always accessed via a getUser( ) accessor, in which I check that the user is not null before returning it. If the user is null, that would mean that the user has not yet logged in, and I need to redirect to the login page: public User getUser() throws IOException { if (this.user == null) { response.sendRedirect("/"); } return this.user; } Unfortunately, the ApplicationStateManager is instantiating the user instance variable behind the scenes. Is there a way to turn this off? Do I need to wrap my user in another object? Thanks, Daniel
T5: onActivate error handling?
Hi, I'm using the activate / passivate infrastructure in T5, and have a question about it. I have the following methods on a search page: public String onPassivate() { return this.jurisdiction; } public void onActivate(String jurisdiction) { this.jurisdiction = jurisdiction; } This works for URLs of the form "http://www.host.com/search/atlanta";. However, if a user ever goes to "http://www.host.com/search";, he will get an ugly error page for an IllegalArgumentException, with a message like "Method com.of.pages.AbstractJurisdictionPage.onActivate(java.lang.String) has more parameters than there are context values for this component event." I'd like to be able to handle this condition myself, and thought I might be able to do so if I added a parameter-less onActivate( ) method, but no cigar: public void onActivate() { // redirect to home page, or use a default jurisdiction } What are my options here? Daniel
weird persister not found bug in hibernate introduced by recent-ish snapshot..
Hello list, A long shot... I've run into an issue and I could use some help. I have a hibernate/spring/tapestry 4(.1.2-SNAPSHOT) application that has worked well for may moons, esp. with respect to this one section of code that loads an object, saves it, and then moves on. I'm getting a Persister not found exception. I want to beleive this is caused by any number of the possible reasons this is usually caused by: no mapping file, etc. The error is below. Anyway, I've reverted to oldder versoins of the SNAPSHOTS: org.apache.tapestry tapestry-annotations 4.1.2-20070215.051249-11 org.apache.tapestry tapestry-framework 4.1.2-20070215.051249-15 org.apache.tapestry tapestry-contrib 4.1.2-20070215.051249-12 Now, the problem seems to be gone, and functioning. However this makes me think that the issue is in one of the subsequent upgrades (i've not managed to isolate it, just yet, as I purposely overshot the plausible dates to be sure i was _REVERTED_. Anyway, is it possible some sort of conflict has been introduced in tapestry 4 with spring, or hibernate 2.15x or, so on? Perhaps an upgraded dependency or something? I'm sorry if this isn't germaine to this list, or maybe I'm inflicting classpath heck on the list, but I think it's tapestry specific. To be sure, I extracted the relevant sequence (get dao, get domain object, save.) to a TestNG unit test and it ran without exception (no pun) there just fine... e$$EnhancerByCGLIB$$b2cd7e92 at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347) at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2691) at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2698) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1383) at org.springframework.orm.hibernate.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:592) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:364) at org.springframework.orm.hibernate.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:589) at mycompanyhere.model.impl.HibernateShopperDAOImpl.addRestaurantProfile(HibernateShopperDAOImpl.java:784) at mycompanyhere.model.impl.HibernateShopperDAOImpl.updateRestaurantProfile(HibernateShopperDAOImpl.java:788) at mycompanyhere.model.impl.HibernateShopperDAOImpl$$FastClassByCGLIB$$8854a40e.invoke() at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148) at mycompanyhere.model.impl.LoggerAdvice.invoke(LoggerAdvice.java:37) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643) at mycompanyhere.model.impl.HibernateShopperDAOImpl$$EnhancerByCGLIB$$b758edb.updateRestaurantProfile() at mycompanyhere.view.pages.subscribers.EditRestaurantProfile.pageBeginRender(EditRestaurantProfile.java:171) at org.apache.tapestry.AbstractPage.firePageBeginRender(AbstractPage.java:406) at org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:241) at org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:404) at org.apache.tapestry.services.impl.DefaultResponseBuilder.renderResponse(DefaultResponseBuilder.java:158) at org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:33) at $ResponseRenderer_110efd36343.renderResponse($ResponseRenderer_110efd36343.java) at org.apache.tapestry.engine.DirectService.service(DirectService.java:151) at $IEngineService_110efd363b5.service($IEngineService_110efd363b5.java) at org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72) at org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:246) at org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:54) at $WebRequestServicer_110efd3638d.service($WebRequestServicer_110efd3638d.java) at org.apache.tapestry.services.impl.DisableCachingFilter.service(DisableCachingFilter.java:54) at $WebRequestServicerFilter_110efd3638f.service($WebRequestServicerFilter_110efd3638f.java) at $WebRequestServicer_110efd36391.service($WebRequestServicer_110efd36391.java) at $WebRequestServicer_110efd36389.service($WebRequestServicer_110efd36389.java) Thanks in advance for your help! -- Joshua Lon
[JOB] Lucene
Any Lucene experts available for contract? Spring / Hibernate a big plus. Get in touch with me if interested. Steve Motola [EMAIL PROTECTED] (310) 422-5521 The Lab, LLC http://www.thelabllc.com Content is for intended recipient only. This message was sent using IMP, the Internet Messaging Program. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Page Validation
Hi, As an alternate approach you may override the default page source with an implementation that checks security constraints just before giving out the page instance - this basically has the added benefit that secured page instances may not be obtained even through (accidental) malicious code in non-secure pages or services. -- Overridden engine public class MyEngine extends BaseEngine { protected IPageSource createPageSource(RequestContext context) { return new ProtectedPageSource(this); } } -- Overridden page source public class ProtectedPageSource extends PageSource { public ProtectedPageSource(IEngine engine) { super(engine); } public IPage getPage(IRequestCycle cycle, String pageName, IMonitor monitor) { IPage page = super.getPage(cycle, pageName, monitor); if (page != null && page instanceof ProtectedPage) { Visit visit = (Visit) cycle.getEngine().getVisit(); if (visit == null || visit.getUser() == null) throw new PageRedirectException("Login"); } return page; } } -- A protected page public class ProtectedPage extends BasePage { } Something along those lines ;) Cheers, -- Nikla Mark Stang wrote: Hi, This seems to work for us. public class ValidatePage extends BasePage implements PageValidateListener { public void pageValidate(PageEvent event) { Mediator mediator = MgmtFactory.getMediator(); if (!mediator.isConsole()) { IPage messagePage = getRequestCycle().getPage("nonAdminConsole"); throw new PageRedirectException(messagePage); } else { // If there is no visit object or the user isn't auth'd ship // them off to the login page Visit visit = (Visit)getVisit(); if (visit == null || !visit.isUserAuthenticated()) { Login login = (Login)getRequestCycle().getPage("login"); throw new PageRedirectException(login); } } } } I tried a couple of different experiments. The first was to log in and copy a link then close the browser. I wasn't able to get to the page via the direct link. If I "logout" and try and access the page via a direct link, I don't get access. If I log in and copy a link and then surf off to another page, then I can come back via the direct link. All of this is based on my use of a session and the visit object. So, reviewing you code, I would think you need to have to check more than if the visit exists. You need to store a flag saying they they have been authenticated. regards, Mark Mark J. Stang Senior Engineer/Architect office: +1 303.468.2900 mobile: +1 303.507.2833 Ping Identity -Original Message- From: James Sherwood [mailto:[EMAIL PROTECTED] Sent: Fri 2/23/2007 6:34 AM To: Tapestry users Subject: Page Validation Hello, We use Tapestry 3.2 I have security (login) using PageValidateListener. The secure page in the site is called ISOPage which extends BasePage. I add the page validation using: public ISOPage(){ super(); addPageValidateListener(new PageValidationListener()); } The PageValidationListener class implements PageValidateListener and does security like this: if(visit.getUser() == null){ throw new PageRedirectException("UserLogin"); } This all works fine it seems unless a direct is involved. If I copy a directlink then try to access it without loggin in it shows me the page the directlink java code is on. The PageRedirectException does happen and if I refresh or try to go anywhere it sends me to the login but it still shows that page first. Any ideas? Thanks, James - 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: Page Validation
Hi, This seems to work for us. public class ValidatePage extends BasePage implements PageValidateListener { public void pageValidate(PageEvent event) { Mediator mediator = MgmtFactory.getMediator(); if (!mediator.isConsole()) { IPage messagePage = getRequestCycle().getPage("nonAdminConsole"); throw new PageRedirectException(messagePage); } else { // If there is no visit object or the user isn't auth'd ship // them off to the login page Visit visit = (Visit)getVisit(); if (visit == null || !visit.isUserAuthenticated()) { Login login = (Login)getRequestCycle().getPage("login"); throw new PageRedirectException(login); } } } } I tried a couple of different experiments. The first was to log in and copy a link then close the browser. I wasn't able to get to the page via the direct link. If I "logout" and try and access the page via a direct link, I don't get access. If I log in and copy a link and then surf off to another page, then I can come back via the direct link. All of this is based on my use of a session and the visit object. So, reviewing you code, I would think you need to have to check more than if the visit exists. You need to store a flag saying they they have been authenticated. regards, Mark Mark J. Stang Senior Engineer/Architect office: +1 303.468.2900 mobile: +1 303.507.2833 Ping Identity -Original Message- From: James Sherwood [mailto:[EMAIL PROTECTED] Sent: Fri 2/23/2007 6:34 AM To: Tapestry users Subject: Page Validation Hello, We use Tapestry 3.2 I have security (login) using PageValidateListener. The secure page in the site is called ISOPage which extends BasePage. I add the page validation using: public ISOPage(){ super(); addPageValidateListener(new PageValidationListener()); } The PageValidationListener class implements PageValidateListener and does security like this: if(visit.getUser() == null){ throw new PageRedirectException("UserLogin"); } This all works fine it seems unless a direct is involved. If I copy a directlink then try to access it without loggin in it shows me the page the directlink java code is on. The PageRedirectException does happen and if I refresh or try to go anywhere it sends me to the login but it still shows that page first. Any ideas? Thanks, James - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Page Validation
Hello, We use Tapestry 3.2 I have security (login) using PageValidateListener. The secure page in the site is called ISOPage which extends BasePage. I add the page validation using: public ISOPage(){ super(); addPageValidateListener(new PageValidationListener()); } The PageValidationListener class implements PageValidateListener and does security like this: if(visit.getUser() == null){ throw new PageRedirectException("UserLogin"); } This all works fine it seems unless a direct is involved. If I copy a directlink then try to access it without loggin in it shows me the page the directlink java code is on. The PageRedirectException does happen and if I refresh or try to go anywhere it sends me to the login but it still shows that page first. Any ideas? Thanks, James - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Variable number of rows with JSON - grid component
Hi, I've put together a small demo of a grid like html component which makes use of a JSON string in a hidden input field (tapestry component) to convey state between the client and server. http://cruise.sadalbari.com:8080/tapestry-prototypes/GridDemo.html Basically each entry in the grid is an ActionEntry (a javascript class which has its java counterpart on the server side). ActionEntries contain 3 fields 1) A unique id (this is a client assigned unique id) 2) An action (either ADD, UPDATE, DELETE or NONE) 3) An embedded object - which in this case is a GridEntry object with a code and amount Editing of the html entries fires javascript events which update the object model (in the client). When the user clicks "Save", the object model - an array of action entries is converted to a JSON String and submitted (using a tapestry form) to the server. On the server side, I manually convert the JSON string to an object graph and then apply the necc. changes (ADDING, UPDATING, DELETING etc) One big drawback is that because the component is dynamic HTML, I can't apply validation (and translation) using the normal tapestry mechanisms. I've hacked around this by including a hidden div containing an @TextField component which contains the same attributes (translators, validators) that I wish to apply to each of the amount input fields. So then on the server side (and this is where it gets ugly) I use this component to do translation and validation, catching the validation errors and populating a validation delegate. TextField comp = (TextField)component; Object object = comp.getTranslatedFieldSupport().parse(comp, jsonValue == JSONObject.NULL ? null : jsonValue.toString()); comp.getValidatableFieldSupport().validate(comp, null, cycle, object); I'm a newbie to tapestry and JSON - but am willing to share this contribution to anyone that may find it useful. I'd also like to improve on the validation - so if anyone has any suggestions on how do this in a more elegant manner let me know. Thanks -- Justin Walsh http://www.ewage.co.za - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Howto add additional packages with components
Thanks Howard, I got it working. The components cant be in the standard location because I have a jar file with common components for a few small tapestry applications. Well I could put them into the same package but I think its a little bit confusing when one package is filled from different locations (jar file and source folder). regards, Dennis Howard Lewis Ship wrote: > Contribute to the tapestry.ComponentClassResolver service's configuration. > > The contribution for the core library is: > > public static void > contributeComponentClassResolver(Configuration > configuration) > { > configuration.add(new LibraryMapping("core", > "org.apache.tapestry.corelib")); > } > > This maps the virtual folder "core" to the given package (with pages, > components, etc. packages beneath). > > You can define a new virtual folder this way, or extend an existing one. > > Why can't the components be in the standard location? > > > On 2/22/07, Dennis Kempin <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I want to make a bunch of components available to my application, but >> these are not inside the [root].components package. How can i add >> additonal packages to the search path for components? >> >> thanks, >> Dennis >> >> >> - >> 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]