Thanks!
I was able to make this work. Do you think my solution is too complex Thiago?
/external/TrackSegmentsExport (the form):
==========================================
@Persist(PersistenceConstants.FLASH)
boolean download;
@AfterRender
void afterRender() {
if (download) {
javaScriptSupport.require("util/util").invoke("windowLocation").with("/external/TrackSegmentsExportDownload");
}
}
Object onSuccessFromTrackExpForm() throws ParserConfigurationException,
JAXBException, TransformerException, IOException {
download = true;
return null;
}
Utils.js:
==========================================
Util.windowLocation = function (href) {
window.location = href;
};
/external/TrackSegmentsExportDownload:
==========================================
StreamResponse onActivate() {
...
return new AttachmentStreamResponse(stream, "TrackSegmentsExport.gpx");
From: Thiago H de Paula Figueiredo [via Apache Tapestry Mailing List Archives]
[mailto:[email protected]]
Sent: mandag 4. september 2017 13:48
To: Svein-Erik Løken <[email protected]>
Subject: Re: Cannot clear validation errors when form onSuccess returns a
StreamResponse
Hi!
This is due to HTTP, not Tapestry itself: you cannot have two different
responses to the same request. So, you either rerender the page to clear
the errors (which calling form.clearErrors() is actually doing, even if you
cannot see the results) or returns a binary download (StreamResponse), but
not both.
You'll need to write some JavaScript for that, so either the form
submission or the file download request is done through JavaScript. Maybe
the easiest solution, even if not pretty, is to return null in onSuccess(),
rendering a <script> tag with a window.location = [URL which triggers the
download] statement.
On Mon, Sep 4, 2017 at 4:41 AM, Svein-Erik Løken
</user/SendEmail.jtp?type=node&node=5733608&i=0> wrote:
> If I record an error for my <t:palette> I cannot find out how to clear
> errors (tried form.clearErrors()).
>
> Because onSuccess returns a StreamResponse to download a file the form
> need to have async="false"
>
> The form should stay open so user can download several files with
> different parameters.
>
> Can anyone help!
>
> S-E
>
--
Thiago
________________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Cannot-clear-validation-errors-when-form-onSuccess-returns-a-StreamResponse-tp5733607p5733608.html
To unsubscribe from mailto:[email protected] Mailing List Archives,
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4.
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml