Re: File download and Exception handling using a servlet.

2012-03-14 Thread George Georgovassilis
Hi Albert,

The way I did this is by reading SubmitCompleteEvent.getResults(), i.e.

uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
 if (event.getResults().contains("SizeException")
 Window.alert("Data entry over limit");
}
}

You would just have to make sure that the servlet which handles the upload 
generates some meaningful, machine readable output which you can parse on 
the client


On Monday, March 12, 2012 12:19:29 PM UTC+2, Appien wrote:
>
> Hi guys,
>
> In my GWT application the user can download a PDF file by using a servlet. 
> To start the download I create in GWT a hidden Frame Object which calls the 
> servlet. The happy workflow path works great however I want give the user 
> some feedback when generating the PDF file fails. Since the result of the 
> servlet call gets ‘printed’ in the Frame object, the printed exception also 
> appears in the hidden Frame and not e.g. by a popup for the user.
>
> Unfortunately I don’t see a way so the servlet throws directly exceptions 
> to the AsyncCallback of GWT.
>
> I’ve the following pseudo code for handling my exception. 
>
> My questions are the following: 
> - Is this the right way to do exception handling for servlet exceptions 
> in GWT?
> - If not, which approach should I use for this?
>
> Many thanks for all the help!
>
> Albert
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/zxkJWOtg4hMJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: File download and Exception handling using a servlet.

2012-03-14 Thread dodo dard
Well I found something interesting related to this.

Try to look at this.
https://groups.google.com/forum/?fromgroups#!topic/google-web-toolkit/5TePQVFsSfg
 


=
www.html5bydemo.com

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/pyveSVxbmssJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: File download and Exception handling using a servlet.

2012-03-14 Thread Albert van Veen
Hi Bowie,

I use the code below. The PDF_HOST_URL variable is the url to my local
servlet. downloadFrame is a GWT Frame object.

pdfService.storeFormInSession(form, new AsyncCallback() {

public void onSuccess(EfPdfData arg0) {

RootPanel.get().remove(downloadFrame);
downloadFrame.setUrl(PDF_HOST_URL);
downloadFrame.setVisible(false);
RootPanel.get().add(downloadFrame);
 downloadFrame.addLoadHandler(new LoadHandler() {

public void onLoad(LoadEvent arg0) {
waitDialog.hide();
 }
});

new ReadyStateWatch(downloadFrame, waitDialog).addReadyStateChangeHandler(
new ValueChangeHandler() {

public void onValueChange(ValueChangeEvent event) {

}
});

}

public void onFailure(Throwable exception) {
new EfDialog(exception.getMessage()).show();
waitDialog.hide();

}
});

On 14 March 2012 10:22, dodo dard  wrote:

> Hi Appien
>>
>
> Ho do you call the servlet ?
>
> 
> http://www.html5bydemo.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/WeXfqz5OpVgJ.
>
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: File download and Exception handling using a servlet.

2012-03-14 Thread dodo dard

>
> Hi Appien
>

Ho do you call the servlet ?

 
http://www.html5bydemo.com/  

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/WeXfqz5OpVgJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: File download and Exception handling using a servlet.

2012-03-13 Thread Albert van Veen
Hi Bowie,

Im actually interested in how to read the error code or exception when
setting an url in a frame object. When the servlet call goes correct
correct, the browser shows a file download window. If the servlet call
fails, the frontend needs to be aware of this somehow.

Do I need somehow read the content of the frame object? If so, how can I
achieve this? There is no AsyncCallback object since I just set an url of a
frame.

Thanks.

Albert

On 12 March 2012 15:29, dodo dard  wrote:

> Helo,
>
> Well it is a delicate subject to handle. There is no default method to
> deal with the error result.
> A way to approach this, is by testing the servlet response. The
> fastest is to make sure that there is no "ERROR CODE" (404, 503 ...)
> in resultHtml.
> But this make your application depends on your servlet container
> implementation. If you can rewritte your ServletReponse, then you can
> decide your own error code and how to handle it.
>
> Hope this help you,
> Bowie
> 
> http://www.html5bydemo.com/
>
> On Mar 12, 11:19 am, Appien  wrote:
> > Hi guys,
> >
> > In my GWT application the user can download a PDF file by using a
> servlet.
> > To start the download I create in GWT a hidden Frame Object which calls
> the
> > servlet. The happy workflow path works great however I want give the user
> > some feedback when generating the PDF file fails. Since the result of the
> > servlet call gets ‘printed’ in the Frame object, the printed exception
> also
> > appears in the hidden Frame and not e.g. by a popup for the user.
> >
> > Unfortunately I don’t see a way so the servlet throws directly exceptions
> > to the AsyncCallback of GWT.
> >
> > I’ve the following pseudo code for handling my exception.
> >
> > My questions are the following:
> > - Is this the right way to do exception handling for servlet exceptions
> in
> > GWT?
> > - If not, which approach should I use for this?
> >
> > Many thanks for all the help!
> >
> > Albert
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: File download and Exception handling using a servlet.

2012-03-12 Thread dodo dard
Helo,

Well it is a delicate subject to handle. There is no default method to
deal with the error result.
A way to approach this, is by testing the servlet response. The
fastest is to make sure that there is no "ERROR CODE" (404, 503 ...)
in resultHtml.
But this make your application depends on your servlet container
implementation. If you can rewritte your ServletReponse, then you can
decide your own error code and how to handle it.

Hope this help you,
Bowie

http://www.html5bydemo.com/

On Mar 12, 11:19 am, Appien  wrote:
> Hi guys,
>
> In my GWT application the user can download a PDF file by using a servlet.
> To start the download I create in GWT a hidden Frame Object which calls the
> servlet. The happy workflow path works great however I want give the user
> some feedback when generating the PDF file fails. Since the result of the
> servlet call gets ‘printed’ in the Frame object, the printed exception also
> appears in the hidden Frame and not e.g. by a popup for the user.
>
> Unfortunately I don’t see a way so the servlet throws directly exceptions
> to the AsyncCallback of GWT.
>
> I’ve the following pseudo code for handling my exception.
>
> My questions are the following:
> - Is this the right way to do exception handling for servlet exceptions in
> GWT?
> - If not, which approach should I use for this?
>
> Many thanks for all the help!
>
> Albert

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



File download and Exception handling using a servlet.

2012-03-12 Thread Appien
Hi guys,

In my GWT application the user can download a PDF file by using a servlet. 
To start the download I create in GWT a hidden Frame Object which calls the 
servlet. The happy workflow path works great however I want give the user 
some feedback when generating the PDF file fails. Since the result of the 
servlet call gets ‘printed’ in the Frame object, the printed exception also 
appears in the hidden Frame and not e.g. by a popup for the user.

Unfortunately I don’t see a way so the servlet throws directly exceptions 
to the AsyncCallback of GWT.

I’ve the following pseudo code for handling my exception. 

My questions are the following: 
- Is this the right way to do exception handling for servlet exceptions in 
GWT?
- If not, which approach should I use for this?

Many thanks for all the help!

Albert

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/wh4QKEY6lPUJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.