Re: Saving state when changing grid pages
Hi everyone, Just for the records I found a more simple solution for this without the javascript stuff: I also had problems that the pager did not update or jump to the new row/page when clicked on a page and all this packed in a hidden div. your tml: your java code (only relevant part): @Component(parameters = {"source=phenotypes", "row=loopPhenotype", "pagerPosition=literal:none"}) private Grid theGrid; @Property @Persist private Integer currPage; @SetupRender public void setupRender() throws Exception{ //init for the first time if(currPage==null) { currPage=1; } theGrid.setCurrentPage(currPage); //now every time a page reload occurs we point the grid to the page theGrid.setCurrentPage(currPage); } -- View this message in context: http://tapestry-users.832.n2.nabble.com/Saving-state-when-changing-grid-pages-tp5104181p5345443.html Sent from the Tapestry Users 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: Saving state when changing grid pages
Thank you so much Josh, your solution works great! It's also easy to understand. Thanks again, Paul Josh Canfield wrote: > > I whipped something up that will allow you to only submit the form > when the link is clicked. > > Add this to your form containing the grid to keep track of the page > > > Add this to your page: > > @Property > private int _page; > > @Component > private Grid _grid; > > void onSuccess() { > _grid.setCurrentPage(_page); > } > > Add this javascript to the page after the grid. > > > $$('.t-data-grid-pager a').each(function(a) { > a.observe("click", function(e) { > e.stop(); > // parse out the page number. > var page = a.href.replace(/^.*pager\/(\d+)$/, "$1"); > var form = $('personForm'); > // Hidden doesn't include the id so find by name > var pageField = form.select("[name='page']")[0]; > pageField.value = page; > > form.submit(); > }); > }); > > > Good Luck, > Josh > > -- View this message in context: http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28694125.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: Saving state when changing grid pages
I whipped something up that will allow you to only submit the form when the link is clicked. Add this to your form containing the grid to keep track of the page Add this to your page: @Property private int _page; @Component private Grid _grid; void onSuccess() { _grid.setCurrentPage(_page); } Add this javascript to the page after the grid. $$('.t-data-grid-pager a').each(function(a) { a.observe("click", function(e) { e.stop(); // parse out the page number. var page = a.href.replace(/^.*pager\/(\d+)$/, "$1"); var form = $('personForm'); // Hidden doesn't include the id so find by name var pageField = form.select("[name='page']")[0]; pageField.value = page; form.submit(); }); }); Good Luck, Josh On Wed, May 26, 2010 at 1:27 PM, des999 wrote: > > I've found a solution (that I feel is horribly inefficient, but is the best > I've got): > > I simply put onclick="$('bookDetailForm').submit()" on my checkbox, and that > way each item that's checked results in a hit back to the server to update > the bean. That way, the form is already updated when you change pages. > > It's a horrible solution, but the user-base is low so it will have to do for > now. > -- > View this message in context: > http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28685905.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 > > -- -- http://www.bodylabgym.com - a private, by appointment only, one-on-one health and fitness facility. -- http://www.ectransition.com - Quality Electronic Cigarettes at a reasonable price! -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Saving state when changing grid pages
I've found a solution (that I feel is horribly inefficient, but is the best I've got): I simply put onclick="$('bookDetailForm').submit()" on my checkbox, and that way each item that's checked results in a hit back to the server to update the bean. That way, the form is already updated when you change pages. It's a horrible solution, but the user-base is low so it will have to do for now. -- View this message in context: http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28685905.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: Saving state when changing grid pages
Thanks a lot for the help Josh, I'm still having trouble though. I've spent hours now and I think I know what I need to do, I just don't know how to do it: I need to have the page links Submit my form and then change the page. Looking at the generated html, it's just a simple anchor tag directly to the page with the component and 2nd page as context. I can't possibly be the first person to want to do something like this, but I just can't seem to find anything on it. My second thought was to use AJAX so that when a checkbox is clicked, it updates the bean in my page class - I'm just not familiar with Tapestry Ajax, so I haven't had any luck. I'll look into this further as well as a possible solution. Thanks for the help, and I'll continue to investigate GridPager and LinkSubmit to see if I can somehow make them do what I want. Paul Josh Canfield wrote: > > I don't use a grid so I could be way off, but a quick look at the > GridPager component tells me that it generates links. Since it's a > link your form isn't getting submitted it's just getting the next > page. I imagine there must be a way to make the pager submit your > form. I don't see a direct way to do it (but I just scanned the > component), but perhaps you can add an event to all the links in > t-data-grid-pager, see the linksubmit component for an example. > > -- View this message in context: http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28685316.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: Saving state when changing grid pages
I don't use a grid so I could be way off, but a quick look at the GridPager component tells me that it generates links. Since it's a link your form isn't getting submitted it's just getting the next page. I imagine there must be a way to make the pager submit your form. I don't see a direct way to do it (but I just scanned the component), but perhaps you can add an event to all the links in t-data-grid-pager, see the linksubmit component for an example. On Wed, May 26, 2010 at 8:29 AM, des999 wrote: > > TLDR: When I change pages of a grid, it doesn't update the object with > changes to the page (I select a bunch of rows, and then go to page 2, it > doesn't remember those checks) > > More details: > I have a GridDataSource that simply contains a persisted list. I have a > checkbox bound to a boolean variable in my bean. > > When I select a few rows, and then click submit - the list is updated as > expected so I can act on the checked boxes. > > However, when I change the page, the variable is not updated. > > Please let me know if any code would help and thanks for any replies! > Paul > -- > View this message in context: > http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28682342.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 > > -- -- http://www.bodylabgym.com - a private, by appointment only, one-on-one health and fitness facility. -- http://www.ectransition.com - Quality Electronic Cigarettes at a reasonable price! -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Saving state when changing grid pages
TLDR: When I change pages of a grid, it doesn't update the object with changes to the page (I select a bunch of rows, and then go to page 2, it doesn't remember those checks) More details: I have a GridDataSource that simply contains a persisted list. I have a checkbox bound to a boolean variable in my bean. When I select a few rows, and then click submit - the list is updated as expected so I can act on the checked boxes. However, when I change the page, the variable is not updated. Please let me know if any code would help and thanks for any replies! Paul -- View this message in context: http://old.nabble.com/Saving-state-when-changing-grid-pages-tp28682342p28682342.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