ajaxformloop and zone

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ajaxformloop and zone

squallmat
Hi,

I try to do a zone-update when adding or removing a row from an
ajaxformloop component. I have :

<thead>
<t:Zone t:id="zoneTitle" id="zoneTitle">
<t:If t:test="${displayFieldsTitle}">
<tr>
<th>${message:fieldName}</th>
<th>${message:fieldContent}</th>
<th></th>
</tr>
</t:If>
</t:Zone>
</thead>
<tbody>
<tr t:type="AjaxFormLoop" t:id="champs"
t:source="applicatifDto.ChampList" t:value="champDto"
t:encoder="champDtoEncoder">
<td><t:TextField style="width:100px;"
t:value="champDto.NomChamp" t:id="fieldName" /></td>
<td><t:TextField style="width:600px;"
t:value="champDto.ContenuChamp" t:id="fieldContent" /></td>
<td><t:RemoveRowLink>${message:deleteField}</t:RemoveRowLink></td>
<p:addRow>
<t:addrowlink>${message:addField}</t:addrowlink>
</p:addRow>
</tr>
</tbody>
</table>




And in the actions for adding and removing rows I do :

// when adding a field row
Object onAddRowFromChamps() {
ChampDto champDto = new ChampDto();
applicatifDto.getChampList().add(champDto);
if (displayFieldsTitle == false) {
displayFieldsTitle = true;
}
ajaxResponseRenderer.addRender("zoneTitle", zoneTitle);
return champDto;
}

// event handler on removing a field row
void onRemoveRowFromChamps(ChampDto champDto) {
// applicatifDto.getChampList().remove(champDto);
applicatifDto.getChampList().set(
applicatifDto.getChampList().indexOf(champDto), null);
if (applicatifDto.getChampList().isEmpty()) {
displayFieldsTitle = false;
}
ajaxResponseRenderer.addRender("zoneTitle", zoneTitle);
}


But when I launched the paged and click on "add" I got this error :

An unexpected application exception has occurred.

Method
org.apache.tapestry5.corelib.internal.HiddenFieldPositioner.discard(HiddenFieldPositioner.java:105)
may no longer be invoked.



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_1204ff7889d5.cleanupAfterPartialZoneRender(Unknown
Source)
at
$AjaxFormUpdateController_1204ff7889d1.cleanupAfterPartialZoneRender(Unknown
Source)
at
org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.renderMarkup(RenderCommandComponentEventResultProcessor.java:80)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
at
org.apache.tapestry5.corelib.components.AjaxFormLoop$10.renderMarkup(AjaxFormLoop.java:436)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
at
org.apache.tapestry5.internal.services.ajax.SingleZonePartialRendererFilter.renderMarkup(SingleZonePartialRendererFilter.java:98)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
at
org.apache.tapestry5.internal.services.ajax.AjaxResponseRendererImpl$3.renderMarkup(AjaxResponseRendererImpl.java:111)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderPartial(PageRenderQueueImpl.java:159)
at $PageRenderQueue_1204ff788947.renderPartial(Unknown Source)
at $PageRenderQueue_1204ff788940.renderPartial(Unknown Source)
at
org.apache.tapestry5.internal.services.PartialMarkupRendererTerminator.renderMarkup(PartialMarkupRendererTerminator.java:45)
at
org.got5.tapestry5.jquery.services.js.JSModule$2.renderMarkup(JSModule.java:58)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$37.renderMarkup(TapestryModule.java:2141)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$36.renderMarkup(TapestryModule.java:2125)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$35.renderMarkup(TapestryModule.java:2107)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$34.renderMarkup(TapestryModule.java:2091)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$33.renderMarkup(TapestryModule.java:2073)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at
org.apache.tapestry5.services.TapestryModule$32.renderMarkup(TapestryModule.java:2048)
at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
at $PartialMarkupRenderer_1204ff7889d7.renderMarkup(Unknown Source)
at
org.apache.tapestry5.internal.services.AjaxPartialResponseRendererImpl.renderPartialPageMarkup(AjaxPartialResponseRendererImpl.java:89)
at
$AjaxPartialResponseRenderer_1204ff7889d3.renderPartialPageMarkup(Unknown
Source)
at
org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.processResultValue(RenderCommandComponentEventResultProcessor.java:58)
at
org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.processResultValue(RenderCommandComponentEventResultProcessor.java:34)
at $ComponentEventResultProcessor_1204ff7889d6.processResultValue(Unknown
Source)
at $ComponentEventResultProcessor_1204ff7889d2.processResultValue(Unknown
Source)
at
org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler$1.processResultValue(AjaxComponentEventRequestHandler.java:80)
at
org.apache.tapestry5.internal.services.ComponentResultProcessorWrapper.handleResult(ComponentResultProcessorWrapper.java:47)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$6.handleResult(ComponentPageElementImpl.java:1089)
at
org.apache.tapestry5.internal.services.EventImpl$1.invoke(EventImpl.java:89)
at
org.apache.tapestry5.internal.services.EventImpl$1.invoke(EventImpl.java:86)
at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
... 96 more
[INFO] AppModule.TimingFilter Request time: 17 ms



And I don't see why it doesn't work.
Reply | Threaded
Open this post in threaded view
|

Re: ajaxformloop and zone

squallmat
Any help ? :(


2014-08-06 15:21 GMT+02:00 squallmat . <[hidden email]>:

> Hi,
>
> I try to do a zone-update when adding or removing a row from an
> ajaxformloop component. I have :
>
> <thead>
> <t:Zone t:id="zoneTitle" id="zoneTitle">
>  <t:If t:test="${displayFieldsTitle}">
> <tr>
> <th>${message:fieldName}</th>
>  <th>${message:fieldContent}</th>
> <th></th>
> </tr>
>  </t:If>
> </t:Zone>
> </thead>
>  <tbody>
> <tr t:type="AjaxFormLoop" t:id="champs"
> t:source="applicatifDto.ChampList" t:value="champDto"
>  t:encoder="champDtoEncoder">
> <td><t:TextField style="width:100px;"
>  t:value="champDto.NomChamp" t:id="fieldName" /></td>
> <td><t:TextField style="width:600px;"
>  t:value="champDto.ContenuChamp" t:id="fieldContent" /></td>
> <td><t:RemoveRowLink>${message:deleteField}</t:RemoveRowLink></td>
>  <p:addRow>
> <t:addrowlink>${message:addField}</t:addrowlink>
> </p:addRow>
>  </tr>
> </tbody>
> </table>
>
>
>
>
> And in the actions for adding and removing rows I do :
>
> // when adding a field row
> Object onAddRowFromChamps() {
>  ChampDto champDto = new ChampDto();
> applicatifDto.getChampList().add(champDto);
> if (displayFieldsTitle == false) {
>  displayFieldsTitle = true;
> }
> ajaxResponseRenderer.addRender("zoneTitle", zoneTitle);
>  return champDto;
> }
>
> // event handler on removing a field row
>  void onRemoveRowFromChamps(ChampDto champDto) {
> // applicatifDto.getChampList().remove(champDto);
> applicatifDto.getChampList().set(
>  applicatifDto.getChampList().indexOf(champDto), null);
> if (applicatifDto.getChampList().isEmpty()) {
>  displayFieldsTitle = false;
> }
> ajaxResponseRenderer.addRender("zoneTitle", zoneTitle);
>  }
>
>
> But when I launched the paged and click on "add" I got this error :
>
> An unexpected application exception has occurred.
>
> Method
> org.apache.tapestry5.corelib.internal.HiddenFieldPositioner.discard(HiddenFieldPositioner.java:105)
> may no longer be invoked.
>
>
>
> 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_1204ff7889d5.cleanupAfterPartialZoneRender(Unknown
> Source)
> at
> $AjaxFormUpdateController_1204ff7889d1.cleanupAfterPartialZoneRender(Unknown
> Source)
>  at
> org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.renderMarkup(RenderCommandComponentEventResultProcessor.java:80)
> at
> org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
>  at
> org.apache.tapestry5.corelib.components.AjaxFormLoop$10.renderMarkup(AjaxFormLoop.java:436)
> at
> org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
>  at
> org.apache.tapestry5.internal.services.ajax.SingleZonePartialRendererFilter.renderMarkup(SingleZonePartialRendererFilter.java:98)
> at
> org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
>  at
> org.apache.tapestry5.internal.services.ajax.AjaxResponseRendererImpl$3.renderMarkup(AjaxResponseRendererImpl.java:111)
> at
> org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
>  at
> org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderPartial(PageRenderQueueImpl.java:159)
> at $PageRenderQueue_1204ff788947.renderPartial(Unknown Source)
>  at $PageRenderQueue_1204ff788940.renderPartial(Unknown Source)
> at
> org.apache.tapestry5.internal.services.PartialMarkupRendererTerminator.renderMarkup(PartialMarkupRendererTerminator.java:45)
>  at
> org.got5.tapestry5.jquery.services.js.JSModule$2.renderMarkup(JSModule.java:58)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$37.renderMarkup(TapestryModule.java:2141)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$36.renderMarkup(TapestryModule.java:2125)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$35.renderMarkup(TapestryModule.java:2107)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$34.renderMarkup(TapestryModule.java:2091)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$33.renderMarkup(TapestryModule.java:2073)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at
> org.apache.tapestry5.services.TapestryModule$32.renderMarkup(TapestryModule.java:2048)
> at $PartialMarkupRenderer_1204ff7889d8.renderMarkup(Unknown Source)
>  at $PartialMarkupRenderer_1204ff7889d7.renderMarkup(Unknown Source)
> at
> org.apache.tapestry5.internal.services.AjaxPartialResponseRendererImpl.renderPartialPageMarkup(AjaxPartialResponseRendererImpl.java:89)
>  at
> $AjaxPartialResponseRenderer_1204ff7889d3.renderPartialPageMarkup(Unknown
> Source)
> at
> org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.processResultValue(RenderCommandComponentEventResultProcessor.java:58)
>  at
> org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.processResultValue(RenderCommandComponentEventResultProcessor.java:34)
> at $ComponentEventResultProcessor_1204ff7889d6.processResultValue(Unknown
> Source)
>  at
> $ComponentEventResultProcessor_1204ff7889d2.processResultValue(Unknown
> Source)
> at
> org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler$1.processResultValue(AjaxComponentEventRequestHandler.java:80)
>  at
> org.apache.tapestry5.internal.services.ComponentResultProcessorWrapper.handleResult(ComponentResultProcessorWrapper.java:47)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$6.handleResult(ComponentPageElementImpl.java:1089)
>  at
> org.apache.tapestry5.internal.services.EventImpl$1.invoke(EventImpl.java:89)
> at
> org.apache.tapestry5.internal.services.EventImpl$1.invoke(EventImpl.java:86)
>  at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
> ... 96 more
> [INFO] AppModule.TimingFilter Request time: 17 ms
>
>
>
> And I don't see why it doesn't work.
>
Reply | Threaded
Open this post in threaded view
|

Re: ajaxformloop and zone

duymap
Hi,

You could not call updating zone in onAddRow or onRemove(). This is my way
to do that:

1. Declare one action link in tml file:

<t:actionlink t:id="updateZoneLink"
t:clientId="updateZoneLink"
t:zone="zoneTitle"
 style="display:none"/>
2. in Java code, we callback a javascript function

onRemoveRow....() {
....
 javascriptSupport.addScript("callUpdateZone()");

}

Object onActionFromUpdateZoneLink() {
 // update your zone
return request.isXHR() ? zoneTitle.getBody() : null;
}

3. In your js file, you have to define callUPdateZone() method:

this.callUpdateZone = function() {
// send ajax to update zone
var $link = $("a[clientid*='updateZoneLink']");
 var href = $link.attr('href');
if (href.indexOf('?') != -1) {
href = href.substr(0, href.indexOf('?'));
 }
Tapestry.findZoneManager($link[0]).updateFromURL(href);
}

Hopefully it can help. Notice I used javascript Jquery. You can use
prototype to find your DOM element.

Thanks,
Duy.
Reply | Threaded
Open this post in threaded view
|

Re: ajaxformloop and zone

squallmat
thanks for your answer Chung, I tried it but when i add a row I got this
error :

No object of type
org.apache.tapestry5.services.javascript.JavaScriptSupport is available
from the Environment.


2014-08-07 10:08 GMT+02:00 Chung Khanh Duy <[hidden email]>:

> Hi,
>
> You could not call updating zone in onAddRow or onRemove(). This is my way
> to do that:
>
> 1. Declare one action link in tml file:
>
> <t:actionlink t:id="updateZoneLink"
> t:clientId="updateZoneLink"
> t:zone="zoneTitle"
>  style="display:none"/>
> 2. in Java code, we callback a javascript function
>
> onRemoveRow....() {
> ....
>  javascriptSupport.addScript("callUpdateZone()");
>
> }
>
> Object onActionFromUpdateZoneLink() {
>  // update your zone
> return request.isXHR() ? zoneTitle.getBody() : null;
> }
>
> 3. In your js file, you have to define callUPdateZone() method:
>
> this.callUpdateZone = function() {
> // send ajax to update zone
> var $link = $("a[clientid*='updateZoneLink']");
>  var href = $link.attr('href');
> if (href.indexOf('?') != -1) {
> href = href.substr(0, href.indexOf('?'));
>  }
> Tapestry.findZoneManager($link[0]).updateFromURL(href);
> }
>
> Hopefully it can help. Notice I used javascript Jquery. You can use
> prototype to find your DOM element.
>
> Thanks,
> Duy.
>
Reply | Threaded
Open this post in threaded view
|

Re: ajaxformloop and zone

duymap
Hi,

Sorry I put some wrong code @_@. The java code should be as below:

ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
@Override
 public void run(JavaScriptSupport javascriptSupport) {
javascriptSupport.addScript('callUpdateZone()");
}
});

You have to  import
org.apache.tapestry5.services.javascript.JavaScriptSupport;

Thanks,
Duy.




On Thu, Aug 7, 2014 at 4:37 PM, squallmat . <[hidden email]> wrote:

> thanks for your answer Chung, I tried it but when i add a row I got this
> error :
>
> No object of type
> org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> from the Environment.
>
>
> 2014-08-07 10:08 GMT+02:00 Chung Khanh Duy <[hidden email]>:
>
> > Hi,
> >
> > You could not call updating zone in onAddRow or onRemove(). This is my
> way
> > to do that:
> >
> > 1. Declare one action link in tml file:
> >
> > <t:actionlink t:id="updateZoneLink"
> > t:clientId="updateZoneLink"
> > t:zone="zoneTitle"
> >  style="display:none"/>
> > 2. in Java code, we callback a javascript function
> >
> > onRemoveRow....() {
> > ....
> >  javascriptSupport.addScript("callUpdateZone()");
> >
> > }
> >
> > Object onActionFromUpdateZoneLink() {
> >  // update your zone
> > return request.isXHR() ? zoneTitle.getBody() : null;
> > }
> >
> > 3. In your js file, you have to define callUPdateZone() method:
> >
> > this.callUpdateZone = function() {
> > // send ajax to update zone
> > var $link = $("a[clientid*='updateZoneLink']");
> >  var href = $link.attr('href');
> > if (href.indexOf('?') != -1) {
> > href = href.substr(0, href.indexOf('?'));
> >  }
> > Tapestry.findZoneManager($link[0]).updateFromURL(href);
> > }
> >
> > Hopefully it can help. Notice I used javascript Jquery. You can use
> > prototype to find your DOM element.
> >
> > Thanks,
> > Duy.
> >
>



--
Chung Khánh Duy
Project Support Manager
Formos
Reply | Threaded
Open this post in threaded view
|

Re: ajaxformloop and zone

squallmat
I added this callback on both add and remove functions, but when I add row
I get this error appearing on top of the windows :
"Communication with the server failed: TypeError: undefined is not a
function".

And it doesn't do it when the callback is done by the remove call. If there
were a problem loading js file it would have complained on it too. Am i
missing something ?


2014-08-07 11:41 GMT+02:00 Chung Khanh Duy <[hidden email]>:

> Hi,
>
> Sorry I put some wrong code @_@. The java code should be as below:
>
> ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
> @Override
>  public void run(JavaScriptSupport javascriptSupport) {
> javascriptSupport.addScript('callUpdateZone()");
> }
> });
>
> You have to  import
> org.apache.tapestry5.services.javascript.JavaScriptSupport;
>
> Thanks,
> Duy.
>
>
>
>
> On Thu, Aug 7, 2014 at 4:37 PM, squallmat . <[hidden email]> wrote:
>
> > thanks for your answer Chung, I tried it but when i add a row I got this
> > error :
> >
> > No object of type
> > org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> > from the Environment.
> >
> >
> > 2014-08-07 10:08 GMT+02:00 Chung Khanh Duy <[hidden email]
> >:
> >
> > > Hi,
> > >
> > > You could not call updating zone in onAddRow or onRemove(). This is my
> > way
> > > to do that:
> > >
> > > 1. Declare one action link in tml file:
> > >
> > > <t:actionlink t:id="updateZoneLink"
> > > t:clientId="updateZoneLink"
> > > t:zone="zoneTitle"
> > >  style="display:none"/>
> > > 2. in Java code, we callback a javascript function
> > >
> > > onRemoveRow....() {
> > > ....
> > >  javascriptSupport.addScript("callUpdateZone()");
> > >
> > > }
> > >
> > > Object onActionFromUpdateZoneLink() {
> > >  // update your zone
> > > return request.isXHR() ? zoneTitle.getBody() : null;
> > > }
> > >
> > > 3. In your js file, you have to define callUPdateZone() method:
> > >
> > > this.callUpdateZone = function() {
> > > // send ajax to update zone
> > > var $link = $("a[clientid*='updateZoneLink']");
> > >  var href = $link.attr('href');
> > > if (href.indexOf('?') != -1) {
> > > href = href.substr(0, href.indexOf('?'));
> > >  }
> > > Tapestry.findZoneManager($link[0]).updateFromURL(href);
> > > }
> > >
> > > Hopefully it can help. Notice I used javascript Jquery. You can use
> > > prototype to find your DOM element.
> > >
> > > Thanks,
> > > Duy.
> > >
> >
>
>
>
> --
> Chung Khánh Duy
> Project Support Manager
> Formos
>