Re: [5.4] javascript - simplify the new paradigm please
Geoff, AFAIK, JavascriptSupport is only available at render time and ajax render doesn't start until after your event handler returns something. I think it's because tapestry doesn't know what will need to be rendered yet. For your second question, I think you can achieve what you want if you pass arguments to your invoke : javaScriptSupport.require("components/MyTimer").invoke(" showTimer").with(true); It may be a nasty workaround but it works ;) Charles. 2014-11-17 7:48 GMT+01:00 Geoff Callender < geoff.callender.jumpst...@gmail.com>: > Chris, It looks like the "rule of thumb" that I stated was wrong. I've > just used JavaScriptSupport#require in some AJAX event handlers. > > Can someone explain under what circumstances we have to use > AjaxResponseRenderer#addCallback instead of JavaScriptSupport#require ? > > Is it something to do with queueing requests? For example I noticed a > limitation of using require. This... > > > javaScriptSupport.require("components/MyTimer").invoke("showTimer"); > > javaScriptSupport.require("components/MyTimer").invoke("hideTimer"); > > javaScriptSupport.require("components/MyTimer").invoke("showTimer"); > > ...resulted in only 2 invocations in the response to the client... > > { > "_tapestry" : { > "inits" : [ > "components/MyTimer:showTimer", > "components/MyTimer:hideTimer" > ] > } > } > > Geoff > > > On 14 Nov 2014, at 3:23 pm, Geoff Callender < > geoff.callender.jumpst...@gmail.com> wrote: > > > I don't think so. I believe the rule of thumb is to use > JavaScriptSupport during render, and use an AJAX callback during partial > page render. > > > > IIRC, the JavaScriptSupport environmental is not available when you're > handling an AJAX component event request. > > > > On 13 Nov 2014, at 6:08 pm, Chris Poulsen > wrote: > > > >> can't you just use javascriptsupport to require and invoke your js > module > >> function? > >> > >> -- > >> Chris > >> > >> On Thu, Nov 13, 2014 at 6:34 AM, Geoff Callender < > >> geoff.callender.jumpst...@gmail.com> wrote: > >> > >>> Have you had a look at these two: > >>> > >>> > >>> > http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/modal/1 > >>> > >>> > http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusablemodal/1 > >>> > >>> Do they fit your scenario? > >>> > >>> On 13 Nov 2014, at 3:40 pm, Paul Stanton wrote: > >>> > Hi Geoff, > > I have found your examples invaluable in learning some of the basics > of > >>> this (and other) concepts. I can't thank you enough > > .. the only thing I can see is missing currently is the example I > asked > >>> about in the previous mail: > > Basically, how do I interact with a js module instance after it is > >>> created? > > pretend some server-side state changes between afterRender and > >>> onSomeEvent, and the client needs to react accordingly. > > jss.addScript is deprecated, so I "shouldn't" be telling the client to > >>> execute script apparently... > > cheers, p. > > On 13/11/2014 2:36 PM, Geoff Callender wrote: > > do these examples cover the situations you are describing? > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > >>> > >>> > > > >
Re: [5.4] javascript - simplify the new paradigm please
Chris, It looks like the "rule of thumb" that I stated was wrong. I've just used JavaScriptSupport#require in some AJAX event handlers. Can someone explain under what circumstances we have to use AjaxResponseRenderer#addCallback instead of JavaScriptSupport#require ? Is it something to do with queueing requests? For example I noticed a limitation of using require. This... javaScriptSupport.require("components/MyTimer").invoke("showTimer"); javaScriptSupport.require("components/MyTimer").invoke("hideTimer"); javaScriptSupport.require("components/MyTimer").invoke("showTimer"); ...resulted in only 2 invocations in the response to the client... { "_tapestry" : { "inits" : [ "components/MyTimer:showTimer", "components/MyTimer:hideTimer" ] } } Geoff On 14 Nov 2014, at 3:23 pm, Geoff Callender wrote: > I don't think so. I believe the rule of thumb is to use JavaScriptSupport > during render, and use an AJAX callback during partial page render. > > IIRC, the JavaScriptSupport environmental is not available when you're > handling an AJAX component event request. > > On 13 Nov 2014, at 6:08 pm, Chris Poulsen wrote: > >> can't you just use javascriptsupport to require and invoke your js module >> function? >> >> -- >> Chris >> >> On Thu, Nov 13, 2014 at 6:34 AM, Geoff Callender < >> geoff.callender.jumpst...@gmail.com> wrote: >> >>> Have you had a look at these two: >>> >>> >>> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/modal/1 >>> >>> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusablemodal/1 >>> >>> Do they fit your scenario? >>> >>> On 13 Nov 2014, at 3:40 pm, Paul Stanton wrote: >>> Hi Geoff, I have found your examples invaluable in learning some of the basics of >>> this (and other) concepts. I can't thank you enough .. the only thing I can see is missing currently is the example I asked >>> about in the previous mail: Basically, how do I interact with a js module instance after it is >>> created? pretend some server-side state changes between afterRender and >>> onSomeEvent, and the client needs to react accordingly. jss.addScript is deprecated, so I "shouldn't" be telling the client to >>> execute script apparently... cheers, p. On 13/11/2014 2:36 PM, Geoff Callender wrote: > do these examples cover the situations you are describing? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >
Re: Different Zone Update's
I've raised a JIRA for client-side pub/sub. https://issues.apache.org/jira/browse/TAP5-2416 On 4 Sep 2014, at 5:57 pm, Geoff Callender wrote: > In an AJAX request the server-side would have no way of knowing how many > subscribers there are within the page unless it exactly rebuilds the entire > page state. For example some subscribers could be within a loop, and they > might be conditional. > > However, the client-side has the full page state, so I think that's where the > pub-sub has to happen. > > A simple mechanism that might be sufficient: > - give the Zone component a "refreshOnMessage" parameter, and > - give AjaxResponseRenderer a publishMessage(String s) method, and > - Tapestry could do the rest, client-side, triggering all the necessary zone > refreshes. > > What do you think? > > > On 4 Sep 2014, at 3:01 pm, Sumanth wrote: > >> Exactly, It's too messy to do it that way, and hence I had to post it here >> to find an alternative for it. >> >> We also need a decoupled solution. We thought of pub-sub but have no idea >> on how to implement it (Cant find much about this topic). So if anyone >> knows of such a way to do it , this would help a lot. >> >> This is one of our common requirement, cause we have many zones under >> multiple nested components in layout component and on action of some of the >> nested components in pages, those layout component needs to be updated. >> >> On Thu, Sep 4, 2014 at 12:08 AM, Geoff Callender < >> geoff.callender.jumpst...@gmail.com> wrote: >> >>> I think the issue here is that he'd like one deeply nested component, >>> let's call it Z, to be refreshed when another deeply nested component, >>> let's call it N, that doesn't know about Z, is refreshed. >>> >>> One way is to bubble up an event from N until it reaches a common parent, >>> C, which in this example is the parent of the layout. C then calls >>> component.doChangeOfNotifications(), which calls >>> componentA.doChangeOfNotifications(), which calls ... etc. .. which calls >>> Z.doChangeOfNotifications(). Messy, with lots of components needing new >>> method doChangeOfNotifications. You can see something like this in: >>> >>> >>> http://jumpstart.doublenegative.com.au/jumpstart7/together/ajaxcomponentscrud/persons >>> >>> where Persons, which is the page, calls list.doChangeOfSelectedPerson() in >>> response to several bubbled-up events. >>> >>> Ideally, a synchronous pub-sub server-side could solve it. N would publish >>> and Z would subscribe. Z would use AjaxResponseRenderer to add its zone to >>> the render list. Unfortunately, I don't know of such a mechanism. >>> >>> Any other suggestions? >>> >>> On 4 Sep 2014, at 3:51 am, Thiago H de Paula Figueiredo < >>> thiag...@gmail.com> wrote: >>> On Wed, 03 Sep 2014 13:40:53 -0300, Sumanth >>> wrote: > Hello Experts, Hi! > > I have encountered one more hurdle now regarding zones, > > I have a layout > component>componentA>componentB>componentC>NotificationComponent>Zone > > This zone is a count zone and is updated using a mixin >>> (periodiczonerefresh > mixin). > > I have a notification page in which i have a Zone(a table inside a zone > containing notifications) and an actionlink to delete the selected > notifications.(bulk delete). On delete of these notifications i want the > count which is in layout component (mentioned above) to be updated. > > How can i do it? The easiest way is to define the id of the zone to be updated and use >>> its addRender(String clientId, Object renderer) to update it. -- 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: [5.4] javascript - simplify the new paradigm please
Geoff, After some testing I can really see the benefits in how you achieve this... One of my main prior misunderstanding was that the 'define' is only run once (I thought it would be re-run each 'require'), making similar to a 'static' object in some ways, in that the state is then shared by all subsequent 'require' calls... so you are effectively creating a hash of stateful objects within the context of that 'define'. thank you for helping me understand this, I feel I have graduated re this concept and can now get some code written. would love to see this in action in jumpstart7. as far as i'm concerned jumpstart is the definitive tapestry documentation, or at least on par with the official. howard, thiago etc, maybe putting a few more complex examples in the 'javascript-modules' documentation would be helpful? if you haven't used requirejs before this concept is hard to grasp at first. p. On 14/11/2014 3:06 PM, Geoff Callender wrote: I accidentally left out the object's state vars. Added below. On 14 Nov 2014, at 10:00 am, Geoff Callender wrote: Yep, that's a valid case, and it's one I have to put into JumpStart. Here's the way I handle it. I'd like to see what others do. Have the module keep an array of objects, identified by a key. The server-side can provide the key when initialising and later whenever invoking a function. The component can use any value for the key as long as it is unique on the page and as long as it is repeatable (eg. the component might need to derive the key from its container or context). Here's an example snippet from a module I called "activate-selectables". More than one component on my page uses this module. A typical case is when I have a list of items on the page, and a button that pops up a modal with another list of items. When an item is selected, the server-side has to set the currentElement on the correct list. define([ "jquery", "t5/core/console" ], function($, console) { var selectablesContainers = []; SelectablesContainer = function() { var containerId = "", selectableClass = "", selectedClass = "", currentClass = ""; init = function(params) { containerId = params.containerId; selectableClass = params.selectableCssClass; selectedClass = params.selectedCssClass; // etc var $container = $('#' + containerId); $container.on('click', '.' + selectableClass, doSelected); }; doSelected = function() { var $clicked = $(this); $clicked.addClass(selectedClass); $clicked.trigger('selected'); }; setCurrentElement = function(selectableName) { // etc. }; return { init : init, setCurrentElement : setCurrentElement }; }; init = function(key, params) { var selectablesContainer = new SelectablesContainer(); selectablesContainer.init(params); selectablesContainers[key] = selectablesContainer; }; setCurrentElement = function(key, currentElementName) { var selectablesContainer = selectablesContainers[key]; selectablesContainer.setCurrentElement(currentElementName); }; return { init : init, setCurrentElement : setCurrentElement }; }); And some corresponding java: void afterRender() { JSONObject params = new JSONObject(); params.put("containerId", thingsDiv.getClientId()); //etc javaScriptSupport.require("activate-selectables").invoke("init").with(SELECTABLES_KEY, params); } Object onThingSelected(Integer thingId) { this.thingId = thingId; // etc ajaxResponseRenderer.addCallback(makeScriptToSetCurrentElement(selectableName)); // etc } private JavaScriptCallback makeScriptToSetCurrentElement(final String selectableName) { return new JavaScriptCallback() { public void run(JavaScriptSupport javaScriptSupport) { javaScriptSupport.require("activate-selectables").invoke("setCurrentElement") .with(SELECTABLES_KEY, selectableName); } }; } In this case I get away with SELECTABLES_KEY being a constant but, as I said above, sometimes you have to derive its value from its container or event context. Geoff On 14 Nov 2014, at 9:18 am, Paul Stanton wrote: Oh, so calling require("modal").invoke("ac
Re: hibernateModule is looking for MethodAdvice
So fixed, i had there also old version of tapestry-security. Million thanks! On Sun, 16 Nov 2014 09:22:23 +0100, Jan Fryblik wrote: Thanks, I had there old tapestry-upload-5.3.7.jar pulled in by tapestry5-jquery, so i`ve fixed it. Unfortunately without positive effect, exception is still there. Strange thing is that exception is comming from org.apache.tapestry5.hibernate.modules.HibernateModule or at least it looks like that. On Sat, 15 Nov 2014 22:06:54 +0100, Tony Nelson wrote: Double check that you don't have both tapestry 5.3 and 5.4 jars in your class path. -Tony On Nov 15, 2014, at 3:03 PM, Jan Fryblik wrote: HI guys, i'm currently migrating from 5.3.7 to 5.4-beta-22 and i'm stuck with strange exception (below) comming from HibernateModule. I have removed all MethodAdvice references from my project, but without any effect. Could you please give me a hint what can be a reason? Thanks for any comments. 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.got5.tapestry5.jquery.services.JQueryModule 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.got5.tapestry5.jquery.services.js.JSModule 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.apache.tapestry5.hibernate.modules.HibernateModule failed Catalog: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext@4506b213{/catalog-web,/mnt/ebrothers/katalog/src/Catalog/catalog-web/src/main/webapp}: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed ContextHandlerCollection@7dd4d950: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed HandlerCollection@7391bf69: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice Error starting handlers java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:340) at org.apache.tapestry5.ioc.RegistryBuilder.add(RegistryBuilder.java:159) at org.apache.tapestry5.ioc.IOCUtilities.addModulesInList(IOCUtilities.java:132) at org.apache.tapestry5.ioc.IOCUtilities.addModulesInManifest(IOCUtilities.java:105) at org.apache.tapestry5.ioc.IOCUtilities.addDefaultModules(IOCUtilities.java:76) at org.apache.tapestry5.internal.TapestryAppInitializer.(TapestryAppInitializer.java:123) at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:97) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489) at org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.doStart(JettyPluginWebAppContext.java:112) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) Have a nice weekend, Jan Since 1982, Starpoint Solutions has been a trusted source of human capital and solutions. We are committed to our clients, employees, environment, community and social concerns. We foster an inclusive culture based on trust, respect, honesty and solid performance. Learn more about Starpoint and our social responsibility at http://www.starpoint.com/social_responsibility This email message from Starpoint Solutions LLC is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Opinions, conclusions and other information in this message that do not relate to the official business of Starpoint Solutions shall be understood as neither given nor endorsed by it. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- S pozdravem Mgr. Jan Fryblík jednatel +420 739 094 784 jan.fryb...@ebrothers.cz eBrothers Software s.r.o. | www.ebrothers.cz - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: hibernateModule is looking for MethodAdvice
Thanks, I had there old tapestry-upload-5.3.7.jar pulled in by tapestry5-jquery, so i`ve fixed it. Unfortunately without positive effect, exception is still there. Strange thing is that exception is comming from org.apache.tapestry5.hibernate.modules.HibernateModule or at least it looks like that. On Sat, 15 Nov 2014 22:06:54 +0100, Tony Nelson wrote: Double check that you don't have both tapestry 5.3 and 5.4 jars in your class path. -Tony On Nov 15, 2014, at 3:03 PM, Jan Fryblik wrote: HI guys, i'm currently migrating from 5.3.7 to 5.4-beta-22 and i'm stuck with strange exception (below) comming from HibernateModule. I have removed all MethodAdvice references from my project, but without any effect. Could you please give me a hint what can be a reason? Thanks for any comments. 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.got5.tapestry5.jquery.services.JQueryModule 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.got5.tapestry5.jquery.services.js.JSModule 19:49:44 [INFO] ioc.RegistryBuilder Adding module definition for class org.apache.tapestry5.hibernate.modules.HibernateModule failed Catalog: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext@4506b213{/catalog-web,/mnt/ebrothers/katalog/src/Catalog/catalog-web/src/main/webapp}: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed ContextHandlerCollection@7dd4d950: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice failed HandlerCollection@7391bf69: java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice Error starting handlers java.lang.NoClassDefFoundError: org/apache/tapestry5/ioc/MethodAdvice at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:340) at org.apache.tapestry5.ioc.RegistryBuilder.add(RegistryBuilder.java:159) at org.apache.tapestry5.ioc.IOCUtilities.addModulesInList(IOCUtilities.java:132) at org.apache.tapestry5.ioc.IOCUtilities.addModulesInManifest(IOCUtilities.java:105) at org.apache.tapestry5.ioc.IOCUtilities.addDefaultModules(IOCUtilities.java:76) at org.apache.tapestry5.internal.TapestryAppInitializer.(TapestryAppInitializer.java:123) at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:97) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1272) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489) at org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.doStart(JettyPluginWebAppContext.java:112) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) Have a nice weekend, Jan Since 1982, Starpoint Solutions has been a trusted source of human capital and solutions. We are committed to our clients, employees, environment, community and social concerns. We foster an inclusive culture based on trust, respect, honesty and solid performance. Learn more about Starpoint and our social responsibility at http://www.starpoint.com/social_responsibility This email message from Starpoint Solutions LLC is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Opinions, conclusions and other information in this message that do not relate to the official business of Starpoint Solutions shall be understood as neither given nor endorsed by it. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- S pozdravem Mgr. Jan Fryblík jednatel +420 739 094 784 jan.fryb...@ebrothers.cz eBrothers Software s.r.o. | www.ebrothers.cz - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org