Re: Tweaking an AjaxFormLoop
Regarding the original problem, if anyone is interested in a workaround to solve it just PM me. Cheers! Peter Stavrinides wrote: > > Hi Robert, > > Here is the new jira: > https://issues.apache.org/jira/browse/TAP5-1102 > > Also its worth looking at https://issues.apache.org/jira/browse/TAP5-775. > Although an unrelated issue, I thought that depending on what Howard was > planning, this might provide some features to work off. The AjaxFormLoop > is one of those components I can certainly see people using more and more > of in future, so seems to me at least to be worth the effort. > > Cheers, > Peter > > > - Original Message - > From: "Robert Zeigler" > To: "Tapestry users" > Sent: Friday, 9 April, 2010 18:12:22 GMT +02:00 Athens, Beirut, Bucharest, > Istanbul > Subject: Re: Tweaking an AjaxFormLoop > > Not that I'm aware of. > Feel free to search jira and create one. :) > > Robert > > On Apr 9, 2010, at 4/95:39 AM , Peter Stavrinides wrote: > >> Nice post! and came at just the right time for me too... so thanks >> for the tips! >> >> +1 for feature addition, any Jira open? >> >> cheers, >> Peter >> >> - Original Message - >> From: "Juan Isern" >> To: users@tapestry.apache.org >> Sent: Friday, 9 April, 2010 08:09:40 GMT +02:00 Athens, Beirut, >> Bucharest, Istanbul >> Subject: Re: Tweaking an AjaxFormLoop >> >> >> Robert, following your recomendation finally implemented a component >> that >> does basically nothing but register itself as a trigger and has an id >> assigned by tap as well. >> >> On the client side, I have a global map and a >> function triggerRowInjector(triggerId) so that I can inject rows >> selectively. >> >> As for the effect thing, you can see that they're hardcoded in the >> function >> Tapestry.Initializer.formLoopRemoveLink so I overrode it making them >> consistent. >> >> I'm using tapestry 5.1.0.5, so I expect this "solution" to be broken >> by... >> 5.2, maybe? :P >> >> >> >> >> Robert Zeigler wrote: >>> >>> That just sounds like you're asking for trouble down the road, >>> though. ;) >>> You're effectively relying on implementation details of the >>> component. >>> It'll break if: >>> * AjaxFormLoop changes the id of the contained RowInjector >>> component >>> * You want more than one AjaxFormLoop on the page >>> >>> I'll grant you that it works... for now. :) And it's the sort of >>> solution I might put in projects that I write for myself, but not a >>> solution I would put into a project I write for clients. >>> >>> It's probably worth submitting a jira for a feature addition to make >>> this sort of functionality easier/more robust. >>> >>> Robert >>> >>> On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: >>> >>>> I've done something similar without much hacking. In my case I have >>>> an autocomplete field in each row, and when a selection is made I >>>> needed to add a new row automatically so the user can enter the next >>>> item. I found that the row injector always has the same name, so I >>>> just call the trigger function defined in tapestry.js when I want to >>>> add the new row. The addRow parameter is empty so the link doesn't >>>> render, but the trigger still does. >>>> >>>> >>>> >>>> >>> t:mixins="autocomplete2" t:afterUpdateElement="itemSelected"/> >>>> >>>> ... >>>> >>>> >>>> >>>> function itemSelected() { >>>> $("rowInjector").trigger(); >>>> } >>>> >>>> You may notice that I'm using my own autocomplete mixin, which I had >>>> to make to expose the afterUpdateElement event, but if you've got >>>> some other logic that invokes the adding of a row the idea should be >>>> the same. >>>> >>>> Hope this helps, >>>> Brian >>>> >>>> >>>> >>>> From: Juan Isern [juanis...@gmail.com] >>>> Sent: Thursday, April 08, 2010 6:43 PM >>>> To: users@tapestry.apache.org >>>> Subject: Re: Tweaking an AjaxFormLoop >
Re: Tweaking an AjaxFormLoop
Hi Robert, Here is the new jira: https://issues.apache.org/jira/browse/TAP5-1102 Also its worth looking at https://issues.apache.org/jira/browse/TAP5-775. Although an unrelated issue, I thought that depending on what Howard was planning, this might provide some features to work off. The AjaxFormLoop is one of those components I can certainly see people using more and more of in future, so seems to me at least to be worth the effort. Cheers, Peter - Original Message - From: "Robert Zeigler" To: "Tapestry users" Sent: Friday, 9 April, 2010 18:12:22 GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: Tweaking an AjaxFormLoop Not that I'm aware of. Feel free to search jira and create one. :) Robert On Apr 9, 2010, at 4/95:39 AM , Peter Stavrinides wrote: > Nice post! and came at just the right time for me too... so thanks > for the tips! > > +1 for feature addition, any Jira open? > > cheers, > Peter > > - Original Message - > From: "Juan Isern" > To: users@tapestry.apache.org > Sent: Friday, 9 April, 2010 08:09:40 GMT +02:00 Athens, Beirut, > Bucharest, Istanbul > Subject: Re: Tweaking an AjaxFormLoop > > > Robert, following your recomendation finally implemented a component > that > does basically nothing but register itself as a trigger and has an id > assigned by tap as well. > > On the client side, I have a global map and a > function triggerRowInjector(triggerId) so that I can inject rows > selectively. > > As for the effect thing, you can see that they're hardcoded in the > function > Tapestry.Initializer.formLoopRemoveLink so I overrode it making them > consistent. > > I'm using tapestry 5.1.0.5, so I expect this "solution" to be broken > by... > 5.2, maybe? :P > > > > > Robert Zeigler wrote: >> >> That just sounds like you're asking for trouble down the road, >> though. ;) >> You're effectively relying on implementation details of the >> component. >> It'll break if: >> * AjaxFormLoop changes the id of the contained RowInjector >> component >> * You want more than one AjaxFormLoop on the page >> >> I'll grant you that it works... for now. :) And it's the sort of >> solution I might put in projects that I write for myself, but not a >> solution I would put into a project I write for clients. >> >> It's probably worth submitting a jira for a feature addition to make >> this sort of functionality easier/more robust. >> >> Robert >> >> On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: >> >>> I've done something similar without much hacking. In my case I have >>> an autocomplete field in each row, and when a selection is made I >>> needed to add a new row automatically so the user can enter the next >>> item. I found that the row injector always has the same name, so I >>> just call the trigger function defined in tapestry.js when I want to >>> add the new row. The addRow parameter is empty so the link doesn't >>> render, but the trigger still does. >>> >>> >>> >>> >> t:mixins="autocomplete2" t:afterUpdateElement="itemSelected"/> >>> >>> ... >>> >>> >>> >>> function itemSelected() { >>> $("rowInjector").trigger(); >>> } >>> >>> You may notice that I'm using my own autocomplete mixin, which I had >>> to make to expose the afterUpdateElement event, but if you've got >>> some other logic that invokes the adding of a row the idea should be >>> the same. >>> >>> Hope this helps, >>> Brian >>> >>> >>> >>> From: Juan Isern [juanis...@gmail.com] >>> Sent: Thursday, April 08, 2010 6:43 PM >>> To: users@tapestry.apache.org >>> Subject: Re: Tweaking an AjaxFormLoop >>> >>> Robert, I've got to say that you gave me the answer that I feared >>> most. >>> >>> Hehe, REALLY thanks for your tips, I knew already that sooner or >>> later I had >>> to hack into tapestry.js >>> >>> Cheers! >>> >>> >>> Robert Zeigler wrote: >>>> >>>> >>>> On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: >>>> >>>>> What I would like to do is to trigger an "addRow" event by >>>>> executing >>>>> some >>>>> javascript
Re: Tweaking an AjaxFormLoop
Not that I'm aware of. Feel free to search jira and create one. :) Robert On Apr 9, 2010, at 4/95:39 AM , Peter Stavrinides wrote: Nice post! and came at just the right time for me too... so thanks for the tips! +1 for feature addition, any Jira open? cheers, Peter - Original Message - From: "Juan Isern" To: users@tapestry.apache.org Sent: Friday, 9 April, 2010 08:09:40 GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: Tweaking an AjaxFormLoop Robert, following your recomendation finally implemented a component that does basically nothing but register itself as a trigger and has an id assigned by tap as well. On the client side, I have a global map and a function triggerRowInjector(triggerId) so that I can inject rows selectively. As for the effect thing, you can see that they're hardcoded in the function Tapestry.Initializer.formLoopRemoveLink so I overrode it making them consistent. I'm using tapestry 5.1.0.5, so I expect this "solution" to be broken by... 5.2, maybe? :P Robert Zeigler wrote: That just sounds like you're asking for trouble down the road, though. ;) You're effectively relying on implementation details of the component. It'll break if: * AjaxFormLoop changes the id of the contained RowInjector component * You want more than one AjaxFormLoop on the page I'll grant you that it works... for now. :) And it's the sort of solution I might put in projects that I write for myself, but not a solution I would put into a project I write for clients. It's probably worth submitting a jira for a feature addition to make this sort of functionality easier/more robust. Robert On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: I've done something similar without much hacking. In my case I have an autocomplete field in each row, and when a selection is made I needed to add a new row automatically so the user can enter the next item. I found that the row injector always has the same name, so I just call the trigger function defined in tapestry.js when I want to add the new row. The addRow parameter is empty so the link doesn't render, but the trigger still does. ... function itemSelected() { $("rowInjector").trigger(); } You may notice that I'm using my own autocomplete mixin, which I had to make to expose the afterUpdateElement event, but if you've got some other logic that invokes the adding of a row the idea should be the same. Hope this helps, Brian From: Juan Isern [juanis...@gmail.com] Sent: Thursday, April 08, 2010 6:43 PM To: users@tapestry.apache.org Subject: Re: Tweaking an AjaxFormLoop Robert, I've got to say that you gave me the answer that I feared most. Hehe, REALLY thanks for your tips, I knew already that sooner or later I had to hack into tapestry.js Cheers! Robert Zeigler wrote: On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: What I would like to do is to trigger an "addRow" event by executing some javascript (that will be invoked when an upload finishes). I thought of simulating a click event on an invisible "add row" link but I'm sure there's a prettier solution out there. There are other ways to do it, although I'm not sure I would call them "prettier". :) AjaxFormLoop places an "AjaxFormLoopContext" object into the environment when it renders. You can access this object and add a call to "addAddRowTrigger". That part is pretty. The main issue (for you) is that tapestry then assumes that the trigger is going to be invoked on the "click" action, which isn't what you want in this case. There's a way around it, and that's where things get uglier. You can monkey patch tapestry.js to override Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. This is typically how I've implemented custom "add row" functionality. It might be a nifty change to enable a second form of the "addAddRowTrigger" that takes, say, a js callback name as a 2nd argument. Or perhaps some flag triggering whether the first argument is an id or a callback. In any event, the initializer could then check for the appropriate condition, and if the condition is met, the initializer would delegate the setup to the callback, passing in the row injector, rather than assuming a click. If there's enough interest in something like this, I would be willing to do the work to add it to the framework (the exact api would need to be worked out, though). The same question could apply to any client-side ajax behavior, like refreshing zones. Is there any way to do it programmatically via javascript? The best answer here is to take a look for yourself through (mainly) the tapestry.js file. But, yes, you can refresh
Re: Tweaking an AjaxFormLoop
Nice post! and came at just the right time for me too... so thanks for the tips! +1 for feature addition, any Jira open? cheers, Peter - Original Message - From: "Juan Isern" To: users@tapestry.apache.org Sent: Friday, 9 April, 2010 08:09:40 GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: Tweaking an AjaxFormLoop Robert, following your recomendation finally implemented a component that does basically nothing but register itself as a trigger and has an id assigned by tap as well. On the client side, I have a global map and a function triggerRowInjector(triggerId) so that I can inject rows selectively. As for the effect thing, you can see that they're hardcoded in the function Tapestry.Initializer.formLoopRemoveLink so I overrode it making them consistent. I'm using tapestry 5.1.0.5, so I expect this "solution" to be broken by... 5.2, maybe? :P Robert Zeigler wrote: > > That just sounds like you're asking for trouble down the road, > though. ;) > You're effectively relying on implementation details of the component. > It'll break if: >* AjaxFormLoop changes the id of the contained RowInjector component >* You want more than one AjaxFormLoop on the page > > I'll grant you that it works... for now. :) And it's the sort of > solution I might put in projects that I write for myself, but not a > solution I would put into a project I write for clients. > > It's probably worth submitting a jira for a feature addition to make > this sort of functionality easier/more robust. > > Robert > > On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: > >> I've done something similar without much hacking. In my case I have >> an autocomplete field in each row, and when a selection is made I >> needed to add a new row automatically so the user can enter the next >> item. I found that the row injector always has the same name, so I >> just call the trigger function defined in tapestry.js when I want to >> add the new row. The addRow parameter is empty so the link doesn't >> render, but the trigger still does. >> >> >> >>> t:mixins="autocomplete2" t:afterUpdateElement="itemSelected"/> >> >>... >> >> >> >> function itemSelected() { >>$("rowInjector").trigger(); >> } >> >> You may notice that I'm using my own autocomplete mixin, which I had >> to make to expose the afterUpdateElement event, but if you've got >> some other logic that invokes the adding of a row the idea should be >> the same. >> >> Hope this helps, >> Brian >> >> >> >> From: Juan Isern [juanis...@gmail.com] >> Sent: Thursday, April 08, 2010 6:43 PM >> To: users@tapestry.apache.org >> Subject: Re: Tweaking an AjaxFormLoop >> >> Robert, I've got to say that you gave me the answer that I feared >> most. >> >> Hehe, REALLY thanks for your tips, I knew already that sooner or >> later I had >> to hack into tapestry.js >> >> Cheers! >> >> >> Robert Zeigler wrote: >>> >>> >>> On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: >>> >>>> What I would like to do is to trigger an "addRow" event by executing >>>> some >>>> javascript (that will be invoked when an upload finishes). I thought >>>> of >>>> simulating a click event on an invisible "add row" link but I'm sure >>>> there's >>>> a prettier solution out there. >>>> >>> >>> There are other ways to do it, although I'm not sure I would call >>> them >>> "prettier". :) >>> AjaxFormLoop places an "AjaxFormLoopContext" object into the >>> environment when it renders. >>> You can access this object and add a call to "addAddRowTrigger". >>> That >>> part is pretty. The main issue (for you) is that tapestry then >>> assumes >>> that the trigger is going to be invoked on the "click" action, which >>> isn't what you want in this case. >>> There's a way around it, and that's where things get uglier. You can >>> monkey patch tapestry.js to override >>> Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. >>> This is typically how I've implemented custom "add row" >>> functionality. >>> >>> It might be a nifty ch
Re: Tweaking an AjaxFormLoop
Robert, following your recomendation finally implemented a component that does basically nothing but register itself as a trigger and has an id assigned by tap as well. On the client side, I have a global map and a function triggerRowInjector(triggerId) so that I can inject rows selectively. As for the effect thing, you can see that they're hardcoded in the function Tapestry.Initializer.formLoopRemoveLink so I overrode it making them consistent. I'm using tapestry 5.1.0.5, so I expect this "solution" to be broken by... 5.2, maybe? :P Robert Zeigler wrote: > > That just sounds like you're asking for trouble down the road, > though. ;) > You're effectively relying on implementation details of the component. > It'll break if: >* AjaxFormLoop changes the id of the contained RowInjector component >* You want more than one AjaxFormLoop on the page > > I'll grant you that it works... for now. :) And it's the sort of > solution I might put in projects that I write for myself, but not a > solution I would put into a project I write for clients. > > It's probably worth submitting a jira for a feature addition to make > this sort of functionality easier/more robust. > > Robert > > On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: > >> I've done something similar without much hacking. In my case I have >> an autocomplete field in each row, and when a selection is made I >> needed to add a new row automatically so the user can enter the next >> item. I found that the row injector always has the same name, so I >> just call the trigger function defined in tapestry.js when I want to >> add the new row. The addRow parameter is empty so the link doesn't >> render, but the trigger still does. >> >> >> >>> t:mixins="autocomplete2" t:afterUpdateElement="itemSelected"/> >> >>... >> >> >> >> function itemSelected() { >>$("rowInjector").trigger(); >> } >> >> You may notice that I'm using my own autocomplete mixin, which I had >> to make to expose the afterUpdateElement event, but if you've got >> some other logic that invokes the adding of a row the idea should be >> the same. >> >> Hope this helps, >> Brian >> >> >> >> From: Juan Isern [juanis...@gmail.com] >> Sent: Thursday, April 08, 2010 6:43 PM >> To: users@tapestry.apache.org >> Subject: Re: Tweaking an AjaxFormLoop >> >> Robert, I've got to say that you gave me the answer that I feared >> most. >> >> Hehe, REALLY thanks for your tips, I knew already that sooner or >> later I had >> to hack into tapestry.js >> >> Cheers! >> >> >> Robert Zeigler wrote: >>> >>> >>> On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: >>> >>>> What I would like to do is to trigger an "addRow" event by executing >>>> some >>>> javascript (that will be invoked when an upload finishes). I thought >>>> of >>>> simulating a click event on an invisible "add row" link but I'm sure >>>> there's >>>> a prettier solution out there. >>>> >>> >>> There are other ways to do it, although I'm not sure I would call >>> them >>> "prettier". :) >>> AjaxFormLoop places an "AjaxFormLoopContext" object into the >>> environment when it renders. >>> You can access this object and add a call to "addAddRowTrigger". >>> That >>> part is pretty. The main issue (for you) is that tapestry then >>> assumes >>> that the trigger is going to be invoked on the "click" action, which >>> isn't what you want in this case. >>> There's a way around it, and that's where things get uglier. You can >>> monkey patch tapestry.js to override >>> Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. >>> This is typically how I've implemented custom "add row" >>> functionality. >>> >>> It might be a nifty change to enable a second form of the >>> "addAddRowTrigger" that takes, say, a js callback name as a 2nd >>> argument. Or perhaps some flag triggering whether the first argument >>> is an id or a callback. In any event, the initializer could then >>> check for the appropriate condition, and if the condit
Re: Tweaking an AjaxFormLoop
That just sounds like you're asking for trouble down the road, though. ;) You're effectively relying on implementation details of the component. It'll break if: * AjaxFormLoop changes the id of the contained RowInjector component * You want more than one AjaxFormLoop on the page I'll grant you that it works... for now. :) And it's the sort of solution I might put in projects that I write for myself, but not a solution I would put into a project I write for clients. It's probably worth submitting a jira for a feature addition to make this sort of functionality easier/more robust. Robert On Apr 8, 2010, at 4/89:20 PM , Brian Heston wrote: I've done something similar without much hacking. In my case I have an autocomplete field in each row, and when a selection is made I needed to add a new row automatically so the user can enter the next item. I found that the row injector always has the same name, so I just call the trigger function defined in tapestry.js when I want to add the new row. The addRow parameter is empty so the link doesn't render, but the trigger still does. t:mixins="autocomplete2" t:afterUpdateElement="itemSelected"/> ... function itemSelected() { $("rowInjector").trigger(); } You may notice that I'm using my own autocomplete mixin, which I had to make to expose the afterUpdateElement event, but if you've got some other logic that invokes the adding of a row the idea should be the same. Hope this helps, Brian From: Juan Isern [juanis...@gmail.com] Sent: Thursday, April 08, 2010 6:43 PM To: users@tapestry.apache.org Subject: Re: Tweaking an AjaxFormLoop Robert, I've got to say that you gave me the answer that I feared most. Hehe, REALLY thanks for your tips, I knew already that sooner or later I had to hack into tapestry.js Cheers! Robert Zeigler wrote: On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: What I would like to do is to trigger an "addRow" event by executing some javascript (that will be invoked when an upload finishes). I thought of simulating a click event on an invisible "add row" link but I'm sure there's a prettier solution out there. There are other ways to do it, although I'm not sure I would call them "prettier". :) AjaxFormLoop places an "AjaxFormLoopContext" object into the environment when it renders. You can access this object and add a call to "addAddRowTrigger". That part is pretty. The main issue (for you) is that tapestry then assumes that the trigger is going to be invoked on the "click" action, which isn't what you want in this case. There's a way around it, and that's where things get uglier. You can monkey patch tapestry.js to override Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. This is typically how I've implemented custom "add row" functionality. It might be a nifty change to enable a second form of the "addAddRowTrigger" that takes, say, a js callback name as a 2nd argument. Or perhaps some flag triggering whether the first argument is an id or a callback. In any event, the initializer could then check for the appropriate condition, and if the condition is met, the initializer would delegate the setup to the callback, passing in the row injector, rather than assuming a click. If there's enough interest in something like this, I would be willing to do the work to add it to the framework (the exact api would need to be worked out, though). The same question could apply to any client-side ajax behavior, like refreshing zones. Is there any way to do it programmatically via javascript? The best answer here is to take a look for yourself through (mainly) the tapestry.js file. But, yes, you can refresh zones in non-default ways; the trick (as with AjaxFormLoop above) is getting a handle to the runtime js objects. Another thing: the javascript effect displayed when a row is added/ removed behaves in a somewhat weird fashion. Can be this effect be disabled or configured? http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html Check out the "show" parameter. Thanks a lot! -- View this message in context: http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28182870.html Sent from the Tapestry - User mailing list archive at Nabble.com. - 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 comman
RE: Tweaking an AjaxFormLoop
I've done something similar without much hacking. In my case I have an autocomplete field in each row, and when a selection is made I needed to add a new row automatically so the user can enter the next item. I found that the row injector always has the same name, so I just call the trigger function defined in tapestry.js when I want to add the new row. The addRow parameter is empty so the link doesn't render, but the trigger still does. ... function itemSelected() { $("rowInjector").trigger(); } You may notice that I'm using my own autocomplete mixin, which I had to make to expose the afterUpdateElement event, but if you've got some other logic that invokes the adding of a row the idea should be the same. Hope this helps, Brian From: Juan Isern [juanis...@gmail.com] Sent: Thursday, April 08, 2010 6:43 PM To: users@tapestry.apache.org Subject: Re: Tweaking an AjaxFormLoop Robert, I've got to say that you gave me the answer that I feared most. Hehe, REALLY thanks for your tips, I knew already that sooner or later I had to hack into tapestry.js Cheers! Robert Zeigler wrote: > > > On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: > >> What I would like to do is to trigger an "addRow" event by executing >> some >> javascript (that will be invoked when an upload finishes). I thought >> of >> simulating a click event on an invisible "add row" link but I'm sure >> there's >> a prettier solution out there. >> > > There are other ways to do it, although I'm not sure I would call them > "prettier". :) > AjaxFormLoop places an "AjaxFormLoopContext" object into the > environment when it renders. > You can access this object and add a call to "addAddRowTrigger". That > part is pretty. The main issue (for you) is that tapestry then assumes > that the trigger is going to be invoked on the "click" action, which > isn't what you want in this case. > There's a way around it, and that's where things get uglier. You can > monkey patch tapestry.js to override > Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. > This is typically how I've implemented custom "add row" functionality. > > It might be a nifty change to enable a second form of the > "addAddRowTrigger" that takes, say, a js callback name as a 2nd > argument. Or perhaps some flag triggering whether the first argument > is an id or a callback. In any event, the initializer could then > check for the appropriate condition, and if the condition is met, the > initializer would delegate the setup to the callback, passing in the > row injector, rather than assuming a click. If there's enough > interest in something like this, I would be willing to do the work to > add it to the framework (the exact api would need to be worked out, > though). > > >> The same question could apply to any client-side ajax behavior, like >> refreshing zones. Is there any way to do it programmatically via >> javascript? >> > > The best answer here is to take a look for yourself through (mainly) > the tapestry.js file. > But, yes, you can refresh zones in non-default ways; the trick (as > with AjaxFormLoop above) is getting a handle to the runtime js objects. > >> Another thing: the javascript effect displayed when a row is added/ >> removed >> behaves in a somewhat weird fashion. Can be this effect be disabled or >> configured? >> > > http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html > Check out the "show" parameter. > >> Thanks a lot! >> -- >> View this message in context: >> http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28182870.html >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> ----- >> 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 > > > -- View this message in context: http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28186610.html Sent from the Tapestry - User mailing list archive at Nabble.com. - 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: Tweaking an AjaxFormLoop
Robert, I've got to say that you gave me the answer that I feared most. Hehe, REALLY thanks for your tips, I knew already that sooner or later I had to hack into tapestry.js Cheers! Robert Zeigler wrote: > > > On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: > >> What I would like to do is to trigger an "addRow" event by executing >> some >> javascript (that will be invoked when an upload finishes). I thought >> of >> simulating a click event on an invisible "add row" link but I'm sure >> there's >> a prettier solution out there. >> > > There are other ways to do it, although I'm not sure I would call them > "prettier". :) > AjaxFormLoop places an "AjaxFormLoopContext" object into the > environment when it renders. > You can access this object and add a call to "addAddRowTrigger". That > part is pretty. The main issue (for you) is that tapestry then assumes > that the trigger is going to be invoked on the "click" action, which > isn't what you want in this case. > There's a way around it, and that's where things get uglier. You can > monkey patch tapestry.js to override > Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. > This is typically how I've implemented custom "add row" functionality. > > It might be a nifty change to enable a second form of the > "addAddRowTrigger" that takes, say, a js callback name as a 2nd > argument. Or perhaps some flag triggering whether the first argument > is an id or a callback. In any event, the initializer could then > check for the appropriate condition, and if the condition is met, the > initializer would delegate the setup to the callback, passing in the > row injector, rather than assuming a click. If there's enough > interest in something like this, I would be willing to do the work to > add it to the framework (the exact api would need to be worked out, > though). > > >> The same question could apply to any client-side ajax behavior, like >> refreshing zones. Is there any way to do it programmatically via >> javascript? >> > > The best answer here is to take a look for yourself through (mainly) > the tapestry.js file. > But, yes, you can refresh zones in non-default ways; the trick (as > with AjaxFormLoop above) is getting a handle to the runtime js objects. > >> Another thing: the javascript effect displayed when a row is added/ >> removed >> behaves in a somewhat weird fashion. Can be this effect be disabled or >> configured? >> > > http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html > Check out the "show" parameter. > >> Thanks a lot! >> -- >> View this message in context: >> http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28182870.html >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> - >> 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 > > > -- View this message in context: http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28186610.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tweaking an AjaxFormLoop
On Apr 8, 2010, at 4/81:48 PM , Juan Isern wrote: What I would like to do is to trigger an "addRow" event by executing some javascript (that will be invoked when an upload finishes). I thought of simulating a click event on an invisible "add row" link but I'm sure there's a prettier solution out there. There are other ways to do it, although I'm not sure I would call them "prettier". :) AjaxFormLoop places an "AjaxFormLoopContext" object into the environment when it renders. You can access this object and add a call to "addAddRowTrigger". That part is pretty. The main issue (for you) is that tapestry then assumes that the trigger is going to be invoked on the "click" action, which isn't what you want in this case. There's a way around it, and that's where things get uglier. You can monkey patch tapestry.js to override Tapestry.Initializer.ajaxFormLoop, and make it behave how you want. This is typically how I've implemented custom "add row" functionality. It might be a nifty change to enable a second form of the "addAddRowTrigger" that takes, say, a js callback name as a 2nd argument. Or perhaps some flag triggering whether the first argument is an id or a callback. In any event, the initializer could then check for the appropriate condition, and if the condition is met, the initializer would delegate the setup to the callback, passing in the row injector, rather than assuming a click. If there's enough interest in something like this, I would be willing to do the work to add it to the framework (the exact api would need to be worked out, though). The same question could apply to any client-side ajax behavior, like refreshing zones. Is there any way to do it programmatically via javascript? The best answer here is to take a look for yourself through (mainly) the tapestry.js file. But, yes, you can refresh zones in non-default ways; the trick (as with AjaxFormLoop above) is getting a handle to the runtime js objects. Another thing: the javascript effect displayed when a row is added/ removed behaves in a somewhat weird fashion. Can be this effect be disabled or configured? http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html Check out the "show" parameter. Thanks a lot! -- View this message in context: http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28182870.html Sent from the Tapestry - User mailing list archive at Nabble.com. - 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
Tweaking an AjaxFormLoop
Hi people, I hope you're doing okay. I'd like to compliment the people that designed Tapestry, it's just great. It turns out that when I'm thinking of a possible solution to a complex problem, it's already implemented as a component or part of the framework. So, kudos to them. (as a suggestion: if the documentation were a little more complete/centralized it'd have an enormous positive impact) So, regarding my question, I was implementing an image upload component based on Uploadify (http://www.uploadify.com/) and an ajaxformloop fits almost perfectly. What I would like to do is to trigger an "addRow" event by executing some javascript (that will be invoked when an upload finishes). I thought of simulating a click event on an invisible "add row" link but I'm sure there's a prettier solution out there. The same question could apply to any client-side ajax behavior, like refreshing zones. Is there any way to do it programmatically via javascript? Another thing: the javascript effect displayed when a row is added/removed behaves in a somewhat weird fashion. Can be this effect be disabled or configured? Thanks a lot! -- View this message in context: http://old.nabble.com/Tweaking-an-AjaxFormLoop-tp28182870p28182870.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org