You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Ihab A.B. Awad" <ih...@stanford.edu> on 2005/06/02 22:17:31 UTC

NPE rendering Tree2 with server toggle

Hi there,

I am using the Tree2 component from MyFaces 1.0.9 with the JSF RI 1.1. To get 
this component in my webapp, I am including commons-validator.jar and 
myfaces-extensions.jar, and nothing else.

With client side toggling, the component works just fine.

When I tried server side toggling, I got a NPE, as pasted below. Here is my 
diagnosis of what is happening --

  - The Tree2 creates a UICommandLink for the navigation link and
    tries to render it;

  - The JSF implemementation needs to add a hidden field during rendering;

  - The JSF implementation tries to find the nearest enclosing UIForm; but

  - The 'parent' of the created UICommandLink is null, hence a NPE.

Here is the relevant portion of the stack trace --

java.lang.NullPointerException
  com.sun.faces.renderkit.html_basic.CommandLinkRenderer.
        getHiddenFieldName(CommandLinkRenderer.java:136)
  com.sun.faces.renderkit.html_basic.CommandLinkRenderer.
        encodeEnd(CommandLinkRenderer.java:320)
  javax.faces.component.UIComponentBase.
        encodeEnd(UIComponentBase.java:712)
  org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
        encodeRecursive(HtmlTreeRenderer.java:573)
  org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
        encodeNavigation(HtmlTreeRenderer.java:544)
  org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
        encodeCurrentNode(HtmlTreeRenderer.java:327)
  ...

Is this a known problem? Would it go away if I used MyFaces as my JSF 
implementation? (I would have tried this already, but I am still at an early 
stage in my development and, unfortunately, I have stuff in my app that does 
not work with MyFaces because it is not standards-clean yet.)

Peace,

-- 
Ihab A.B. Awad <ih...@stanford.edu>
Snr Scientific Programmer
Dept of Genetics

Re: NPE rendering Tree2 with server toggle

Posted by "Ihab A.B. Awad" <ih...@stanford.edu>.
I should clarify --

On Thursday 02 June 2005 13:17, Ihab A.B. Awad wrote:
> ... I have stuff in my app that does not work with MyFaces
> because it is not standards-clean yet.

The "it" in question is my app, not MyFaces. My code relies on the fact that 
the JSF RI doesn't serialize the components between requests if you specify 
server-side state saving. Thank you in advance for your help! Peace,

Ihab

-- 
Ihab A.B. Awad <ih...@stanford.edu>
Snr Scientific Programmer
Dept of Genetics

Re: NPE rendering Tree2 with server toggle

Posted by Ihab Awad <ih...@stanford.edu>.
Hi again,

On Jun 4, 2005, at 04:51, Sean Schofield wrote:
> Tree2 doesn't require that you put your tree in a form (at least with
> MyFaces implementation.)  See the simple tree2 examples.  Try running
> those same simple examples with the RI to see if there is a problem.

Fwiw, after sending my message, I switched to RI 1.2 EA and the problem 
went away. I think I will now just concentrate on cleaning up my code 
to handle view serialization properly. :) Thank you for your response. 
Peace,

Ihab

-- 
Ihab A.B. Awad <ih...@stanford.edu>
Snr Scientific Programmer, Dept of Genetics


Re: NPE rendering Tree2 with server toggle

Posted by Sean Schofield <se...@gmail.com>.
Tree2 doesn't require that you put your tree in a form (at least with
MyFaces implementation.)  See the simple tree2 examples.  Try running
those same simple examples with the RI to see if there is a problem.

sean

On 6/2/05, Ihab A.B. Awad <ih...@stanford.edu> wrote:
> Hi there,
> 
> I am using the Tree2 component from MyFaces 1.0.9 with the JSF RI 1.1. To get
> this component in my webapp, I am including commons-validator.jar and
> myfaces-extensions.jar, and nothing else.
> 
> With client side toggling, the component works just fine.
> 
> When I tried server side toggling, I got a NPE, as pasted below. Here is my
> diagnosis of what is happening --
> 
>   - The Tree2 creates a UICommandLink for the navigation link and
>     tries to render it;
> 
>   - The JSF implemementation needs to add a hidden field during rendering;
> 
>   - The JSF implementation tries to find the nearest enclosing UIForm; but
> 
>   - The 'parent' of the created UICommandLink is null, hence a NPE.
> 
> Here is the relevant portion of the stack trace --
> 
> java.lang.NullPointerException
>   com.sun.faces.renderkit.html_basic.CommandLinkRenderer.
>         getHiddenFieldName(CommandLinkRenderer.java:136)
>   com.sun.faces.renderkit.html_basic.CommandLinkRenderer.
>         encodeEnd(CommandLinkRenderer.java:320)
>   javax.faces.component.UIComponentBase.
>         encodeEnd(UIComponentBase.java:712)
>   org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
>         encodeRecursive(HtmlTreeRenderer.java:573)
>   org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
>         encodeNavigation(HtmlTreeRenderer.java:544)
>   org.apache.myfaces.custom.tree2.HtmlTreeRenderer.
>         encodeCurrentNode(HtmlTreeRenderer.java:327)
>   ...
> 
> Is this a known problem? Would it go away if I used MyFaces as my JSF
> implementation? (I would have tried this already, but I am still at an early
> stage in my development and, unfortunately, I have stuff in my app that does
> not work with MyFaces because it is not standards-clean yet.)
> 
> Peace,
> 
> --
> Ihab A.B. Awad <ih...@stanford.edu>
> Snr Scientific Programmer
> Dept of Genetics
>