Re: [Xsltforms-support] XSLTForms and REST
Brought to you by:
alain-couthures
From: Grégoire C. <gco...@gm...> - 2011-02-23 16:52:46
|
Hi, I don't know what the "req.status = 0" case is for, but for sure I forgot about it! The fix should be: if ((req.status != 0 && req.status < 200) || req.status >= 300) { evcontext["error-type"] = "resource-error"; subm.issueSubmitException_(evcontext, req, null); xforms.closeAction(); return; } Hope this is right, now! :-) Regards, Grégoire Le 23/02/2011 17:43, Grégoire COLBERT a écrit : > Me again! > > I found where the problem comes from! Not from the > "xforms-submit-done" event, but from my 201 return code (XSLTForms rev > 484 only expects 200). > > *Fix:* in function "XFSubmission.prototype.submit", replace: > > if (req.status != 200 && req.status != 0) { > evcontext["error-type"] = "resource-error"; > subm.issueSubmitException_(evcontext, req, null); > xforms.closeAction(); > return; > } > > with : > > if (req.status < 200 || req.status >= 300) { > evcontext["error-type"] = "resource-error"; > subm.issueSubmitException_(evcontext, req, null); > xforms.closeAction(); > return; > } > > Just tested it and it works fine! Very cool! > > Cheers, > Grégoire > > > Le 23/02/2011 17:02, Grégoire COLBERT a écrit : >> Hi! >> >> Another problem I encountered (r484) is that it only works with >> "xforms-submit-error" and not with "xforms-submit-done". >> >> Non-working (but valid) example: >> >> <xf:action ev:event="*xforms-submit-done*" >> if="event('response-status-code') = 201"> >> <xf:message>Response is 201, good!</xf:message> >> </xf:action> >> >> Working (but non-valid) example: >> >> <xf:action ev:event="*xforms-submit-error*" >> if="event('response-status-code') = 201"> >> <xf:message>Response is 201, good!</xf:message> >> </xf:action> >> >> As you know, status-codes 2xx are not errors but successes. >> >> According to: >> http://www.w3.org/TR/xforms11/#submit-evt-submit-done >> this looks like a bug. >> >> Best regards, >> Grégoire >> >> PS : Efraim is right, the 'response-body' header does something strange. >> >> Le 22/02/2011 17:14, Efraim Feinstein a écrit : >>> Hi, >>> >>> I made a little more progress understanding the failures involving >>> responses/REST errors. I'm using dataisland branch r484. >>> >>> The attached code demonstrates that if you receive an error, it will >>> invoke the error handler and show the message. >>> >>> If, however the 'response-body' event is referenced (uncomment it in >>> the example), the event handler never occurs. That may be why >>> Grégoire and I were getting different results. >>> >>> Hope this helps, >>> -Efraim >>> >>> On 02/13/2011 10:49 AM, Grégoire COLBERT wrote: >>>> Hi! >>>> >>>> Le 13/02/2011 04:30, Efraim Feinstein a écrit : >>>>> Hi, >>>>> Never mind. I see that r480 has some new code in it for response >>>>> headers. I tried it with the attached code. I'm finding that it >>>>> does give the correct 404 error message when you press the button, >>>>> but it also returns a long error message in a popup dialog when >>>>> the page is first loaded. >>>>> >>>>> The text of the error is: >>>>> XSLTForms Exception >>>>> -------------------------- >>>>> (...) >>>> >>>> I get the same initialization error, but I don't get any output >>>> (the pop-up is not displayed and no JS error is raised). >>>> >>>> I use: >>>> >>>> <xf:action ev:event="xforms-submit-done"> >>>> <xf:message><xf:output >>>> value="event('response-status-code')"/></xf:message> >>>> </xf:action> >>>> >>>> This is based on the example at : >>>> http://www.w3.org/TR/xforms11/#submit-evt-submit-done >>>> >>>> Anyway, thank you Alain for your very quick answer! >>>> >>>> Best regards, >>>> Grégoire >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: >>>> Pinpoint memory and threading errors before they happen. >>>> Find and fix more than 250 security defects in the development cycle. >>>> Locate bottlenecks in serial and parallel code that limit performance. >>>> http://p.sf.net/sfu/intel-dev2devfeb >>>> >>>> >>>> _______________________________________________ >>>> Xsltforms-support mailing list >>>> Xsl...@li... >>>> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >>>> >>> >>> >>> -- >>> --- >>> Efraim Feinstein >>> Lead Developer >>> Open Siddur Project >>> http://opensiddur.net >>> http://wiki.jewishliturgy.org >>> >>> >>> ------------------------------------------------------------------------------ >>> Index, Search & Analyze Logs and other IT data in Real-Time with Splunk >>> Collect, index and harness all the fast moving IT data generated by your >>> applications, servers and devices whether physical, virtual or in the cloud. >>> Deliver compliance at lower cost and gain new business insights. >>> Free Software Download: http://p.sf.net/sfu/splunk-dev2dev >>> >>> >>> _______________________________________________ >>> Xsltforms-support mailing list >>> Xsl...@li... >>> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >> > |