juhar wrote:
> Hi,
>
> I have a page with a form on it. After the user has submitted the form
> successfully (all the fields have validated ok), the server creates a
> report-file based on the form values. The file is not created as physical
> file on the server, but it is given as download to the user.
>
> Now, if the user first fills the form incorrectly, there are validator
> feedback messages shown. If the user then submits the form with correct
> values, the problem is that previous feedback error messages are not
> cleared. I can't also create a new feedback message saying something like
> "The report was created successfully." The file download response prevents
> any updating of the current page.
>
Have you tried to use a resource link with
a) an AJAX action to update your page
b) a Call-Decorator that adds "return true" to the onclick-Event.
That causes the genuine Resource-Link-Action to be done which
initiate a download.
c) Maybe also use target="_blank" in your Link-HTML. If there are
errors in your download code, you can arrange to show them in a
new situation-specific error page.
Something like:
final ResourceLink<Object> downloadPDF = new
ResourceLink<Object>("downloadPDF", pdfResource);
downloadPDF.add(new AjaxEventBehavior ("onclick") {
private static final long serialVersionUID = 1L;
@Override protected void onEvent (AjaxRequestTarget target) {
// update actions for page go here
}
@Override protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
private static final long serialVersionUID = 1L;
@Override public CharSequence decorateScript(CharSequence script) {
return script+"return true;";
}
};
}
});
This is working 1.4 code (it has to run on JBoss 4, I can't use 1.5ff),
no problems with IE8. (pdfResource is a WebResource-subclass object that
actually generates a PDF document.) IAjaxCallDecorator is gone in Wicket 6,
but there is a replacement for it; that was mentioned on this list
recently.
Joachim
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod, Roedermark, Germany
Email: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]