[
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.