shale-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary VanMatre (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (SHALE-406) ConverterHelper produce NullPointerException by calling Converter with uiComponent = null parameter during restore view phase.
Date Sat, 28 Jul 2007 17:01:05 GMT

     [ https://issues.apache.org/struts/browse/SHALE-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gary VanMatre resolved SHALE-406.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 1.1.0-SNAPSHOT
                   1.0.5-SNAPSHOT

When the shale-tiger Property annotation is evaluated, a nifty type converter is used to coerce
the source data type to the target data type.  This utility reuses existing JSF converters
outside the context of rendering.  It assumes a FacesContext and UIViewRoot.  I removed the
requirement that a UIViewRoot is needed.  Since we are using converters for outside of the
component tree, we just need a object that extends UIComponent.

Fixed in the 20070729 nightly build.

> ConverterHelper produce NullPointerException by calling Converter with uiComponent =
null parameter during restore view phase.
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SHALE-406
>                 URL: https://issues.apache.org/struts/browse/SHALE-406
>             Project: Shale
>          Issue Type: Bug
>          Components: Core, View
>    Affects Versions: 1.0.4
>         Environment: Facelets 1.1.12, MyFaces 1.1.5-SNAPSHOT , Tomahawk 1.1.5-SNAPSHOT
>            Reporter: Ingo Dueppe
>            Assignee: Gary VanMatre
>             Fix For: 1.0.5-SNAPSHOT, 1.1.0-SNAPSHOT
>
>
> I had an backing bean class with the following property:
> @Property{value="#{param.enrollmentId}")
> private Long enrollmentId;
> And this ends up that shale calls the
> getAsObject method javax.faces.convert.LongConverter of MyFaces-1.1.5-SNAPSHOT during
the restore view phase .
> This method expects an uiComponent not null otherwise it throws a
> NullPointerException. But this method is called by the
> org.apache.shale.util.ConverterHelper during create view and therefore
> the facesContext setViewRoot is still null. So the below code of the ConverterHelper
> end ups in a NullPointerException in this situation.
>     public Object asObject(FacesContext context, Class type, String value) {
>         if (String.class == type) {
>             return value;
>         }
>         return converter(context, type).getAsObject(context,context.getViewRoot(), value);
>     } 
> There are also some other parts in the ConverterHelper class that depends on that viewRoot
is not null.
> Well the jsf - 1.1 spec says that the getAsObject method is called during the apply request
values phase. 
> As far as I understood it myfaces doesn't use the converter to initialize the beans also.
Instead it uses the Coercions class of common-el to convert #{param.enrollmentId}.
> Btw.: As workaround, define your own ConverterClass that can handle that the component
parameter is null.
> - Ingo

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


Mime
View raw message