Re: 2nd try: ajax updating components inside a For
After the update from Jesse, the test-page I mentioned in a previous thread behaves as expected. Thank you for the fix. If anyone is interested the test page java+html is as follows: package dk.atira.commonstest.pages; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; import org.apache.tapestry.html.BasePage; public abstract class NumericPage extends BasePage implements PageBeginRenderListener { @Persist public abstract String[] getRows(); public abstract void setRows(String[] rows); public abstract String getRow(); public abstract int getTheIndex(); public void pageBeginRender(PageEvent e) { if (getRows() == null){ setRows(new String[] {"foo", "bar", "baz"}); } } public void aListener(IRequestCycle cycle, int idx) { getRows()[idx] = "" + (int)(Math.random()*1); } } index="ognl:theIndex"> Update "value="ognl:components.therow.clientId"> " Ron Piterman wrote: Thanx jesse, thats great ! I guess I miss some basic understanding of how for works in ajax context, but I still didn't manager to update a single iteration - Currently it only works if you update the container of the for, and still there are some issues with multiple posts (I added a jira issue). Would you/? explain what would be the preferred way to solve this prob (updating a form inside a single iteration)? Cheers, Ron Jesse Kuhnert wrote: This should work now. I'm not entirely certain it was being handled correctly at the time you originally wrote this message but it works now. An example to look at might be http://opencomponentry.com:8080/timetracker/LocaleList.htm On 11/24/06, Ron Piterman <[EMAIL PROTECTED]> wrote: Hi all, I have a simple For loop which iterates over some object. the objects are all rendered to DirectLinks. When a DirectLink-listener is called, the clicked Item should change to "edit view" and render a Form instead of the Link. When the form is submitted, the item should render again to the Link ( "view mode"). Now the question is, how to change the code below, to do the trick with ajax. When using normal http requests the page looks like this: try ajax with list listener="listener:doCancel"/> value="ognl:currentObject.name"> and the class: public abstract class Home extends BasePage { public Object getObjects() { // return the list of obejcts } /** the value of the current iteration */ public abstract Value getCurrentObject(); @Persist public abstract Value getEditObject(); public abstract void setEditObject( Value v ); public boolean isEditMode() { return getEditObject() != null && getEditObject().equals( getCurrentObject() ); } public void edit( Long id ) { setEditObject( getObject( id ) ); } public void doSubmit() { // ... save ... and then this.setEditObject ( null ); } public void doCancel() { this.setEditObject( null ); } private Value getObject( Long id ) { // ... return the value for the given id } } Thanx in advance, Cheers, Ron - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Tlf. +45 7214 6793 · [EMAIL PROTECTED] · MSN: [EMAIL PROTECTED] Atira A/S · Niels Jernes Vej 10 · 9220 Aalborg Ø · www.atira.dk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Trouble updating component after async. directlink : clientId's generated in For-loops
Thank you for the response. That is exactly what I wanted. But ... something is still odd. I get too and mixed up updates back to in the ajax-response requests. Is this a bug or expected behaviour? _Click on first row :_ Tapestry / DojoAjaxResponseBuilder sends * (actually containing both first and second row(!) * Works fine. _Click on second row :_ * * * ie. of first row * DOJO warns: WARNING: 10:06:53 AM: No node could be found to update content in with id Insert _Click on third row :_ * * DOJO warns: WARNING: 10:05:40 AM: No node could be found to update content in with id Insert_1 /kim andyhot wrote: Sam Gendler wrote: On 11/21/06, andyhot <[EMAIL PROTECTED]> wrote: updateComponents="ognl:components.therow.clientId" Can I suggest that we get this into the docs in some way. It stumps a lot of people, including myself. http://issues.apache.org/jira/browse/TAPESTRY-1137 proposes a binding for that exact use-case, i.e. updateComponents="clientId:therow" Also, it seems like if I want to update a component by calling ResponseBuilder.updateComponent() from within a listener method, I have to give it the id of the component, rather than the clientId. In that case, does it only update the current instance of the component accessed by that id, or will it update every component that uses that id as the code iterates over a collection in some way? If it is the former, how would I update the row that follows the current row? Is it even possible? --sam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Tlf. +45 7214 6793 · [EMAIL PROTECTED] · MSN: [EMAIL PROTECTED] Atira A/S · Niels Jernes Vej 10 · 9220 Aalborg SØ · www.atira.dk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Trouble updating component after async. directlink : clientId's generated in For-loops
In a page containing elements generated by a component placed under a For-Loop component I want to be able to update a single such component/element using the very nifty "DojoAjaxResponseBuilder.updateComponent()" feature. In summary I want to have a DirectLink for each row in a table. The listener method for this DirectLink will update data, the row should be updated via the updateComponents attribute of DirectLink. But... how do I address components generated (and thus named) by a For-loop? updateComponents="therow" will work for first row updateComponents="therow_2" does not work at all (sends updates to the Insert and DirectLink components in stead! updateComponents="ognl:'therow_' + theIndex" has the same behaviour. . Hopefully this small example illustrates my issue: one column for data one for the async DirectLink to listener "aListener". This code works for the _first_ row but not the other two. *The html* index="ognl:theIndex"> Update this row! *The Page Class* import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.event.PageEvent; import dk.atira.tapestry.AbstractBasePage; public abstract class NumericPage extends AbstractBasePage { @Persist public abstract String[] getRows(); public abstract void setRows(String[] rows); public abstract String getRow(); public abstract int getTheIndex(); @Override public void pageBeginRender(PageEvent e) { if (getRows() == null){ setRows(new String[] {"foo", "bar", "baz"}); } } public void aListener(IRequestCycle cycle, int idx) { getRows()[idx] = "" + (int)(Math.random()*1); } } /thanks kim -- Tlf. +45 7214 6793 · [EMAIL PROTECTED] · MSN: [EMAIL PROTECTED] Atira A/S · Niels Jernes Vej 10 · 9220 Aalborg SØ · www.atira.dk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]