You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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]
The text was updated successfully, but these errors were encountered:
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:
the FacesContext.
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]
The text was updated successfully, but these errors were encountered: