Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine where a ConverterException should be handled #775

Closed
eclipse-faces-bot opened this issue Mar 23, 2010 · 8 comments
Closed

Determine where a ConverterException should be handled #775

eclipse-faces-bot opened this issue Mar 23, 2010 · 8 comments

Comments

@eclipse-faces-bot
Copy link

I was working on MYFACES-2615 when I discovered that currently it is not exactly
defined where the handling of a ConverterException has to happen. Here are my
thoughts from the MyFaces issue:

This problem raises the following question: "where should we handle a
ConverterException?".

The javadoc of UIInput.getConvertedValue() says the following: If conversion fails:

  • Enqueue an appropriate error message by calling the addMessage() method on
    the FacesContext.
  • Set the valid property on this component to false

However this is weird, because the javadoc also defines the method in the
following way:

protected Object getConvertedValue(FacesContext context, Object
newSubmittedValue) throws ConverterException

But "if conversion fails" means a ConverterException and if we handle it in
getConvertedValue() as described in the javadoc, then it will never throw this
ConverterException and thus the method signature is wrong. Furthermore the
related getConvertedValue() method of Renderer has the following on the javadoc:
"if not, a ConverterException should be thrown". So shouldn't we be consistent
here? Why would the "same" method on Renderer behave different than the one from
UIInput?

Furthermore this MyFaces issue is caused, because on UIViewParameter's javadoc
of getConvertedValue() it says that we should obtain the right Renderer and call
its getConvertedValue() method (which will per definition throw a
ConverterException in the error case). The javadoc says nothing about handling
of the ConverterException here, althought it has to happen somewhere to fulfil
the spec requirements posted in this issue's description!

To stay consistent here and also to get rid of duplicate code, I think it would
be the best to have the handling of the ConverterException in
UIInput.validate(), because this is the place where getConvertedValue() is
called. Of course this is not mentioned in the spec javadoc of
UIInput.validate(). In addition to my thoughts, I did a black box test of
Mojarra and they are not handling a ConverterException in any of their
getConvertedValue() methods, but in validate(). Just as I thought and as it
makes the most sence!

So this has to be changed in the spec javadoc of UIInput!

Environment

Operating System: All
Platform: All

Affected Versions

[2.0]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by jakobkorherr

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Was assigned to javaserverfowner

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Fix committed.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
rogerk said:
changelog

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Tuesday, June 22nd 2010, 3:20:25 am

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@manfredriem said:
Closing resolved issue out

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-775

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants