Yeah, checking for the _ERROR_MESSAGE* keys is the right way to go, would be great if you could create a jira issue so this doesn't get lost.
Regards Scott HotWax Media http://www.hotwaxmedia.com On 17/07/2011, at 7:56 AM, Jonatan Soto wrote: > Well, I did a little read on the jquery ajax documentation ( > http://api.jquery.com/jQuery.ajax/) and some of my assertions were wrong. > It is definitively not related to > the CommonEvents#jsonResponseFromRequestAttributes. I felt stupid when I > realized that the result the controller returns has nothing to do with the > ajax callbacks :) > > According to this doc the error callback is: > "A function to be called if the request fails...." > > In the case I'm exposing, obviously the request is not failing so the error > I'm getting should be handled in the success callback. Please, tell me if > there is another way to do it. > I found a js function in the CheckoutProcess.js called getServerError(...) > which is never invoked. I think it should be included in the success > callback like the following code: > > (chekoutProcess.js) > > // Check server side error > function getServerError(data) { > var serverErrorHash = []; > var serverError = ""; > if (data._ERROR_MESSAGE_LIST_ != undefined) { > serverErrorHash = data._ERROR_MESSAGE_LIST_; > jQuery.each(serverErrorHash, function(i, error) { > serverError += error.message + '<br/>'; > }); > } > if (data._ERROR_MESSAGE_ != undefined) { > serverError = data._ERROR_MESSAGE_; > } > return serverError; > } > > function createUpdateCustomerAndShippingAddress() { > var result = false; > jQuery.ajax({ > url: 'createUpdateShippingAddress', > type: 'POST', > dataType: 'json', > async: false, > data: jQuery('#shippingForm').serialize(), > success: function(json) { > var serverError = getServerError(json); > if (!serverError) { > jQuery('#shippingFormServerError').fadeOut('fast'); > // Process Shipping data response. > jQuery('#shipToPartyId').val(json.partyId); > jQuery('#billToPartyId').val(json.partyId); > jQuery('#shipToContactMechId').val(json.contactMechId); > > jQuery('#shipToPhoneContactMechId').val(json.phoneContactMechId); > jQuery('#emailContactMechId').val(json.emailContactMechId); > > //jQuery('#completedShippingMethod').html(json.shippingDescription); > updateShippingSummary(); > getShipOptions(); > result = true; > } else { > jQuery('#shippingFormServerError').html(serverError); > jQuery('#shippingFormServerError').css("display","block"); > result = false; > } > }, > error: function(error) { > if (error != "") { > jQuery('#shippingFormServerError').html(error); > } > result = false; > } > }); > return result; > } > > Now with this modifications I am showing the server side error messages > correctly. > > > HTH > > > On Sat, Jul 16, 2011 at 8:28 PM, Jonatan Soto <seniledemen...@gmail.com>wrote: > >> Hi BJ, >> >> The setAnonuserLogin is an ECA triggered before. The problem is after it if >> I'm not wrong. >> >> Look at: >> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >> ServiceDispatcher.java:599:INFO ] Sync service >> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in [112] >> milliseconds with response [{errorMessageList={Area code is missing, Falta >> Teléfono de Contacto}, responseMessage=error}] >> ... >> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >> RequestHandler.java:639:INFO ] Ran Event >> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] from >> [request], result is [success] >> >> The service that is called from ajax is returning 'error' but the chained >> json request is returning 'success'. I guess this is the problem. >> >> Thanks anyway! >> >> >> On Sat, Jul 16, 2011 at 8:18 PM, BJ Freeman <bjf...@free-man.net> wrote: >> >>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>> response [{responseMessage=success}] >>> >>> it is evaluating a good lognin. this is where to debug. >>> >>> Jonatan Soto sent the following on 7/16/2011 10:59 AM: >>>> Hi all, >>>> >>>> I am customizing the onePageCheckout (the anonymous part) and I found >>>> something strange. I've changed the client-side validation in order to >>> allow >>>> the customer to only introduce the phone, cell phone or both. But on >>>> server-side I didn't change anything in the PartyContactMechMapProcs.xml >>>> yet. So, it is throwing an error of course, but the ajax handler does >>> not >>>> consider it as an error. It always executes the success ajax handler! >>>> >>>> This is the stack trace: >>>> >>>> 2011-07-16 19:44:35,266 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:141:INFO ] [[[createUpdateShippingAddress] Request >>>> Begun, encoding=[UTF-8]- total:0.0,since last(Begin):0.0]] >>>> 2011-07-16 19:44:35,283 (http-0.0.0.0-8443-2) [ >>>> ConfigXMLReader.java:120:INFO ] controller loaded: 0.0030s, 281 >>> requests, >>>> 96 views in jndi:/0.0.0.0/ecomm/traditional/WEB-INF/controller.xml >>>> 2011-07-16 19:44:35,286 (http-0.0.0.0-8443-2) [ >>>> ServiceEcaRule.java:150:INFO ] Running Service ECA Service: >>>> setAnonUserLogin, triggered by rule on Service: >>>> createUpdateCustomerAndShippingAddress >>>> 2011-07-16 19:44:35,392 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/setAnonUserLogin] finished in [105] milliseconds with >>>> response [{responseMessage=success}] >>>> 2011-07-16 19:44:35,396 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:374:WARN ] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.setRollbackOnly] Calling transaction setRollbackOnly; >>> this >>>> stack trace shows where this is happening: >>>> Exception: java.lang.Exception >>>> Message: Error in simple-method [Create/Update Customer, Shipping >>> Address >>>> and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Error in simple-method [Create/Update Customer, >>>> Shipping Address and other contact details. >>>> >>> [file:/home/jsoto/workspace/ofbizcustom/applications/order/script/org/ofbiz/order/order/CheckoutServices.xml#createUpdateCustomerAndShippingAddress]]: >>>> ; {Area code is missing, Falta Teléfono de Contacto} >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:374) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:316) >>>> org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:870) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:160) >>>> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:142) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:78) >>>> >>> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:53) >>>> >>> org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761) >>>> >>> _$gen.file_58$.home.jsoto.workspace.ofbizcustom.applications.order.servicedef.services_95$checkout_46$xml_35$createUpdateCustomerAndShippingAddress.runSync(file:/home/jsoto/workspace/ofbizcustom/applications/order/servicedef/services_checkout.xml#createUpdateCustomerAndShippingAddress:24) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:543:ERROR] Error in Service >>>> [createUpdateCustomerAndShippingAddress]: Area code is missing, Falta >>>> Teléfono de Contacto >>>> 2011-07-16 19:44:35,397 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:338:ERROR] >>>> ---- exception report >>>> ---------------------------------------------------------- >>>> [TransactionUtil.rollback] >>>> Exception: java.lang.Exception >>>> Message: Stack Trace >>>> ---- stack trace >>>> --------------------------------------------------------------- >>>> java.lang.Exception: Stack Trace >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:337) >>>> >>> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:314) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:547) >>>> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226) >>>> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165) >>>> >>> org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336) >>>> >>> org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:638) >>>> >>> org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:384) >>>> org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224) >>>> org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:637) >>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:338) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >>>> >>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >>>> >>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >>>> >>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >>>> >>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) >>>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>>> >>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >>>> >>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554) >>>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) >>>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>>> java.lang.Thread.run(Thread.java:619) >>>> >>> -------------------------------------------------------------------------------- >>>> >>>> 2011-07-16 19:44:35,398 (http-0.0.0.0-8443-2) [ >>>> TransactionUtil.java:348:INFO ] [TransactionUtil.rollback] transaction >>>> rolled back >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> ServiceDispatcher.java:599:INFO ] Sync service >>>> [traditional#JF/createUpdateCustomerAndShippingAddress] finished in >>> [112] >>>> milliseconds with response [{errorMessageList={Area code is missing, >>> Falta >>>> Teléfono de Contacto}, responseMessage=error}] >>>> 2011-07-16 19:44:35,399 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [service:#createUpdateCustomerAndShippingAddress] from [request], result >>> is >>>> [error] >>>> 2011-07-16 19:44:35,495 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:425:ERROR] Request createUpdateShippingAddress >>> caused an >>>> error with the following message: {Area code is missing, Falta Teléfono >>> de >>>> Contacto} >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:524:INFO ] [RequestHandler.doRequest]: Response is a >>>> chained request. sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,496 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:167:INFO ] [RequestHandler]: Chain in place: >>>> requestUri=json overrideViewUri=null >>>> sessionId=4D2FA44B2DA6BCB7E2D9BE245F808E22.jvm1 >>>> 2011-07-16 19:44:35,504 (http-0.0.0.0-8443-2) [ >>>> RequestHandler.java:639:INFO ] Ran Event >>>> [java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes] >>> from >>>> [request], result is [success] >>>> 2011-07-16 19:44:35,556 (http-0.0.0.0-8443-2) [ >>>> ServerHitBin.java:627:INFO ] Visit delegatorName=default#JF, >>> ServerHitBin >>>> delegatorName=default#JF >>>> 2011-07-16 19:44:35,604 (http-0.0.0.0-8443-2) [ >>>> SequenceUtil.java:337:INFO ] Got bank of sequenced IDs for >>> [ServerHitBin]; >>>> curSeqId=53390, maxSeqId=53400, bankSize=10 >>>> 2011-07-16 19:44:35,653 (http-0.0.0.0-8443-2) [ >>>> ControlServlet.java:324:INFO ] [[[createUpdateShippingAddress] Request >>> Done- >>>> total:0.386,since last([createUpdateShip...):0.386]] >>>> >>>> >>>> >>> ----------------------------------------------------------------------------------------------- >>>> >>>> After a bit of investigation I found this: >>>> >>>> The event 'createUpdateCustomerAndShippingAddress' is returning an error >>> as >>>> a result but since the request is chained (with a json request) the >>>> controller takes the response from the event >>>> 'java:org.ofbiz.common.CommonEvents#jsonResponseFromRequestAttributes' >>> which >>>> is always 'success'. So that's why I figure out the ajax error handler >>> is >>>> never invoked. >>>> >>>> What do you think? >>>> >>>> For further details, I am using a 3 months old trunk version with MySql. >>>> I've checked out the latest version >>>> of CommonEvents#jsonResponseFromRequestAttributes in the SVN, still the >>> same >>>> code as I have. >>>> >>>> Thanks in advance. >>>> >>> >> >> >> >> -- >> ----- >> >> Jonatan Soto >> > > > > -- > ----- > > Jonatan Soto
smime.p7s
Description: S/MIME cryptographic signature