Re: How to stay on same page
Hi Ken! Can you paste your onPassivate method? Maybe you always return Team.class as context parameter instead of beanType member? I expect you want to see the selection in the URL like: query/team right? Than you need an proper on activate, too. So if you use your enum ReportType in onPassivate you can use it in onActivate(ReportType rt) later and load the list here? Jens Jens Sent from my iPhone On 13.05.2013, at 05:42, nhhockeyplayer nashua nhhockeypla...@hotmail.com wrote: Hi Folks, I created a page called Query. http://powerplayhockey.noip.us:9011/pphl/query It offers two things to the user... a select component and a grid. My select has two options... TEAM or PLAYER. So I toggle my beanType to Team.class or Player.class and render a grid based on the collection I pull out of the database. I am having an issue though. On the submit form method, it currently returns nothing. @OnEvent(value = go) void submit() { logger.debug(In submit : ); switch (reportType) { case TEAM: beanType = Team.class; break; case PLAYER: beanType = Team.class; break; default: } collection = loadCollection(beanType); } Maybe I can return THIS... Currently it seems to be taking me to http://powerplayhockey.noip.us:9011/team Thanks for any tips. Best regards and thanks... KEN - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
how to use HibernateEntityValueEncoder
Hi Folks, Finding scant docs on this class usage. And getting pulled down a rabbit hole. Are there any example usages of this ? All i want to do is populate my select component with database entities strings. thanks
Re: Tapestry Hibernate Session usage
On Mon, May 13, 2013 at 2:59 AM, Boris Horvat horvat.z.bo...@gmail.comwrote: Hi all, Hi! I have a question about what should be the best way to use hibernate session in tapestry. My environment consists of 2 layers (relevant to this). The first one would be a group of classes that represent an access point to a table. For example if I have a table student then I will have a class DAOHibernateStudent. This class receives Session object in its constructor. Doing it this way I can separate all of the queries that are available for that table into its own class. Thats strange naming, I would name the interface as StudentDAO, and implementation as just StudentDAOImpl. Note that you can also @Inject session to your DAO, you don't have to pass it through the constructor. Btw, in my projects I never put @CommitAfter annotations in this layer. In this case I can do more than one DAO-method-call in a single transaction. The second layer is a class called Manager that implements business logic. This layer has fields that represent different DAOHibernate* classes. They are all passed down using constructor. This way I can keep my business logic in a special class which will communicate with different table using different DAOHibernate* objects Again, you don't have to pass DAO instances via constructor, use @Inject. Having one big Manager class looks like God Object anti-pattern to me -- http://en.wikipedia.org/wiki/God_object I usually have one Manager class per table, so in it would be named StudentManager in your case. Its okay having multiple different DAO instances to be injected in this ConcreteManager class also, as well as another manager classes if you wish. Usually I put most of @CommitAfter annotations on this layer, some of them goes to page classes event handlers directly. Depends on use-case. I use @Inject annotation to inject manager into a page Lets imagine that I want to create a new Student. So my code would call a Manager's method createStudent(some data) which would then use a few of the DAO classes to do all sorts of stuff (e.g. create a student, register subjects for him, assign him a mentor, add him to a student group, send notification email and so on...). The problem that I see here is that since all of those DAO classes are independent I need to use few Session objects as each one will receive its own session object. So here are my questions. As far as I know in tapestry there is only one instance of Session object per request (at least by default) -- its a per-thread proxy. And this Session instance is shared across all your DAO/Manager instances. 1. Will every time when someone loads/refreshes/opens the page a new Manager class be created which will in return create a new DAOHibernate* objects and each one will receive a new Session object? There are only two scopes for tapestry services now: SINGLETON and PERTRHEAD http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/ScopeConstants.html So if you bind your service via AppModule then by default you declare singleton instance. So only one instance of your Manager/DAO classes will be created and injected to your page instance. Btw, there's also only once instance of your page class will be created and shared across all requests. 2. Is it a good idea to use different session objects for the same transaction I guess (yea I know that it is not good idea so moving to the next question) As I said above, you usually have one Session object per request, and its okay. Since you will use single session instance you will have common first-level cache for all your request-scoped-queries, which is also good, I think. 3. How should this problem be solved? Should I pass new session object to manager and then pass it as a method parameter to the DAOHibernate* Leave session management to tapestry and only think about transaction scope, i.e. where to put @CommitAfter annotations. Use @Inject to inject sessions and other tapestry services to your classes. 4. Any general tips about this approach? Thanks all, Cheers -- Sincerely *Boris Horvat* -- Dmitry Gusev AnjLab Team http://anjlab.com
Re: hover pop show image widget
Hi Ken! I use bootstrap / tapestry-jquery for this. See: http://tapestry5-jquery.com/mixins/docstooltip Sent from my iPhone On 13.05.2013, at 04:29, nhhockeyplayer nashua nhhockeypla...@hotmail.com wrote: Hi Folks, Is there a hover show widget? Something like what netflix does when you hover over a movie, it produces a dialogue with image and details ? I would like to add something like this to my grid items when a user hovers over an id or a photo. Best regards and thanks... KEN - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Strategy for dealing with stale sessions?
My application is heavily dependent on state using @Persist annotations. If a user gets the application into a certain state, then their session becomes stale (i.e. they leave their computer for half an hour), what is the preferred approach for graceful recovery of the application now that the Persistent fields are null?
Re: how to use HibernateEntityValueEncoder
On Mon, 13 May 2013 04:44:36 -0300, Ken in Nashua kcola...@live.com wrote: Hi Folks, Hi! Finding scant docs on this class usage. And getting pulled down a rabbit hole. Are there any example usages of this ? All i want to do is populate my select component with database entities strings. HibernateEntityValueEncoder is used automatically. All you need to do is to have tapestry-hibernate in your classpath. For populating Select's model parameter, you can use the SelectModelFactory service. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: how to use HibernateEntityValueEncoder
In case you exclusively want to get the encoder, you can inject ComponentDefaultProvider and then use http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ComponentDefaultProvider.html#defaultValueEncoder(java.lang.String, org.apache.tapestry5.ComponentResources) regards Taha On 13-May-2013, at 4:59 PM, Thiago H de Paula Figueiredo thiag...@gmail.com wrote: On Mon, 13 May 2013 04:44:36 -0300, Ken in Nashua kcola...@live.com wrote: Hi Folks, Hi! Finding scant docs on this class usage. And getting pulled down a rabbit hole. Are there any example usages of this ? All i want to do is populate my select component with database entities strings. HibernateEntityValueEncoder is used automatically. All you need to do is to have tapestry-hibernate in your classpath. For populating Select's model parameter, you can use the SelectModelFactory service. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: How do you remove link Parameters generically?
Hi Barry I've been using a different workaround for this and maybe it could help you. You can listen for the DECORATE_PAGE_RENDER_LINK and then decorate the link as you want. Add something like this to your page. @OnEvent(EventConstants.DECORATE_PAGE_RENDER_LINK) void decoratePageRenderLink(Link link, PageRenderRequestParameters parameters) { if (parameters.getLogicalPageName().equals(YOUR_LOGICAL_PAGE_NAME)) { for (String name : link.getParameterNames()) { link.removeParameter(name); } } } Cheers. Alejandro. On Thu, May 9, 2013 at 2:44 PM, Barry Books trs...@gmail.com wrote: I am using @ActivationRequestParameter and perhaps this is feature under some circumstances but currently it seems like a bug to me. In this case I have a menu item called 'All Prints' that goes to a page that might set ARP fields from a search. I'd like the menu link to always go to the page without any url parameters so that it will show All Prints. If I just had a simple PageLink I could just set parameters={'tag'='All'} but the menu links come from a database so they can be dynamically added. I did get it to work as I wanted by adding a context of 'All' the pagelink and then set tag to null in begin render. The only think I don't like about that is the URL ends up being: /studio/work/All?tag=Paris (best case would be /studio/work?tag=All which I don't really care for either) I suspect I'll really fix this by hardcoding a URL in the database and just using a href=/studio/work/ but that seems wrong. I guess it comes down to what PageLink should do. I view it as a way to go to some arbitrary page with a set of arguments I specify. I'm OK with leaving context and parameters empty and Tapestry providing defaults but it seems like if I supply a value it should use that and only that. I suppose there may be other cases where this functionality is useful but I can't think of any off hand. Perhaps if parameters=null or parameters={} would just remove all parameters that might be OK and would solve the common case of: 1. A menu item linking to a page that shows a bunch of things 2. The page has search parameters to narrow the list and uses ARP to store them The menu link does not need to know (and should not know) what the possible set of search criteria is, it just wants to turn them all off. The search page can handle them using EventLink to clear individual ones. On Wed, May 8, 2013 at 7:06 PM, Howard Lewis Ship hls...@gmail.com wrote: I suspect you are using @ActivationRequestParameter annotatations and that is the source of your sticky query parameters. It may be a bug that you explicitly supply an empt parameters map to the PageLink and it still adds the ARP in, but that is likely a feature. To accomplish what you want, you may need to set the ARP fields to null inside beginRender(). On Wed, May 8, 2013 at 6:02 AM, Barry Books trs...@gmail.com wrote: I've got a menu item generated from a database with a pagelink like this t:pagelink page=prop:drop.page context=dropContext style=${drop.style} ${drop.label}/t:pagelink I've added a search function to one of the linked pages that adds parameters to the URL with t:pagelink ... parameters=searchPage/t:pagelink I'd like to make the menu item clear the search so I tried this: t:pagelink page=prop:drop.page context=dropContext style=${drop .style} parameters={}${drop.label}/t:pagelink but it does not work. It seems Tapestry is clever enough to always add my search criteria to the parameter map. This would be easy enough to fix if my menu was not driven from a database but I don't see an easy to make my generic menu know how to fix this. It would seem useful to be able to say t:pagelink ... parameters=nullPage/t:pagelink but parameters cannot be set to null. Any suggestions? -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com
Re: How do you remove link Parameters generically?
Thanks, That does exactly what I needed. It appears to be called before the new parameters are added so it lets you remove the defaults. On Mon, May 13, 2013 at 7:27 AM, Alejandro Scandroli alejandroscandr...@gmail.com wrote: Hi Barry I've been using a different workaround for this and maybe it could help you. You can listen for the DECORATE_PAGE_RENDER_LINK and then decorate the link as you want. Add something like this to your page. @OnEvent(EventConstants.DECORATE_PAGE_RENDER_LINK) void decoratePageRenderLink(Link link, PageRenderRequestParameters parameters) { if (parameters.getLogicalPageName().equals(YOUR_LOGICAL_PAGE_NAME)) { for (String name : link.getParameterNames()) { link.removeParameter(name); } } } Cheers. Alejandro. On Thu, May 9, 2013 at 2:44 PM, Barry Books trs...@gmail.com wrote: I am using @ActivationRequestParameter and perhaps this is feature under some circumstances but currently it seems like a bug to me. In this case I have a menu item called 'All Prints' that goes to a page that might set ARP fields from a search. I'd like the menu link to always go to the page without any url parameters so that it will show All Prints. If I just had a simple PageLink I could just set parameters={'tag'='All'} but the menu links come from a database so they can be dynamically added. I did get it to work as I wanted by adding a context of 'All' the pagelink and then set tag to null in begin render. The only think I don't like about that is the URL ends up being: /studio/work/All?tag=Paris (best case would be /studio/work?tag=All which I don't really care for either) I suspect I'll really fix this by hardcoding a URL in the database and just using a href=/studio/work/ but that seems wrong. I guess it comes down to what PageLink should do. I view it as a way to go to some arbitrary page with a set of arguments I specify. I'm OK with leaving context and parameters empty and Tapestry providing defaults but it seems like if I supply a value it should use that and only that. I suppose there may be other cases where this functionality is useful but I can't think of any off hand. Perhaps if parameters=null or parameters={} would just remove all parameters that might be OK and would solve the common case of: 1. A menu item linking to a page that shows a bunch of things 2. The page has search parameters to narrow the list and uses ARP to store them The menu link does not need to know (and should not know) what the possible set of search criteria is, it just wants to turn them all off. The search page can handle them using EventLink to clear individual ones. On Wed, May 8, 2013 at 7:06 PM, Howard Lewis Ship hls...@gmail.com wrote: I suspect you are using @ActivationRequestParameter annotatations and that is the source of your sticky query parameters. It may be a bug that you explicitly supply an empt parameters map to the PageLink and it still adds the ARP in, but that is likely a feature. To accomplish what you want, you may need to set the ARP fields to null inside beginRender(). On Wed, May 8, 2013 at 6:02 AM, Barry Books trs...@gmail.com wrote: I've got a menu item generated from a database with a pagelink like this t:pagelink page=prop:drop.page context=dropContext style=${drop.style} ${drop.label}/t:pagelink I've added a search function to one of the linked pages that adds parameters to the URL with t:pagelink ... parameters=searchPage/t:pagelink I'd like to make the menu item clear the search so I tried this: t:pagelink page=prop:drop.page context=dropContext style=${drop .style} parameters={}${drop.label}/t:pagelink but it does not work. It seems Tapestry is clever enough to always add my search criteria to the parameter map. This would be easy enough to fix if my menu was not driven from a database but I don't see an easy to make my generic menu know how to fix this. It would seem useful to be able to say t:pagelink ... parameters=nullPage/t:pagelink but parameters cannot be set to null. Any suggestions? -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com
Re: Strategy for dealing with stale sessions?
I think this is an application-specific question. When the application server's underlying session expires, all your @Persisted fields become null, as you say. If the user continues, it's just as if a random, unknown user arrived and attempted to start interacting with your application somewhere deep inside. Presumably you need to gracefully direct them to the start of your application, where you can (potentially authenticating them first) start setting persistent state once more. An alternative would be for you to use a different persistence strategy other than 'session'. The wiki has an example of a cookie-based strategy (link below). Another option would be some sort of database storage. You stick a key in the session or a cookie, and this is used to look up the rest of the state, which is stored in something more long term, like a database. If the session expires, then when they re-authenticate, you can associate the new session with the key they were using last time. On 13 May 2013 06:24, Ben Titmarsh ben.titma...@hotmail.co.uk wrote: My application is heavily dependent on state using @Persist annotations. If a user gets the application into a certain state, then their session becomes stale (i.e. they leave their computer for half an hour), what is the preferred approach for graceful recovery of the application now that the Persistent fields are null?
Re: Strategy for dealing with stale sessions?
FlowLogix library handles this generically by reloading the page if session expired. Take a look specifically at @AJAX annotation. http://code.google.com/p/flowlogix/wiki/TapestryLibrary http://code.google.com/p/flowlogix/wiki/TLAJAXAnnotation On May 13, 2013, at 6:24 AM, Ben Titmarsh ben.titma...@hotmail.co.uk wrote: My application is heavily dependent on state using @Persist annotations. If a user gets the application into a certain state, then their session becomes stale (i.e. they leave their computer for half an hour), what is the preferred approach for graceful recovery of the application now that the Persistent fields are null? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: how to use HibernateEntityValueEncoder
thanks guys... but I keep gettign an NPE @Persist @Property HibernateEntityValueEncoderYear yearValueEncoder; @Inject private ValueEncoderSource valueEncoderSource; @Inject private SelectModelFactory selectModelFactory; private ArrayList years; @SetupRender void setupRender() { years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearSelectModel = selectModelFactory.create(years, year); } my selectModelFactory fails Any ideas ? An unexpected application exception has occurred.org.apache.tapestry5.internal.services.RenderQueueExceptionRender queue error in SetupRender[pphl/Query]: org.apache.tapestry5.ioc.internal.util.TapestryExceptionactiveComponentspphl/Query (class org.tynamo.examples.pphl.pages.Query)org.apache.tapestry5.ioc.internal.util.TapestryExceptionjava.lang.NullPointerExceptionFilter stack frames Stack trace org.apache.tapestry5.internal.services.SelectModelFactoryImpl.create(SelectModelFactoryImpl.java:55) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java:200) org.tynamo.examples.pphl.pages.Query.advised$setupRender_844d26137ccc(Query.java) org.tynamo.examples.pphl.pages.Query$Invocation_setupRender_844d26137ccb.proceedToAdvisedMethod(Unknown Source) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84) org.got5.tapestry5.jquery.services.ImportJQueryUIWorker$2.advise(ImportJQueryUIWorker.java:94) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181) org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72) org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124) org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
RE: How to stay on same page
Thnanks jens Here is my passivate @OnEvent(EventConstants.PASSIVATE) Object[] passivate() {return new Object[] { beanType }; } but I toggle it when I hit submit @OnEvent(value = go) public Object submit() { logger.debug(In submit : ); switch (reportType) { case TEAM: beanType = Team.class; break; case PLAYER: beanType = Player.class; break; default: } beanCollection = TynamoUTIL.loadCollection(hibernatePersistenceService, beanType); return this; }
RE: how to use HibernateEntityValueEncoder
Here is the tml tr align=left td align=center select t:type=Select t:id=yearSelect t:clientId=yearSelect id=yearSelect t:model=prop:yearSelectModel t:encoder=prop:yearValueEncoder t:value=prop:year blankOption=never / /td How do I know which valuencoder its using? Why the NPE ?
Re: how to use HibernateEntityValueEncoder
Please copy stack traces from the console, not the error page. On Mon, 13 May 2013 16:00:50 -0300, Ken in Nashua kcola...@live.com wrote: thanks guys... but I keep gettign an NPE @Persist @Property HibernateEntityValueEncoderYear yearValueEncoder; @Inject private ValueEncoderSource valueEncoderSource; @Inject private SelectModelFactory selectModelFactory; private ArrayList years; @SetupRender void setupRender() { years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearSelectModel = selectModelFactory.create(years, year); } my selectModelFactory fails Any ideas ? An unexpected application exception has occurred.org.apache.tapestry5.internal.services.RenderQueueExceptionRender queue error in SetupRender[pphl/Query]: org.apache.tapestry5.ioc.internal.util.TapestryExceptionactiveComponentspphl/Query (class org.tynamo.examples.pphl.pages.Query)org.apache.tapestry5.ioc.internal.util.TapestryExceptionjava.lang.NullPointerExceptionFilter stack frames Stack trace org.apache.tapestry5.internal.services.SelectModelFactoryImpl.create(SelectModelFactoryImpl.java:55) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java:200) org.tynamo.examples.pphl.pages.Query.advised$setupRender_844d26137ccc(Query.java) org.tynamo.examples.pphl.pages.Query$Invocation_setupRender_844d26137ccb.proceedToAdvisedMethod(Unknown Source) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84) org.got5.tapestry5.jquery.services.ImportJQueryUIWorker$2.advise(ImportJQueryUIWorker.java:94) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181) org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72) org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124) org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37) -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: how to use HibernateEntityValueEncoder
By the way, do you really have an Year class? Why? On Mon, 13 May 2013 16:00:50 -0300, Ken in Nashua kcola...@live.com wrote: thanks guys... but I keep gettign an NPE @Persist @Property HibernateEntityValueEncoderYear yearValueEncoder; @Inject private ValueEncoderSource valueEncoderSource; @Inject private SelectModelFactory selectModelFactory; private ArrayList years; @SetupRender void setupRender() { years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearSelectModel = selectModelFactory.create(years, year); } my selectModelFactory fails Any ideas ? An unexpected application exception has occurred.org.apache.tapestry5.internal.services.RenderQueueExceptionRender queue error in SetupRender[pphl/Query]: org.apache.tapestry5.ioc.internal.util.TapestryExceptionactiveComponentspphl/Query (class org.tynamo.examples.pphl.pages.Query)org.apache.tapestry5.ioc.internal.util.TapestryExceptionjava.lang.NullPointerExceptionFilter stack frames Stack trace org.apache.tapestry5.internal.services.SelectModelFactoryImpl.create(SelectModelFactoryImpl.java:55) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java:200) org.tynamo.examples.pphl.pages.Query.advised$setupRender_844d26137ccc(Query.java) org.tynamo.examples.pphl.pages.Query$Invocation_setupRender_844d26137ccb.proceedToAdvisedMethod(Unknown Source) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84) org.got5.tapestry5.jquery.services.ImportJQueryUIWorker$2.advise(ImportJQueryUIWorker.java:94) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181) org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72) org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124) org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37) -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: how to use HibernateEntityValueEncoder
whats so bad about a year class ? @Entity @ClassDescriptor(hasCyclicRelationships = true, nonVisual = false) public class Year implements Cloneable, Serializable { private static final Log log = LogFactory.getLog(Year.class); private Integer id = null; private Integer yearStart = new Integer(0); private Integer yearEnd = new Integer(0); private League league = null; private Long created = new Long(GregorianCalendar.getInstance() .getTimeInMillis()); private Long accessed = new Long(GregorianCalendar.getInstance() .getTimeInMillis()); /** * CTOR */ public Year() { } public Year(Year dto) { try { BeanUtils.copyProperties(this, dto); } catch (Exception e) { log.error(e.toString()); e.printStackTrace(); } } /** * Accessor for id * * @return Integer * @hibernate.id generator-class=increment unsaved-value=-1 * type=java.lang.Integer unique=true insert=true */ @Id @GeneratedValue(strategy = GenerationType.AUTO) @PropertyDescriptor(readOnly = true) public Integer getId() { return id; } @PropertyDescriptor public Integer getYearStart() { return yearStart; } @PropertyDescriptor public Integer getYearEnd() { return yearEnd; } @ManyToOne public League getLeague() { return league; } @PropertyDescriptor(nonVisual = true, searchable = false) public Long getCreated() { return created; } @PropertyDescriptor(nonVisual = true, searchable = false) public Long getAccessed() { return accessed; } @Transient @PropertyDescriptor(nonVisual = true, searchable = false) public String getCreatedAsString() { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(created.longValue()); return DatePattern.sdf.format(cal.getTime()); } @Transient @PropertyDescriptor(nonVisual = true, searchable = false) public String getAccessedAsString() { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(accessed.longValue()); return DatePattern.sdf.format(cal.getTime()); } public void setId(Integer id) { this.id = id; } public void setYearStart(Integer yearStart) { this.yearStart = yearStart; } public void setYearEnd(Integer yearEnd) { this.yearEnd = yearEnd; } public void setLeague(League league) { this.league = league; } @Transient @PropertyDescriptor(nonVisual = true, searchable = false) public void setCreatedAsString(String value) throws Exception { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(DatePattern.sdf.parse(value).getTime()); this.created = new Long(cal.getTimeInMillis()); } @Transient @PropertyDescriptor(nonVisual = true, searchable = false) public void setAccessedAsString(String value) throws Exception { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(DatePattern.sdf.parse(value).getTime()); this.accessed = new Long(cal.getTimeInMillis()); } public void setAccessed(Long accessed) { this.accessed = accessed; } public void setCreated(Long created) { this.created = created; } @Override public int hashCode() { return (getId() != null ? getId().hashCode() : 0); } @Override public Year clone() { return new Year(this); } /** * equals and hashCode need to be hammered out for hibernate to work * properly * * Check the matrix summary for best practices at * http://www.hibernate.org/109.html */ @Override public boolean equals(Object rhs) { if (this == rhs) return true; // instance equality if (rhs == null || getClass() != rhs.getClass()) return false; // null/class equality final Year castedObject = (Year) rhs; return !(getId() != null ? !getId().equals(castedObject.getId()) : castedObject.getId() != null); } public String toString() { return getYearStart().toString() + / + getYearEnd().toString(); } }
Re: Tapestry Hibernate Session usage
Hi Dmitry Please ignore the naming as I haven't really user he real names here as this is just an example (the project also has nothing to do with Students but it is easier for the explanations :) ). In all fairness though I do prefer to append DAOService in front as it allows me to search for the class more easily (If my page, service and domain class all start with Student it is annoying to find anything) The @CommitAfter it is my manager that has this class not the DAO's so I guess why use the same approach As for the constructor and @Inject annotation I know that I can use it but in that way I restrain my self to Tapestry (or Spring), which is not the case if I use constructor. I am aware of the God anti pattern and while there is fine line between that and my code I dont think I have crossed it as I have more then one manager. They represent an area of business logic and basically they are place where transaction annotation is put. Still it is something to keep in mind I agree. I think now I understand a bit more about the Session object in Tapestry. So yes if it is shard across all of my DAO object that would be what the behavior what I need. Do you know any place where I can read a bit about it? I am interested it as from what I can see in my code constructor is only called once (you also confirmed this) so I was wondering how does it switch the Session object each time? You mention it is a proxy so I guess that is how it replaces it, right? Thanks for the reply, Cheers, Boris On Mon, May 13, 2013 at 10:09 AM, Dmitry Gusev dmitry.gu...@gmail.comwrote: On Mon, May 13, 2013 at 2:59 AM, Boris Horvat horvat.z.bo...@gmail.com wrote: Hi all, Hi! I have a question about what should be the best way to use hibernate session in tapestry. My environment consists of 2 layers (relevant to this). The first one would be a group of classes that represent an access point to a table. For example if I have a table student then I will have a class DAOHibernateStudent. This class receives Session object in its constructor. Doing it this way I can separate all of the queries that are available for that table into its own class. Thats strange naming, I would name the interface as StudentDAO, and implementation as just StudentDAOImpl. Note that you can also @Inject session to your DAO, you don't have to pass it through the constructor. Btw, in my projects I never put @CommitAfter annotations in this layer. In this case I can do more than one DAO-method-call in a single transaction. The second layer is a class called Manager that implements business logic. This layer has fields that represent different DAOHibernate* classes. They are all passed down using constructor. This way I can keep my business logic in a special class which will communicate with different table using different DAOHibernate* objects Again, you don't have to pass DAO instances via constructor, use @Inject. Having one big Manager class looks like God Object anti-pattern to me -- http://en.wikipedia.org/wiki/God_object I usually have one Manager class per table, so in it would be named StudentManager in your case. Its okay having multiple different DAO instances to be injected in this ConcreteManager class also, as well as another manager classes if you wish. Usually I put most of @CommitAfter annotations on this layer, some of them goes to page classes event handlers directly. Depends on use-case. I use @Inject annotation to inject manager into a page Lets imagine that I want to create a new Student. So my code would call a Manager's method createStudent(some data) which would then use a few of the DAO classes to do all sorts of stuff (e.g. create a student, register subjects for him, assign him a mentor, add him to a student group, send notification email and so on...). The problem that I see here is that since all of those DAO classes are independent I need to use few Session objects as each one will receive its own session object. So here are my questions. As far as I know in tapestry there is only one instance of Session object per request (at least by default) -- its a per-thread proxy. And this Session instance is shared across all your DAO/Manager instances. 1. Will every time when someone loads/refreshes/opens the page a new Manager class be created which will in return create a new DAOHibernate* objects and each one will receive a new Session object? There are only two scopes for tapestry services now: SINGLETON and PERTRHEAD http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/ScopeConstants.html So if you bind your service via AppModule then by default you declare singleton instance. So only one instance of your Manager/DAO classes will be created and injected to your page instance. Btw, there's also only once instance of your page class will be created and shared across all
Re: how to use HibernateEntityValueEncoder
Hi Ken! Just a shot in the dark: Are you sure the PKs of your hibernate beans are not null (maybe you have a newly created bean instance which is not persited yet)? Afair the HibernateValueEncoder requires properly filled PK fields otherwise pk.toString() fails. Unfortunately the stacktrace is difficult to read... Jens Sent from my iPhone On 13.05.2013, at 21:00, Ken in Nashua kcola...@live.com wrote: thanks guys... but I keep gettign an NPE @Persist @Property HibernateEntityValueEncoderYear yearValueEncoder; @Inject private ValueEncoderSource valueEncoderSource; @Inject private SelectModelFactory selectModelFactory; private ArrayList years; @SetupRender void setupRender() { years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearSelectModel = selectModelFactory.create(years, year); } my selectModelFactory fails Any ideas ? An unexpected application exception has occurred.org.apache.tapestry5.internal.services.RenderQueueExceptionRender queue error in SetupRender[pphl/Query]: org.apache.tapestry5.ioc.internal.util.TapestryExceptionactiveComponentspphl/Query (class org.tynamo.examples.pphl.pages.Query)org.apache.tapestry5.ioc.internal.util.TapestryExceptionjava.lang.NullPointerExceptionFilter stack frames Stack trace org.apache.tapestry5.internal.services.SelectModelFactoryImpl.create(SelectModelFactoryImpl.java:55) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java:200) org.tynamo.examples.pphl.pages.Query.advised$setupRender_844d26137ccc(Query.java) org.tynamo.examples.pphl.pages.Query$Invocation_setupRender_844d26137ccb.proceedToAdvisedMethod(Unknown Source) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84) org.got5.tapestry5.jquery.services.ImportJQueryUIWorker$2.advise(ImportJQueryUIWorker.java:94) org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86) org.tynamo.examples.pphl.pages.Query.setupRender(Query.java) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133) org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181) org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72) org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124) org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37) - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: how to use HibernateEntityValueEncoder
Hi Thiago, Here is the console... after I induce the NPE. 2013-05-13 16:11:14.622:INFO:oejs.Server:jetty-7.6.0.v20120127 2013-05-13 16:11:22.970:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one. 2013-05-13 16:11:23.424:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/C:/Prototype/Mavenized/Product/tynamo/trunk/tynamo-examples/pphl/src/main/webapp/},file:/C:/Prototype/Mavenized/Product/tynamo/trunk/tynamo-examples/pphl/src/main/webapp/ 2013-05-13 16:11:29.726:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080 [INFO] Started Jetty Server 127.0.0.1 - - [13/May/2013:20:11:34 +] GET /pphl/login HTTP/1.1 200 3301 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/core/default.css HTTP/1.1 200 2089 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/kawwa2_asset/css/k-structure.css HTTP/1.1 200 990 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/core/tree.css HTTP/1.1 200 570 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/core/t5-alerts.css HTTP/1.1 200 386 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/core/tapestry-console.css HTTP/1.1 200 322 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/form.css HTTP/1.1 200 77 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/kawwa2_asset/css/library.css HTTP/1.1 200 137 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/facebook/components/fb-button.css HTTP/1.1 200 1395 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/tap-jquery/tapestry.js HTTP/1.1 200 1739 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/openid-0.2.1-SNAPSHOT-1367865189000/components/button.css HTTP/1.1 200 1429 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/ui_1_8_24/jquery.ui.widget.js HTTP/1.1 200 2344 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/ui_1_8_24/jquery.ui.core.js HTTP/1.1 200 3439 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/ui_1_8_24/jquery.ui.position.js HTTP/1.1 200 2772 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/jquery.effects.show.js HTTP/1.1 200 105 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/ui_1_8_24/jquery.effects.highlight.js HTTP/1.1 200 608 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/jquery.json-2.2.js HTTP/1.1 200 1930 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET /assets/1.0-SNAPSHOT-1368475842243/jquery/ui_1_8_24/jquery.effects.core.js HTTP/1.1 200 5436 http://localhost:8080/pphl/login; Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 127.0.0.1 - - [13/May/2013:20:11:38 +] GET
RE: how to use HibernateEntityValueEncoder
Thanks Jens... I just stepped thru debugger... @SetupRender void setupRender() { grid.reset(); years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearValueEncoder = new EnumValueEncoder(typeCoercer, Year.class); this is what the debugger shows for my years collection after loadCollection gets called. [2012/2013] Thats an entity... Year.class... the toString method So the collection is populating properly. Its stored with standard hibernate Integer id. Kinda blue in the face... kinda
RE: how to use HibernateEntityValueEncoder
Ooops... this is the code I am exercising... @Persist @Property private EnumValueEncoder yearValueEncoder; @Inject @Property private TypeCoercer typeCoercer; @Inject private SelectModelFactory selectModelFactory; @Property private SelectModel yearSelectModel; @Property @Persist(PersistenceConstants.FLASH) private Year year; @SetupRender void setupRender() { grid.reset(); years = new ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class)); yearValueEncoder = new EnumValueEncoder(typeCoercer, Year.class); yearSelectModel = selectModelFactory.create(years, year);
RE: how to use HibernateEntityValueEncoder
Thanks Jens... I believe I posted the Year.class for Thiago the primary keye is just ID Is this a bug ? I would like to get into the create routine for the factory but dont know how
Re: how to use HibernateEntityValueEncoder
On Mon, 13 May 2013 17:15:05 -0300, Ken in Nashua kcola...@live.com wrote: Hi Thiago, Here is the console... after I induce the NPE. It doesn't contain the stack trace, so it's completely useless. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: how to use HibernateEntityValueEncoder
its obviously happening on the valueencoder final PropertyAdapter propertyAdapter = classPropertyAdapter.getPropertyAdapter(labelProperty);5455final ValueEncoder encoder = this.valueEncoderSource.getValueEncoder(propertyAdapter.getType());56 I changed the property method to toString() and it still fails with NPE
RE: Strategy for dealing with stale sessions?
Lenny, George, Thanks for the replies. I actually left a somewhat crucial piece of information out of my initial post in that I am talking specifically about Ajax! So Lenny this library looks fantastic, exactly what I was looking for! CC: users@tapestry.apache.org From: lpri...@hope.nyc.ny.us Subject: Re: Strategy for dealing with stale sessions? Date: Mon, 13 May 2013 11:44:45 -0400 To: users@tapestry.apache.org FlowLogix library handles this generically by reloading the page if session expired. Take a look specifically at @AJAX annotation. http://code.google.com/p/flowlogix/wiki/TapestryLibrary http://code.google.com/p/flowlogix/wiki/TLAJAXAnnotation On May 13, 2013, at 6:24 AM, Ben Titmarsh ben.titma...@hotmail.co.uk wrote: My application is heavily dependent on state using @Persist annotations. If a user gets the application into a certain state, then their session becomes stale (i.e. they leave their computer for half an hour), what is the preferred approach for graceful recovery of the application now that the Persistent fields are null? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: how to use HibernateEntityValueEncoder
Hi Ken, please paste the whole Bean class, too. I got an NPE in the past due to an leading underscore in my pk member name. _pk -- NPE pk -- works fine. Guess this is a bug, because Tapestry in general is happy with _ when accessing properties. Jens Am 13.05.13 23:26, schrieb Ken in Nashua: its obviously happening on the valueencoder final PropertyAdapter propertyAdapter = classPropertyAdapter.getPropertyAdapter(labelProperty);5455final ValueEncoder encoder = this.valueEncoderSource.getValueEncoder(propertyAdapter.getType());56 I changed the property method to toString() and it still fails with NPE - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org