You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Achim Hügen (JIRA)" <de...@myfaces.apache.org> on 2007/08/21 13:57:31 UTC

[jira] Commented: (MYFACES-1684) myface 1.2 cant handle enum type

    [ https://issues.apache.org/jira/browse/MYFACES-1684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521405 ] 

Achim Hügen commented on MYFACES-1684:
--------------------------------------

The reason is that the EnumConverter gets java.lang.Enum handed in as targetClass parameter, while it expects the concrete enum type (like MyEnum for example). It throws an IllegalargumentException which is swallowed by ApplicationImpl.internalCreateConverter.
Instead a a new instance of EnumConverter is created using the noargs constructor. This results in an NPE when calling EnumConverter#getAsString later.

IMHO these changes must be done:
- fix internalCreateConverter so that it handles Enums correctly
- fix the exception handling of internalCreateConverter: there is no reason to catch any exception thrown by the constructor of a converter. And the conclusion of such an exception is _not_ that the constructor doesnt't exist in any case
- fix EnumConverter: it should check for targetClass == null in getAsString, since a no-args constructor is required by the spec

I will attach a patch soon.


> myface 1.2 cant handle enum type
> --------------------------------
>
>                 Key: MYFACES-1684
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1684
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.1-SNAPSHOT
>         Environment: xp
>            Reporter: Dan Tran
>            Assignee: Matthias Weßendorf
>             Fix For: 1.2.1-SNAPSHOT
>
>
> I switch my jsf 1.2 from ri to myfaces 1.2.0 and run in this issue
> java.lang.IllegalArgumentException: Value is no String (class=com.iplocks.model.domain.target.DatabaseType, value=DB27) and component databaseSearchForm:j_id25with path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /database/search.xhtml][Class: javax.faces.component.html.HtmlForm,Id: databaseSearchForm][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id22][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id23][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: j_id25]} does not have a Converter
> 	org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:560)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.