You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jens Breitenstein <ma...@j-b-s.de> on 2013/05/28 10:26:52 UTC

AjaxFormLoop + multiple Zones

Hi All!

I use the AjaxFormLoop to render a table with multiple columns and 
provide inplace-editing capabilities by replacing a particular row with 
a different block content. Now I added a Button "SAVE" outside the 
AjaxFormLoop component to save all changes made in "one transaction", 
but I only want to display the button in case a change was made. 
Therefore I defined a 2nd Zone for my Button like:

         <span t:type="zone" t:id="saveButtonZone" id="saveButtonZone">
             <t:if test="somethingModified">
                 <br/>
                 <input type="submit" name="saveGridChanges" class="btn 
btn-primary" value="${message:saveChanges}"/>
             <p:else>
                 &nbsp;
             </p:else></t:if>
         </span>


To replace a row in the AjaxFormLoop and update the button Zone 
accordingly I use an AjaxResponseRenderer (_arr):

     Object onActionFromModifyFormEvent(final long pk)
     {
         ...

         if (_request.isXHR()) {
             _arr.addRender(_zone).addRender(_zoneSaveButton);
         }
         return null;
     }

which re-renders the AjaxFormLoop (_zone) and the save button 
(_zoneSaveButton). I did this for several other methods too (e.g. 
checkbox callbacks) and everything is fine.

Unfortunately when adding the same code fragment to the AddRowLink callback

     void onAddRowFromModifiedFormEvents()
     {
         ...

         if (_request.isXHR()) {
             _arr.addRender(_zoneSaveButton);
         }
     }

Tapestry throws

Console:

Caused by: java.lang.IllegalStateException: Method 
org.apache.tapestry5.corelib.internal.HiddenFieldPositioner.discard(HiddenFieldPositioner.java:105) 
may no longer be invoked.
     at 
org.apache.tapestry5.ioc.internal.util.OneShotLock.innerCheck(OneShotLock.java:58)
     at 
org.apache.tapestry5.ioc.internal.util.OneShotLock.lock(OneShotLock.java:71)
     at 
org.apache.tapestry5.corelib.internal.HiddenFieldPositioner.discard(HiddenFieldPositioner.java:105)
     at 
org.apache.tapestry5.internal.services.ajax.AjaxFormUpdateControllerImpl.cleanupAfterPartialZoneRender(AjaxFormUpdateControllerImpl.java:114)
     at 
$AjaxFormUpdateController_13023b225f815e65.cleanupAfterPartialZoneRender(Unknown 
Source)
     at 
$AjaxFormUpdateController_13023b225f815e5e.cleanupAfterPartialZoneRender(Unknown 
Source)
     at


WebSite:

An unexpected application exception has occurred.

org.apache.tapestry5.runtime.ComponentEventException
Method 
org.apache.tapestry5.corelib.internal.HiddenFieldPositioner.discard(HiddenFieldPositioner.java:105) 
may no longer be invoked.
context
eventType: inject
location: 
classpath:org/apache/tapestry5/corelib/components/AjaxFormLoop.tml, line 8

3    <t:formfragment t:id="fragment" element="prop:element" visible="true">
4    <t:delegate to="block:ajaxResponse"/>
5    </t:formfragment>
6
7    <t:block id="tail">
8    <t:forminjector element="prop:element" t:id="rowInjector" 
show="inherit:show" context="inherit:context">
9    <t:delegate to="prop:addRow"/>
10    <t:block id="defaultAddRow">
11    <t:addrowlink>Add row</t:addrowlink>
12    </t:block>
13    </t:forminjector><t:formfragment t:id="fragment" 
element="prop:element" visible="true">



Any idea what I am doing wrong or how to work around it, preferably with 
Tapestry? Last resort is something like jquery/live, adding change 
callbacks to all fields aso, which I want to avoid, if possible.

Thanks in advance

Jens