You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rafa Pérez <ra...@gmail.com> on 2008/01/24 11:30:27 UTC

[Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Hi all,

We are trying to implement a custom UploadFileProcessor to be able to show a
message to the user when the file he wants to upload is too large to be
handled by Trinidad.

By now, Trinidad throws an EOFException, but it can not be handled in
anyway, isn't it? How could we show a FacesMessage to the user telling what
the problem is without propagating the exception?

Thanks in advance,

- - Rafa

Re: [Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Posted by Rafa Pérez <ra...@gmail.com>.
Hi Matthias,

I have been trying to override the validate method for a custom component,
but I have been facing problems of configuration and trinidad is still using
the CoreInputFile. Because of deadlines of the project I am working in, I
can not spend more time in this solution. I hope in the future I will have
time enough to solve it this way.
Anyway, we have a custom phase listener and have created a custom
UploadedFileProcessor to catch the EOFException. In the afterPhase() of the
phase listener, we look for a key in the requestMap that is set in the
processFile() if this exception occurs. Less elegant, I know, but at least
it was easy to make it work  :)

Thank you for your tips!!

On Jan 24, 2008 8:15 PM, Matthias Wessendorf <ma...@apache.org> wrote:

> I am traveling to the rest of the week;
>
> But, I can try to do a "prototype" in Trinidad next week.
> Like provide a *modified* input-file comp.
>
> I haven't really spent time on it, but there is this bug:
> http://issues.apache.org/jira/browse/TRINIDAD-607
>
> and we are aware of the related issues;
>
> -M
>
> On Jan 24, 2008 11:05 AM, Rafa Pérez <ra...@gmail.com> wrote:
> > Thanks for your help Matthias. I will try to override the validate() for
> the
> > component on Monday
> >
> >
> >
> >
> > On Jan 24, 2008 4:09 PM, Matthias Wessendorf <matzew@apache.org > wrote:
> > > or better, override the validate()
> > > of the component, to check for a key.
> > > b/c not really a conversion error, more
> > > validation
> > >
> > >
> > >
> > >
> > > On Jan 24, 2008 6:55 AM, Matthias Wessendorf <ma...@apache.org>
> wrote:
> > > > I haven't looked into this particular thing, but we already have a
> bug
> > > > for it in our jira.
> > > >
> > > > Perhaps it is worth to check this:
> > > > the size-check is done in UploadedFileImpl.load()
> > > >
> > > > catch that exception and return null from processFile().
> > > > when there is an exception store a "flag" in the requestMap.
> > > >
> > > > currently the SimpleInputFileRenderer.getSubmittedValue()
> > > > reads the UploadedFiles map, and does this:
> > > > get(clientId) (to get the file)
> > > >
> > > >
> > > >
> > > > you could provide your own renderer for that,
> > > > and in check for the error
> > > >   @Override
> > > >   public Object getConvertedValue(
> > > >     FacesContext context,
> > > >     UIComponent  component,
> > > >     Object       submittedValue)
> > > >   {
> > > >
> > > > //check for the error
> > > >
> > > >   }
> > > >
> > > > let me try this on our side as well.
> > > >
> > > > -Matthias
> > > >
> > > >
> > > > On Jan 24, 2008 2:30 AM, Rafa Pérez <ra...@gmail.com> wrote:
> > > > > Hi all,
> > > > >
> > > > > We are trying to implement a custom UploadFileProcessor to be able
> to
> > show a
> > > > > message to the user when the file he wants to upload is too large
> to
> > be
> > > > > handled by Trinidad.
> > > > >
> > > > > By now, Trinidad throws an EOFException, but it can not be handled
> in
> > > > > anyway, isn't it? How could we show a FacesMessage to the user
> telling
> > what
> > > > > the problem is without propagating the exception?
> > > > >
> > > > > Thanks in advance,
> > > > >
> > > > > - - Rafa
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Matthias Wessendorf
> > > >
> > > > further stuff:
> > > > blog: http://matthiaswessendorf.wordpress.com/
> > > > sessions: http://www.slideshare.net/mwessendorf
> > > > mail: matzew-at-apache-dot-org
> > > >
> > >
> > >
> > >
> > > --
> > > Matthias Wessendorf
> > >
> > > further stuff:
> > > blog: http://matthiaswessendorf.wordpress.com/
> > > sessions: http://www.slideshare.net/mwessendorf
> > > mail: matzew-at-apache-dot-org
> > >
> >
> >
>
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>

Re: [Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Posted by Matthias Wessendorf <ma...@apache.org>.
I am traveling to the rest of the week;

But, I can try to do a "prototype" in Trinidad next week.
Like provide a *modified* input-file comp.

I haven't really spent time on it, but there is this bug:
http://issues.apache.org/jira/browse/TRINIDAD-607

and we are aware of the related issues;

-M

On Jan 24, 2008 11:05 AM, Rafa Pérez <ra...@gmail.com> wrote:
> Thanks for your help Matthias. I will try to override the validate() for the
> component on Monday
>
>
>
>
> On Jan 24, 2008 4:09 PM, Matthias Wessendorf <matzew@apache.org > wrote:
> > or better, override the validate()
> > of the component, to check for a key.
> > b/c not really a conversion error, more
> > validation
> >
> >
> >
> >
> > On Jan 24, 2008 6:55 AM, Matthias Wessendorf <ma...@apache.org> wrote:
> > > I haven't looked into this particular thing, but we already have a bug
> > > for it in our jira.
> > >
> > > Perhaps it is worth to check this:
> > > the size-check is done in UploadedFileImpl.load()
> > >
> > > catch that exception and return null from processFile().
> > > when there is an exception store a "flag" in the requestMap.
> > >
> > > currently the SimpleInputFileRenderer.getSubmittedValue()
> > > reads the UploadedFiles map, and does this:
> > > get(clientId) (to get the file)
> > >
> > >
> > >
> > > you could provide your own renderer for that,
> > > and in check for the error
> > >   @Override
> > >   public Object getConvertedValue(
> > >     FacesContext context,
> > >     UIComponent  component,
> > >     Object       submittedValue)
> > >   {
> > >
> > > //check for the error
> > >
> > >   }
> > >
> > > let me try this on our side as well.
> > >
> > > -Matthias
> > >
> > >
> > > On Jan 24, 2008 2:30 AM, Rafa Pérez <ra...@gmail.com> wrote:
> > > > Hi all,
> > > >
> > > > We are trying to implement a custom UploadFileProcessor to be able to
> show a
> > > > message to the user when the file he wants to upload is too large to
> be
> > > > handled by Trinidad.
> > > >
> > > > By now, Trinidad throws an EOFException, but it can not be handled in
> > > > anyway, isn't it? How could we show a FacesMessage to the user telling
> what
> > > > the problem is without propagating the exception?
> > > >
> > > > Thanks in advance,
> > > >
> > > > - - Rafa
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Matthias Wessendorf
> > >
> > > further stuff:
> > > blog: http://matthiaswessendorf.wordpress.com/
> > > sessions: http://www.slideshare.net/mwessendorf
> > > mail: matzew-at-apache-dot-org
> > >
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > further stuff:
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > mail: matzew-at-apache-dot-org
> >
>
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: [Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Posted by Rafa Pérez <ra...@gmail.com>.
Thanks for your help Matthias. I will try to override the validate() for the
component on Monday


On Jan 24, 2008 4:09 PM, Matthias Wessendorf <ma...@apache.org> wrote:

> or better, override the validate()
> of the component, to check for a key.
> b/c not really a conversion error, more
> validation
>
> On Jan 24, 2008 6:55 AM, Matthias Wessendorf <ma...@apache.org> wrote:
> > I haven't looked into this particular thing, but we already have a bug
> > for it in our jira.
> >
> > Perhaps it is worth to check this:
> > the size-check is done in UploadedFileImpl.load()
> >
> > catch that exception and return null from processFile().
> > when there is an exception store a "flag" in the requestMap.
> >
> > currently the SimpleInputFileRenderer.getSubmittedValue()
> > reads the UploadedFiles map, and does this:
> > get(clientId) (to get the file)
> >
> >
> >
> > you could provide your own renderer for that,
> > and in check for the error
> >   @Override
> >   public Object getConvertedValue(
> >     FacesContext context,
> >     UIComponent  component,
> >     Object       submittedValue)
> >   {
> >
> > //check for the error
> >
> >   }
> >
> > let me try this on our side as well.
> >
> > -Matthias
> >
> >
> > On Jan 24, 2008 2:30 AM, Rafa Pérez <ra...@gmail.com> wrote:
> > > Hi all,
> > >
> > > We are trying to implement a custom UploadFileProcessor to be able to
> show a
> > > message to the user when the file he wants to upload is too large to
> be
> > > handled by Trinidad.
> > >
> > > By now, Trinidad throws an EOFException, but it can not be handled in
> > > anyway, isn't it? How could we show a FacesMessage to the user telling
> what
> > > the problem is without propagating the exception?
> > >
> > > Thanks in advance,
> > >
> > > - - Rafa
> > >
> > >
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > further stuff:
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > mail: matzew-at-apache-dot-org
> >
>
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>

Re: [Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Posted by Matthias Wessendorf <ma...@apache.org>.
or better, override the validate()
of the component, to check for a key.
b/c not really a conversion error, more
validation

On Jan 24, 2008 6:55 AM, Matthias Wessendorf <ma...@apache.org> wrote:
> I haven't looked into this particular thing, but we already have a bug
> for it in our jira.
>
> Perhaps it is worth to check this:
> the size-check is done in UploadedFileImpl.load()
>
> catch that exception and return null from processFile().
> when there is an exception store a "flag" in the requestMap.
>
> currently the SimpleInputFileRenderer.getSubmittedValue()
> reads the UploadedFiles map, and does this:
> get(clientId) (to get the file)
>
>
>
> you could provide your own renderer for that,
> and in check for the error
>   @Override
>   public Object getConvertedValue(
>     FacesContext context,
>     UIComponent  component,
>     Object       submittedValue)
>   {
>
> //check for the error
>
>   }
>
> let me try this on our side as well.
>
> -Matthias
>
>
> On Jan 24, 2008 2:30 AM, Rafa Pérez <ra...@gmail.com> wrote:
> > Hi all,
> >
> > We are trying to implement a custom UploadFileProcessor to be able to show a
> > message to the user when the file he wants to upload is too large to be
> > handled by Trinidad.
> >
> > By now, Trinidad throws an EOFException, but it can not be handled in
> > anyway, isn't it? How could we show a FacesMessage to the user telling what
> > the problem is without propagating the exception?
> >
> > Thanks in advance,
> >
> > - - Rafa
> >
> >
>
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: [Trinidad] How to show a FacesMessage inside a custom UploadFileProcessor?

Posted by Matthias Wessendorf <ma...@apache.org>.
I haven't looked into this particular thing, but we already have a bug
for it in our jira.

Perhaps it is worth to check this:
the size-check is done in UploadedFileImpl.load()

catch that exception and return null from processFile().
when there is an exception store a "flag" in the requestMap.

currently the SimpleInputFileRenderer.getSubmittedValue()
reads the UploadedFiles map, and does this:
get(clientId) (to get the file)



you could provide your own renderer for that,
and in check for the error
  @Override
  public Object getConvertedValue(
    FacesContext context,
    UIComponent  component,
    Object       submittedValue)
  {

//check for the error

  }

let me try this on our side as well.

-Matthias

On Jan 24, 2008 2:30 AM, Rafa Pérez <ra...@gmail.com> wrote:
> Hi all,
>
> We are trying to implement a custom UploadFileProcessor to be able to show a
> message to the user when the file he wants to upload is too large to be
> handled by Trinidad.
>
> By now, Trinidad throws an EOFException, but it can not be handled in
> anyway, isn't it? How could we show a FacesMessage to the user telling what
> the problem is without propagating the exception?
>
> Thanks in advance,
>
> - - Rafa
>
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org