Hello Khristian,

you have to get the error in the phase listener (Render Phase in before 
Phase).

public class myPhaseListener implements PhaseListener {

...

        public void beforePhase(PhaseEvent event) {

                // RENDER_RESPONSE Phase
                if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)){

                        //error fileupload ?
                        Object req = 
context.getExternalContext().getRequest();
                        String message=null;
                        if (req instanceof MultipartRequestWrapper) {
                                MultipartRequestWrapper mpreq = 
(MultipartRequestWrapper) req;
                                Object m = 
mpreq.getAttribute("org.apache.myfaces.custom.fileupload.exception");
                                if(m!=null) 
message=m.toString().toLowerCase();
                                if (message!= null && 
message.indexOf("sizelimitexceeded")>-1) {
 
MessageUtils.addMessage(FacesMessage.SEVERITY_ERROR,"msg_FileSizeLimitExceeded",null);
                                }
                        }



                }

        }

}


best regards 
Andreas




Khristian <[email protected]>

18.11.2009 20:28
Bitte antworten an
"MyFaces Discussion" <[email protected]>


An
[email protected]
Kopie

Thema
[fileupload] need help dealing with large files!






Hello,
I'm trying to limit the size of files users can upload in my app, but
I can't figure out what to do when a user tries to upload some file
larger than the limit.
The limit is set in the web.xml file. Any file smaller than the limit
is handled without problem; when I try to upload a larger file, I
never get a response (not a exception, nor error, nor timeout).
How can I handle this situation correctly?
TIA,
--
Khristian Alexander Schönrock
http://derkosak.blogspot.com - Meu blógue!

Reply via email to