You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Helbig <mi...@michael-helbig.de> on 2023/02/17 13:14:38 UTC

Problem with Ajax Form Submit and invalid Response Status

H

i am looking for some ways, how to handle failed requests or form 
submits when i am using a Ajax based communications from the client 
browser. The related request gets blocked by a firewall in between. The 
browser receives a not expected answer, but did not render or provide 
further information on the Feedback.

_Template:_

<form t:id="Dummy" t:async="true"...>

     <t:submit ...>

</t:form>

_Java Class:_

public onSuccessFromDummy() {

  task, but not executed due to failed communications...

}

How i am able to recognized from the Tapestry Pages the failed 
communication ?

Michael



Re: Problem with Ajax Form Submit and invalid Response Status

Posted by JumpStart <ge...@gmail.com>.
Hi Michael,

To date I’ve handled this more generally by letting the user know when the server cannot be reached. It’s detected by Offline.js (https://github.hubspot.com/offline/docs/welcome/), which is in in the <head> of our layout component.

	<!-- Do not move Offline items into a JavaScriptStack or a module - they work best right here, synchronously loaded. -->
	<link type="text/css" rel="stylesheet" href="${asset:offline-0.7.13/offline-theme-default.css}"/>
	<t:if test="languageEN">
		<link type="text/css" rel="stylesheet" href="${asset:offline-0.7.13/offline-language-english.css}"/>
	</t:if>
	<t:if test="languageFR">
		<link type="text/css" rel="stylesheet" href="${asset:offline-0.7.13/offline-language-french.css}"/>
	</t:if>
	<script type="text/javascript" charset="utf-8" src="${asset:offline-0.7.13/offline.js}"/>
	<script type="text/javascript" charset="utf-8" src="${asset:offline-0.7.13/offline-options.js}"/>

Offline.js doesn’t know what buttons or links the user has pressed, but it doesn't have to.

I’m also keen to hear other opinions.

Geoff

> On 22 Feb 2023, at 12:15 am, Volker Lamp <vl...@apache.org> wrote:
> 
> Hi Michael
> 
>> How i am able to recognized from the Tapestry Pages the failed 
>> communication ?
> 
> The (server-side) page class has no chance of knowing the communication failed, because the ajax request never makes it through.
> 
> So the logic would have to be on the client. If the server doesn't send a useful respond within an acceptable time, display an error message. I don't think Tapestry's client-side code has such error handling built in, but in the light of your example, it appears to a good enhancement.
> 
> Keen to hear other opinions.
> 
> Volker 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


Re: Problem with Ajax Form Submit and invalid Response Status

Posted by Volker Lamp <vl...@apache.org>.
Hi Michael

> How i am able to recognized from the Tapestry Pages the failed 
> communication ?

The (server-side) page class has no chance of knowing the communication failed, because the ajax request never makes it through.

So the logic would have to be on the client. If the server doesn't send a useful respond within an acceptable time, display an error message. I don't think Tapestry's client-side code has such error handling built in, but in the light of your example, it appears to a good enhancement.

Keen to hear other opinions.

Volker 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org