Re: ajaxformloop and localization
I added @Persist on both source and value, now fields persist between languages. But localization switching reload the page, so I assume if I want the field that were filled to stay filled at language switching I need to put on all my Property with @Persist and refill each field in SetupRender, right ? Is this possible to have localization switchin without page reloading, and only the labels ajaxly updated ? 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com : On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . squall...@gmail.com wrote: Still, in the Client entity that i will persist at the submit, I store my contacts in it : // when adding a contact row Object onAddRowFromContacts() { ContactDto contactDto = new ContactDto(); clientDto.getContactList().add(contactDto); return contactDto; } Is there a way to achieve what I want, keep my rows at language switching without persisting in db ? Look at the @Persist annotation. Session persistence. Again, it's completely unrelated to language switching. @Persist private ContactDto contactDto; -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: ajaxformloop and localization
I added @Persist on a field in my form, it doesn't persist if switch locale. But if I try to submit (onSubmit not implemented in the .java) then the field become really persistente, even if I switch locale the field stay filled. Why this behavior ? How can I get this persistency between locale switching without having to fail-submit before ? 2014-07-17 10:23 GMT+02:00 squallmat . squall...@gmail.com: I added @Persist on both source and value, now fields persist between languages. But localization switching reload the page, so I assume if I want the field that were filled to stay filled at language switching I need to put on all my Property with @Persist and refill each field in SetupRender, right ? Is this possible to have localization switchin without page reloading, and only the labels ajaxly updated ? 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com: On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . squall...@gmail.com wrote: Still, in the Client entity that i will persist at the submit, I store my contacts in it : // when adding a contact row Object onAddRowFromContacts() { ContactDto contactDto = new ContactDto(); clientDto.getContactList().add(contactDto); return contactDto; } Is there a way to achieve what I want, keep my rows at language switching without persisting in db ? Look at the @Persist annotation. Session persistence. Again, it's completely unrelated to language switching. @Persist private ContactDto contactDto; -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: ajaxformloop and localization
Yes, to switch language the client (ie. the browser) must request the server to render the page in the new language. If the request to switch is from an EventLink or ActionLink, then values entered into the form will be lost. That is because they use HTTP GET. If your request to switch is from a Submit, then values entered into the form will be sent to the server. That is because it uses HTTP POST. Remember that by default the server-side is stateless (and that is a good thing). @Persist tells the server to keep state: it says keep a copy of the last rendered value of something. (By default it keeps that copy in the session, but there are options to keep it as a cookie, or in the URL, or wherever you like). If your user really does want to switch language while working in a form (which is a very unusual use case) then try Submit with mode=cancel or mode=unconditional. http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html On 17 Jul 2014, at 8:26 pm, squallmat . squall...@gmail.com wrote: I added @Persist on a field in my form, it doesn't persist if switch locale. But if I try to submit (onSubmit not implemented in the .java) then the field become really persistente, even if I switch locale the field stay filled. Why this behavior ? How can I get this persistency between locale switching without having to fail-submit before ? 2014-07-17 10:23 GMT+02:00 squallmat . squall...@gmail.com: I added @Persist on both source and value, now fields persist between languages. But localization switching reload the page, so I assume if I want the field that were filled to stay filled at language switching I need to put on all my Property with @Persist and refill each field in SetupRender, right ? Is this possible to have localization switchin without page reloading, and only the labels ajaxly updated ? 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com: On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . squall...@gmail.com wrote: Still, in the Client entity that i will persist at the submit, I store my contacts in it : // when adding a contact row Object onAddRowFromContacts() { ContactDto contactDto = new ContactDto(); clientDto.getContactList().add(contactDto); return contactDto; } Is there a way to achieve what I want, keep my rows at language switching without persisting in db ? Look at the @Persist annotation. Session persistence. Again, it's completely unrelated to language switching. @Persist private ContactDto contactDto; -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - 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: ajaxformloop and localization
hello Geoff, I just changed my actionlinks to form-submit : li style=float: right t:Form t:id=englishForm t:Submit t:mode=UNCONDITIONAL t:image=asset:classpath:layout/images/en.jpg class=imgflag alt=en/ /t:Form /li li style=float: right; border: none t:Form t:id=frenchForm t:Submit t:mode=UNCONDITIONAL t:image=asset:classpath:layout/images/fr.jpg class=imgflag alt=fr/ /t:Form /li @Component(id = englishForm) private Form englishForm; @Component(id = frenchForm) private Form frenchForm; @OnEvent(value = EventConstants.SUCCESS, component = englishForm) public Object onSuccess() { persistentLocale.set(new Locale(en)); return null; } @OnEvent(value = EventConstants.SUCCESS, component = frenchForm) public Object onSuccesstwo() { persistentLocale.set(new Locale(fr)); return null; } But that still continue to do the same thing. Is it necessary that my forms with submit switching language covers the field that we want persisted ? Because the switching language links/submit are in component layout. Is there another way/method/trick to achieve what I want ? 2014-07-17 12:36 GMT+02:00 Geoff Callender geoff.callender.jumpst...@gmail.com: Yes, to switch language the client (ie. the browser) must request the server to render the page in the new language. If the request to switch is from an EventLink or ActionLink, then values entered into the form will be lost. That is because they use HTTP GET. If your request to switch is from a Submit, then values entered into the form will be sent to the server. That is because it uses HTTP POST. Remember that by default the server-side is stateless (and that is a good thing). @Persist tells the server to keep state: it says keep a copy of the last rendered value of something. (By default it keeps that copy in the session, but there are options to keep it as a cookie, or in the URL, or wherever you like). If your user really does want to switch language while working in a form (which is a very unusual use case) then try Submit with mode=cancel or mode=unconditional. http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html On 17 Jul 2014, at 8:26 pm, squallmat . squall...@gmail.com wrote: I added @Persist on a field in my form, it doesn't persist if switch locale. But if I try to submit (onSubmit not implemented in the .java) then the field become really persistente, even if I switch locale the field stay filled. Why this behavior ? How can I get this persistency between locale switching without having to fail-submit before ? 2014-07-17 10:23 GMT+02:00 squallmat . squall...@gmail.com: I added @Persist on both source and value, now fields persist between languages. But localization switching reload the page, so I assume if I want the field that were filled to stay filled at language switching I need to put on all my Property with @Persist and refill each field in SetupRender, right ? Is this possible to have localization switchin without page reloading, and only the labels ajaxly updated ? 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com: On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . squall...@gmail.com wrote: Still, in the Client entity that i will persist at the submit, I store my contacts in it : // when adding a contact row Object onAddRowFromContacts() { ContactDto contactDto = new ContactDto(); clientDto.getContactList().add(contactDto); return contactDto; } Is there a way to achieve what I want, keep my rows at language switching without persisting in db ? Look at the @Persist annotation. Session persistence. Again, it's completely unrelated to language switching. @Persist private ContactDto contactDto; -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - 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
Tree Component : problem facing while adding child node data at runtime
Hello, I am a beginner for using Tapestry framework. I need some help on Tree Component. Problem Statement:1. I need to implement a Tree which contains 2 different Objects(P,C) for Parent and Child Nodes[P:C 1:n relationship].2. On first render, we only load P objects and populate only parent nodes(without any child nodes). [THIS DATA IS AVAILABLE PRIOR TO RENDERING THE TREE].3. After the Tree is rendered, User Clicks on Expand(+) button, we should fetch the C objects from DB and populate the child node of the clicked Parent Node. 4. THE CALL TO DB SHOULD BE ONLY ONCE IF USER HAS CLICKED TO EXPAND THE PARENT NODE AND FETCH THE CHILD NODE DATA.” I have taken reference from http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/treefromdatabasewithzones and implemented the functionality in similar manner. I am able to render the tree and display all Parent nodes. When I try to add data to child nodes I have the data but I am not able to modify the existing tree mode l. I am actually trying to override the functionality in Tree.java of Tapestry source code to achieve this in below method. Object onExpandChildren(String nodeId){TreeNode container = model.getById(nodeId);expansionModel.markExpanded(container);return new RenderNodes(container.getChildren());} Based on the NodeId passed to this method, I am able to fetch the list of C Objects at the start of this method. I am not able to know where shall i try to modify and add content to tree?Please guide me on this. Any thoughts ? Thanks in AdvanceSiddDear userssubscribe ! Get Yourself a cool, short @in.com Email ID now! Dear users! Get Yourself a cool, short @in.com Email ID now!
Re: ajaxformloop and localization
On Thu, 17 Jul 2014 10:32:32 -0300, squallmat . squall...@gmail.com wrote: But that still continue to do the same thing. Is it necessary that my forms with submit switching language covers the field that we want persisted ? Yep. Otherwise, the field values you want persisted aren't submitted. That's basic HTML knowledge. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: ajaxformloop and localization
A form will only submit what it contains. You need a single form that contains all your switch submits, the AjaxFormLoop, and anything else you don't want to lose. Regarding changing Add a Row, it's just text in this example... http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1 ...which you could replace with something like ${message:add-a-row-label} and a corresponding entry in app.properties or your localisation solution... http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bymessagecatalog http://jumpstart.doublenegative.com.au/jumpstart7/examples/localization/bytemplate Geoff On 17 Jul 2014, at 11:32 pm, squallmat . squall...@gmail.com wrote: hello Geoff, I just changed my actionlinks to form-submit : li style=float: right t:Form t:id=englishForm t:Submit t:mode=UNCONDITIONAL t:image=asset:classpath:layout/images/en.jpg class=imgflag alt=en/ /t:Form /li li style=float: right; border: none t:Form t:id=frenchForm t:Submit t:mode=UNCONDITIONAL t:image=asset:classpath:layout/images/fr.jpg class=imgflag alt=fr/ /t:Form /li @Component(id = englishForm) private Form englishForm; @Component(id = frenchForm) private Form frenchForm; @OnEvent(value = EventConstants.SUCCESS, component = englishForm) public Object onSuccess() { persistentLocale.set(new Locale(en)); return null; } @OnEvent(value = EventConstants.SUCCESS, component = frenchForm) public Object onSuccesstwo() { persistentLocale.set(new Locale(fr)); return null; } But that still continue to do the same thing. Is it necessary that my forms with submit switching language covers the field that we want persisted ? Because the switching language links/submit are in component layout. Is there another way/method/trick to achieve what I want ? 2014-07-17 12:36 GMT+02:00 Geoff Callender geoff.callender.jumpst...@gmail.com: Yes, to switch language the client (ie. the browser) must request the server to render the page in the new language. If the request to switch is from an EventLink or ActionLink, then values entered into the form will be lost. That is because they use HTTP GET. If your request to switch is from a Submit, then values entered into the form will be sent to the server. That is because it uses HTTP POST. Remember that by default the server-side is stateless (and that is a good thing). @Persist tells the server to keep state: it says keep a copy of the last rendered value of something. (By default it keeps that copy in the session, but there are options to keep it as a cookie, or in the URL, or wherever you like). If your user really does want to switch language while working in a form (which is a very unusual use case) then try Submit with mode=cancel or mode=unconditional. http://people.apache.org/~hlship/t5api/apidocs/org/apache/tapestry5/corelib/components/Submit.html On 17 Jul 2014, at 8:26 pm, squallmat . squall...@gmail.com wrote: I added @Persist on a field in my form, it doesn't persist if switch locale. But if I try to submit (onSubmit not implemented in the .java) then the field become really persistente, even if I switch locale the field stay filled. Why this behavior ? How can I get this persistency between locale switching without having to fail-submit before ? 2014-07-17 10:23 GMT+02:00 squallmat . squall...@gmail.com: I added @Persist on both source and value, now fields persist between languages. But localization switching reload the page, so I assume if I want the field that were filled to stay filled at language switching I need to put on all my Property with @Persist and refill each field in SetupRender, right ? Is this possible to have localization switchin without page reloading, and only the labels ajaxly updated ? 2014-07-16 21:02 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com: On Wed, 16 Jul 2014 12:55:24 -0300, squallmat . squall...@gmail.com wrote: Still, in the Client entity that i will persist at the submit, I store my contacts in it : // when adding a contact row Object onAddRowFromContacts() { ContactDto contactDto = new ContactDto(); clientDto.getContactList().add(contactDto); return contactDto; } Is there a way to achieve what I want, keep my rows at language switching without persisting in db ? Look at the @Persist annotation. Session persistence. Again, it's completely unrelated to language switching. @Persist private ContactDto contactDto; -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail:
Re: Tapestry-jpa, unit testing and (servlet)context
On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
tapestry injecting spring services
I used at many times injections of spring services bean in my tapestry pages and that works really well. But now I need to use them in Encoders class, when I do that : public class ApplicatifDtoEncoder implements ValueEncoderApplicatifDto { @Inject IServiceApplicatif serviceApplicatif; ... My serviceApplicatif stays null. Is it possible to make @Inject works here ? outside of tapestry pages ?
Re: ajaxformloop and localization
On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . squall...@gmail.com wrote: What is still stucking me is that language switching, I can't do it with form because we can't nest them. Put the language switcher inside the form. No need to nest forms. Or add some JavaScript to disable the language switcher when your form has something typed on them. Is there a way in an actionlink to force persisting of the properties of a page ? I'm sorry, this questions doesn't make much sense, as what controls the persistence of a page fields are annotations in the fields themselves. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: tapestry injecting spring services
On Thu, 17 Jul 2014 12:31:45 -0300, squallmat . squall...@gmail.com wrote: public class ApplicatifDtoEncoder implements ValueEncoderApplicatifDto { @Inject IServiceApplicatif serviceApplicatif; ... My serviceApplicatif stays null. Is it possible to make @Inject works here ? outside of tapestry pages ? Injection only happens in Tapestry-controlled classes (pages, components and mixins) or Tapestry-IoC instantiated objects (services or objects created with ObjectLocator.autobuild()). In other words, no injection happens if you get your object by instantiating it yourself (using the 'new' keyword). -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: ajaxformloop and localization
The language switchers are in a component layout including the pages where there is the forms. And I don't want (and the client too :p) to change the presentation. 2014-07-17 17:34 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com : On Thu, 17 Jul 2014 11:49:56 -0300, squallmat . squall...@gmail.com wrote: What is still stucking me is that language switching, I can't do it with form because we can't nest them. Put the language switcher inside the form. No need to nest forms. Or add some JavaScript to disable the language switcher when your form has something typed on them. Is there a way in an actionlink to force persisting of the properties of a page ? I'm sorry, this questions doesn't make much sense, as what controls the persistence of a page fields are annotations in the fields themselves. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry-jpa, unit testing and (servlet)context
I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
You might find this stack overflow question useful, it's about tapestry-hibernate but has some parallels. http://stackoverflow.com/questions/15664815/how-to-test-dao-layer-in-tapestry-dependent-projects On 17 Jul 2014 21:32, Lance Java lance.j...@googlemail.com wrote: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
I will do what you said but maybe i could open a ticket for this issue and propose a patch for tapestry-jpa, what do you think ? 2014-07-17 22:32 GMT+02:00 Lance Java lance.j...@googlemail.com: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
What are you instantiating in tapestry-jpa that needs context? To test your persistence layer, you should only need an entityManager. You could have something like this as a base class for unit testing: public abstract class BasePersistenceTest { private static Class?[] entities = new Class[] { DataEntity.class, UserAccount.class, ... }; private final static PersistenceUnitConfigurer configurer = new PersistenceUnitConfigurer() { public void configure(final TapestryPersistenceUnitInfo unitInfo) { for (Class? entityClass : entities) unitInfo.addManagedClass(entityClass); } }; protected EntityManagerSource emSource; protected EntityManager em; public BasePersistenceTest() { emSource = new EntityManagerSourceImpl(LoggerFactory.getLogger(BasePersistenceTest.class), new ClasspathResource( persistence.xml), configurer, CollectionFactory.String, PersistenceUnitConfigurer newMap()); } @Before public void createEntityManager() { em = emSource.create(persistence); } Then mock/instantiate services as needed on top to test your persistence logic. Kalle On Thu, Jul 17, 2014 at 1:32 PM, Lance Java lance.j...@googlemail.com wrote: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
I think it's a good idea to split tapestry-jpa in the same way as tapestry-hibernate. See HibernateCoreModule and HibernateModule to see how it's split. On 17 Jul 2014 21:47, Charlouze m...@charlouze.com wrote: I will do what you said but maybe i could open a ticket for this issue and propose a patch for tapestry-jpa, what do you think ? 2014-07-17 22:32 GMT+02:00 Lance Java lance.j...@googlemail.com: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
To Kalle: I'm a fan of the less I mock, the better I am. Also, I think it's easier to import module classes and let them do the job. This way, the full stack is tested. I let JpaModule instanciate what it needs ... To Lance: It's seems that hibernate modules and jpa are quite similar. What is the procedure for me to provide a patch ? Developing it and creating an issue with the patch attached ? 2014-07-17 23:05 GMT+02:00 Lance Java lance.j...@googlemail.com: I think it's a good idea to split tapestry-jpa in the same way as tapestry-hibernate. See HibernateCoreModule and HibernateModule to see how it's split. On 17 Jul 2014 21:47, Charlouze m...@charlouze.com wrote: I will do what you said but maybe i could open a ticket for this issue and propose a patch for tapestry-jpa, what do you think ? 2014-07-17 22:32 GMT+02:00 Lance Java lance.j...@googlemail.com: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.
Re: Tapestry-jpa, unit testing and (servlet)context
What is the procedure for me to provide a patch ? Developing it and creating an issue with the patch attached ? That's a great start. Some things to keep in mind 1. To be consistent with tapestry-hibernate, a new gradle submodule for tapestry-jpa-core is required. This will only have tapestry-ioc as a dependency. This will contain JpaCoreModule and the core jpa services. 2. tapestry-jpa-core needs a jar manifest entry for JpaCoreModule. 3. Test case for tapestry-jpa-core starting a registry without tapestry-core Cheers, Lance. On 17 Jul 2014 23:30, Charlouze m...@charlouze.com wrote: To Kalle: I'm a fan of the less I mock, the better I am. Also, I think it's easier to import module classes and let them do the job. This way, the full stack is tested. I let JpaModule instanciate what it needs ... To Lance: It's seems that hibernate modules and jpa are quite similar. What is the procedure for me to provide a patch ? Developing it and creating an issue with the patch attached ? 2014-07-17 23:05 GMT+02:00 Lance Java lance.j...@googlemail.com: I think it's a good idea to split tapestry-jpa in the same way as tapestry-hibernate. See HibernateCoreModule and HibernateModule to see how it's split. On 17 Jul 2014 21:47, Charlouze m...@charlouze.com wrote: I will do what you said but maybe i could open a ticket for this issue and propose a patch for tapestry-jpa, what do you think ? 2014-07-17 22:32 GMT+02:00 Lance Java lance.j...@googlemail.com: Ah, I haven't used tapestry-jpa myself. tapestry-hibernate is split into two modules to allow for this type of testing. If this is the case, you may need to override ApplicationGlobals and provide a mock ServletContext as I said initially. On 17 Jul 2014 17:37, Charlouze m...@charlouze.com wrote: I have separated modules for the service tier and the web tier but tapestry-jpa requires tapestry web modules... IMO, it should not but that's the way it is (maybe JpaModule should be divided into two modules). Anyway, I would have the same problem with beanvalidation module. I'll take a look at the tapestry sources for examples 2014-07-17 17:29 GMT+02:00 Lance Java lance.j...@googlemail.com: On second thought of you are unit testing just your jpa classes you shouldn't need the ServletContext to be mocked. Note that tapestry modules have been split in such a way that Web services are separated from core services. I think your test should not require any web modules. This might require you to split your custom module into 2 modules (web and core) but will make testing easier. On 17 Jul 2014 16:20, Lance Java lance.j...@googlemail.com wrote: I'm not sure exactly what you're doing but you probably need to override the ApplicationGlobals service such that getServletContext() returns an appropriate mock. If you're using junit, you might want to try the new TapestryIOCJunit4ClassRunner. See the tapestry sources for example test cases. On 17 Jul 2014 16:02, Charlouze m...@charlouze.com wrote: Hello everyone. I'm currently setting up an application using T5.4-b13. For unit testing, I use junit, unitils-dbunit, spock (with spock-tapestry and spock-unitils extension). In my specification I added @submodule annotation with every needed module (Tapestry, Jpa, beanValidator and my custom module). My problem is that there are no context and therefore, my tests do not pass the assert context != null in ContextResource class constructor. Does anyone know what can I do ? Thanks in advance Charles.