You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shahid Shaikh <ss...@yahoo.com.INVALID> on 2014/08/22 03:31:56 UTC

ZoneUpdater

Fellow Tapestry Users,

I have the following code in Tapestry

 <t:loop source="ubForm.conditioncodes" value="conditioncode" index="conditionindex" encoder="conditionCodeEncoder">
  <t:zone id="conditionZone" t:id="conditionZone">
      <td>
         <INPUT t:type="TextField" maxlength="2" t:clientEvent="change" 
             t:event="updateConditionCode" t:zone="conditionZone" 
             t:clientid="${getConditionCodeId('conditioncode', conditionindex)}" t:value="conditioncode.conditioncode" 
             t:mixins="ZoneUpdater" style="width:90%; height:25px; border:none;" />
      </td>
      </t:zone>
      </t:loop>

Bascially the issue i am running into is if the user goes and backspaces the contents of the textfield, my event , updateConditionCode fires, but the parms passed into the event are null!

Here is my code, had to tweak ZoneUpdater.js so i could include the id of the control that triggered the event

(function($) {
window.T5JQZoneUpdater = function(spec) {
var elementId = spec.elementId;
var element = document.getElementById(elementId);
var url = spec.url;
var $zone = $('#' + spec.zone);

var updateZone = function() {
var updatedUrl = url;
var params = {};

params.param = element.value;
params.id = elementId;
params.target = event.target.id;

$zone.tapestryZone('update', {
url : updatedUrl,
params : params
});
}

if (spec.event) {
var event = spec.event;
$(element).bind(event, updateZone);
}

return {
updateZone : updateZone
};
};
})(jQuery);

Can someone suggest a way for me to get the id of the input control that triggered the event when user clears its contents? I have seen comments about how keyup/change evnt does not appear to trigger the event but if you put spaces it does.

The goal here is if user backspaces and clears the field i wanted to use the zoneUpdater to inform my POJO to clear its contents


Thanks for your help

Re: ZoneUpdater

Posted by Lance Java <la...@googlemail.com>.
Sounds like you want to pass a context value along with the field value to
the serverside event. I'm pretty sure that ZoneUpdater doesn't support
this.

You can use the observe mixin from tapestry-stitch
http://tapestry-stitch.uklance.cloudbees.net/observedemo

(might require a tweak to use jquery /  tapestry 5.4)