Re: Tapestry-jpa, unit testing and (servlet)context
I'll try to provide something next week or the week after. Charles 2014-07-18 4:20 GMT+02:00 Lance Java lance.j...@googlemail.com: 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.
Re: ajaxformloop and localization
IMHO, you should take a fresh look at the user experience. If you choose the more natural flow of asking the user to choose a language *before* presenting them with any forms, then the flow becomes natural and all the difficulties disappear. If, however, you proceed with the way you describe, then the inescapable fact is that when you switch language, the separate form on the page must be submitted and it must include info about the language you're switching to. Here's a way: * in each form, include a hidden field, switchLanguage. * in each form, include a hidden Submit with mode=cancel. * in the component layout, you don't need Form, Submit, EventLink, or ActionLink in the component layout. Instead, use a href=# links. * in the component layout, require javascript that, on click of a switcher link: * finds the hidden field, switchLanguage, and populates it; and * finds the hidden Submit with mode=cancel and clicks it. * server-side, in onSubmit, if switchLanguage is not null then you know to switch the language. If however, the component layout is around multiple forms, then things get tricky. It might work if it AJAX-submits each one. HTH, Geoff On 18 Jul 2014, at 1:49 am, squallmat . squall...@gmail.com wrote: 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 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: ajaxformloop and localization
I meant in onValidateFromForm(), not in onSubmit(). Alternatively, detect which submit was pressed like this: http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/multiplesubmits1 On 18 Jul 2014, at 8:02 pm, Geoff Callender geoff.callender.jumpst...@gmail.com wrote: IMHO, you should take a fresh look at the user experience. If you choose the more natural flow of asking the user to choose a language *before* presenting them with any forms, then the flow becomes natural and all the difficulties disappear. If, however, you proceed with the way you describe, then the inescapable fact is that when you switch language, the separate form on the page must be submitted and it must include info about the language you're switching to. Here's a way: * in each form, include a hidden field, switchLanguage. * in each form, include a hidden Submit with mode=cancel. * in the component layout, you don't need Form, Submit, EventLink, or ActionLink in the component layout. Instead, use a href=# links. * in the component layout, require javascript that, on click of a switcher link: * finds the hidden field, switchLanguage, and populates it; and * finds the hidden Submit with mode=cancel and clicks it. * server-side, in onSubmit, if switchLanguage is not null then you know to switch the language. If however, the component layout is around multiple forms, then things get tricky. It might work if it AJAX-submits each one. HTH, Geoff On 18 Jul 2014, at 1:49 am, squallmat . squall...@gmail.com wrote: 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 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
How to call onSuccess in components from page
Hi everyone, I have a page with a couple of custom components in it, most of them are containing different inputs. In the page after all components I have submit button. By pressing the submit button I want to execute different things in the components. I thought the onSuccess methods in the components will be called, but they are not. I want to call some methods from the components but I can not access them, because these components are not injected in my java class, they are only injected in the tml file as markup, because it's being done inside a loop, they are dynamic number. Is there a way to fire event from the page and to be caught in the components? I saw only the onValidate is called everywhere, but onSuccess, onSubmit, etc. - not - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Inject dynamic number of components
Hi all, how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I want to access these components as they are injected and to execute in the onSuccess for everyone of them some method as if it is a single component: @inject MyCustomComponent component; void onSuccess() { component.method(); } I want to the the same for dynamic number of components, created by the loop - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: How to call onSuccess in components from page
On Fri, 18 Jul 2014 19:10:10 -0300, nn kk inv...@abv.bg wrote: Hi everyone, Hi! Remember that events bubble up: from the component that triggered it to its parent and so on until it reachs the page. So, if your components are inside a form, the form events won't be triggered on these components. Why your components need to know when the form is submitted? I have a page with a couple of custom components in it, most of them are containing different inputs. In the page after all components I have submit button. By pressing the submit button I want to execute different things in the components. I thought the onSuccess methods in the components will be called, but they are not. I want to call some methods from the components but I can not access them, because these components are not injected in my java class, they are only injected in the tml file as markup, because it's being done inside a loop, they are dynamic number. Is there a way to fire event from the page and to be caught in the components? I saw only the onValidate is called everywhere, but onSuccess, onSubmit, etc. - not - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- 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: Inject dynamic number of components
On Fri, 18 Jul 2014 19:42:26 -0300, nn kk inv...@abv.bg wrote: Hi all, Hi! how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I'm sorry, but your question doesn't even make sense, because Tapestry doesn't create components instance dynamically. It's all 100% static. The rendering of them, though, is 100% dynamic. In your template above, there are just two component instances, one Loop, one MyCustomComponent, no matter how many times the Loop iterates. A single MyCustomComponent instance will be rendered many times. -- 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: Inject dynamic number of components
You need SubmitNotifier: http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/SubmitNotifier.html On Friday, July 18, 2014, nn kk inv...@abv.bg wrote: Hi all, how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I want to access these components as they are injected and to execute in the onSuccess for everyone of them some method as if it is a single component: @inject MyCustomComponent component; void onSuccess() { component.method(); } I want to the the same for dynamic number of components, created by the loop - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org javascript:; For additional commands, e-mail: users-h...@tapestry.apache.org javascript:; -- Dmitry Gusev AnjLab Team http://anjlab.com