This looks great Lance, I'll give it a whirl in the am. Thanks.
On Thu, Oct 31, 2013 at 5:27 PM, Lance Java <lance.j...@googlemail.com>wrote: > Take a look at the onEvent mixin in tapestry-stitch > http://tapestry-stitch.uklance.cloudbees.net/oneventdemo > > > > On 31 October 2013 19:44, George Christman <gchrist...@cardaddy.com> > wrote: > > > I was semi able to get it to work using the following code, but it looks > as > > if the onDocument method doesn't have a blur event handler? > > > > > > (function() { > > define(["t5/core/events", "t5/core/dom", "t5/core/zone", "./jquery"], > > function(events, dom, zone, $) { > > int = function(spec) { > > var $field = $("#" + spec.id); > > > > $field.attr("data-update-zone", spec.zone); > > $field.attr("data-update-url", spec.url); > > > > return dom.onDocument('click', 'input[data-update-zone]', > > function() { > > var containingZone; > > > > containingZone = zone.findZone(this); > > return containingZone && > > containingZone.trigger(events.zone.refresh, { > > url: this.attribute("data-update-url"), > > parameters: { > > "t:fieldvalue": $field.val() > > } > > }); > > }); > > }; > > return int; > > }); > > > > }).call(this); > > > > > > On Thu, Oct 31, 2013 at 2:36 PM, George Christman > > <gchrist...@cardaddy.com>wrote: > > > > > I'm trying to create a mixin that on blur will grab the field value and > > > pass it to an event handler followed by a zone refresh. I continue to > > get a > > > null pointer on the zone refresh, I'm not sure what I'm missing. > > > > > > > > > tml. > > > > > > <t:textfield t:id="employeeName" value="accrualBalance.employeeTemp" > > > t:mixins="fieldUpdate" t:zone="empIdZone" updateFieldId="empId"/> > > > > > > mixins > > > > > > @Events( > > > {EventConstants.VALIDATE, "fieldUpdated" + " when 'zone' > > parameter > > > is bound"}) > > > public class FieldUpdate { > > > > > > static final String EVENT_NAME = "fieldupdate"; > > > @Environmental > > > private JavaScriptSupport jsSupport; > > > @InjectContainer > > > private ClientElement element; > > > @Parameter(required = true, defaultPrefix = > BindingConstants.LITERAL) > > > private String updateFieldId; > > > @Inject > > > private ComponentResources resources; > > > @Parameter(required = true, defaultPrefix = > BindingConstants.LITERAL) > > > private String zone; > > > > > > public void afterRender() { > > > Link link = resources.createEventLink(EVENT_NAME); > > > > > > JSONObject param = new JSONObject(); > > > param.put("id", element.getClientId()); > > > param.put("updateFieldId", updateFieldId); > > > param.put("url", link.toString()); > > > param.put("zone", zone); > > > > > > jsSupport.require("fieldupdate").with(param); > > > } > > > > > > Object onFieldUpdate(@RequestParameter(value = "t:fieldvalue", > > > allowBlank = true) final String fieldvalue) throws ValidationException > { > > > > > > CaptureResultCallback<Object> callback = new > > > CaptureResultCallback<>(); > > > > > > this.resources.triggerEvent("fieldUpdated", new > > > Object[]{fieldvalue}, callback); > > > > > > return callback.getResult(); > > > } > > > } > > > > > > > > > .js > > > > > > (function() { > > > define(["t5/core/ajax", "./jquery"], function(ajax, $) { > > > int = function(spec) { > > > var $field = $("#" + spec.id); > > > > > > return $field.bind('blur', function() { > > > return ajax(spec.url, { > > > type: "POST", > > > data: { > > > "t:fieldvalue": $field.val() > > > }, > > > contentType: "application/x-www-form-urlencoded", > > > success: function(response) { > > > return process(response); > > > } > > > }); > > > }); > > > }; > > > return int; > > > }); > > > }).call(this); > > > > > > .java > > > > > > @InjectComponenet > > > private Zone empIdZone; > > > > > > @Inject > > > private AjaxResponseRenderer ajaxResponseRenderer; > > > > > > void onFieldUpdated(String value) { > > > test = "test"; > > > ajaxResponseRenderer.addRender(empIdZone); > > > } > > > > > > > > > exception > > > > > > > > > org.apache.tapestry5.ioc.internal.OperationException trace > > > > > > - Handling Ajax 'fieldupdate' component event request for > > > timerecords/AccrualBalance:employeename. > > > > > > java.lang.NullPointerException > > > Filter Frames? > > > Stack trace: > > > > > > - > org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:929) > > > - org.apache.tapestry5.json.JSONArray.print(JSONArray.java:464) > > > - > org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:901) > > > - org.apache.tapestry5.json.JSONArray.print(JSONArray.java:464) > > > - > org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:901) > > > - org.apache.tapestry5.json.JSONObject.print(JSONObject.java:872) > > > - > org.apache.tapestry5.json.JSONObject.printValue(JSONObject.java:895) > > > - org.apache.tapestry5.json.JSONObject.print(JSONObject.java:872) > > > - > > org.apache.tapestry5.json.JSONCollection.print(JSONCollection.java:95) > > > > > > - > > > org.apache.tapestry5.internal.services.AjaxPartialResponseRendererImpl.renderPartialPageMarkup(AjaxPartialResponseRendererImpl.java:93) > > > > > > - > > > org.apache.tapestry5.internal.services.AjaxPartialResponseRendererImpl.renderPartialPageMarkup(AjaxPartialResponseRendererImpl.java:104) > > > > > > - > > > org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler.handle(AjaxComponentEventRequestHandler.java:128) > > > > > > - > > > org.apache.tapestry5.internal.services.ajax.AjaxFormUpdateFilter.handle(AjaxFormUpdateFilter.java:56) > > > > > > - > > > org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) > > > > > > > > > > > > -- > > > George Christman > > > www.CarDaddy.com > > > P.O. Box 735 > > > Johnstown, New York > > > > > > > > > > > > -- > > George Christman > > www.CarDaddy.com > > P.O. Box 735 > > Johnstown, New York > > > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York