You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "David Jencks (JIRA)" <de...@myfaces.apache.org> on 2010/12/02 02:37:12 UTC

[jira] Created: (MYFACES-2991) NPE from rendering button with missing resource URL

NPE from rendering button with missing resource URL
---------------------------------------------------

                 Key: MYFACES-2991
                 URL: https://issues.apache.org/jira/browse/MYFACES-2991
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 2.0.3-SNAPSHOT
            Reporter: David Jencks
         Attachments: MYFACES-2991.patch

I ran into this with the tck in geronimo.  The test appears to be trying to render a button that is just created and not part of a view to test the EL bits of encodeBegin.  There's no resource info associated with this button so the resource URL is null, and trying to encode it throws an NPE.  Some comments in the code seem to indicate that something else should be happening.  In any case this can be fixed by testing for a null resourceURL and not trying to encode null.

Code involved and comments that make be wonder what should be happening are in

HtmlOutcomeTargetButtonRendererBase line 115:
            String href = facesContext.getExternalContext().encodeResourceURL(
                    HtmlRendererUtils.getOutcomeTargetLinkHref(facesContext,
                            (UIOutcomeTarget) uiComponent));



ServletExternalContextImpl line 325:
    @Override
    public String encodeResourceURL(final String url)
    {
        checkNull(url, "url");
        checkHttpServletRequest();
        return ((HttpServletResponse) _servletResponse).encodeURL(url);
    }


HtmlRendererUtils line 1771:

    public static String getOutcomeTargetLinkHref(
            FacesContext facesContext, UIOutcomeTarget component) throws IOException {
...
        // when navigation case is null, force the "link" to be rendered as text
        if (navigationCase == null) {
            return null;
        }
...

Result appears to be that when there is no navigation case the first method will throw an NPE, although the comment in getOutcomeTargetLinkHref seems to indicate something else should happen.

I haven't yet figured out how to add an appropriate renderer to the mock renderkit to write a unit test showing the problem.


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


[jira] Commented: (MYFACES-2991) NPE from rendering button with missing resource URL

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12966066#action_12966066 ] 

Jakob Korherr commented on MYFACES-2991:
----------------------------------------

I checked this scenario in the spec and the renderkit-docs but unfortunately could not find a description. However, I also checked it against Mojarra and they disable the button in this case and also log a warning. Furthermore we already do the same if we get a null-href on h:link and actually it makes the most sence this way.

Thus I applied the null-href handling from h:link to h:button (just disable the component). In addition I added some code on HtmlRendererUtils.getOutcomeTargetHref() to log a warning if no NavigationCase can be determined.

> NPE from rendering button with missing resource URL
> ---------------------------------------------------
>
>                 Key: MYFACES-2991
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2991
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.3-SNAPSHOT
>            Reporter: David Jencks
>            Assignee: Jakob Korherr
>         Attachments: MYFACES-2991.patch
>
>
> I ran into this with the tck in geronimo.  The test appears to be trying to render a button that is just created and not part of a view to test the EL bits of encodeBegin.  There's no resource info associated with this button so the resource URL is null, and trying to encode it throws an NPE.  Some comments in the code seem to indicate that something else should be happening.  In any case this can be fixed by testing for a null resourceURL and not trying to encode null.
> Code involved and comments that make be wonder what should be happening are in
> HtmlOutcomeTargetButtonRendererBase line 115:
>             String href = facesContext.getExternalContext().encodeResourceURL(
>                     HtmlRendererUtils.getOutcomeTargetLinkHref(facesContext,
>                             (UIOutcomeTarget) uiComponent));
> ServletExternalContextImpl line 325:
>     @Override
>     public String encodeResourceURL(final String url)
>     {
>         checkNull(url, "url");
>         checkHttpServletRequest();
>         return ((HttpServletResponse) _servletResponse).encodeURL(url);
>     }
> HtmlRendererUtils line 1771:
>     public static String getOutcomeTargetLinkHref(
>             FacesContext facesContext, UIOutcomeTarget component) throws IOException {
> ...
>         // when navigation case is null, force the "link" to be rendered as text
>         if (navigationCase == null) {
>             return null;
>         }
> ...
> Result appears to be that when there is no navigation case the first method will throw an NPE, although the comment in getOutcomeTargetLinkHref seems to indicate something else should happen.
> I haven't yet figured out how to add an appropriate renderer to the mock renderkit to write a unit test showing the problem.

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


[jira] Resolved: (MYFACES-2991) NPE from rendering button with missing resource URL

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Korherr resolved MYFACES-2991.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.3-SNAPSHOT

> NPE from rendering button with missing resource URL
> ---------------------------------------------------
>
>                 Key: MYFACES-2991
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2991
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.3-SNAPSHOT
>            Reporter: David Jencks
>            Assignee: Jakob Korherr
>             Fix For: 2.0.3-SNAPSHOT
>
>         Attachments: MYFACES-2991.patch
>
>
> I ran into this with the tck in geronimo.  The test appears to be trying to render a button that is just created and not part of a view to test the EL bits of encodeBegin.  There's no resource info associated with this button so the resource URL is null, and trying to encode it throws an NPE.  Some comments in the code seem to indicate that something else should be happening.  In any case this can be fixed by testing for a null resourceURL and not trying to encode null.
> Code involved and comments that make be wonder what should be happening are in
> HtmlOutcomeTargetButtonRendererBase line 115:
>             String href = facesContext.getExternalContext().encodeResourceURL(
>                     HtmlRendererUtils.getOutcomeTargetLinkHref(facesContext,
>                             (UIOutcomeTarget) uiComponent));
> ServletExternalContextImpl line 325:
>     @Override
>     public String encodeResourceURL(final String url)
>     {
>         checkNull(url, "url");
>         checkHttpServletRequest();
>         return ((HttpServletResponse) _servletResponse).encodeURL(url);
>     }
> HtmlRendererUtils line 1771:
>     public static String getOutcomeTargetLinkHref(
>             FacesContext facesContext, UIOutcomeTarget component) throws IOException {
> ...
>         // when navigation case is null, force the "link" to be rendered as text
>         if (navigationCase == null) {
>             return null;
>         }
> ...
> Result appears to be that when there is no navigation case the first method will throw an NPE, although the comment in getOutcomeTargetLinkHref seems to indicate something else should happen.
> I haven't yet figured out how to add an appropriate renderer to the mock renderkit to write a unit test showing the problem.

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