You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bu...@apache.org on 2004/03/11 16:18:23 UTC

DO NOT REPLY [Bug 27608] New: - NullPointerException when initialising page property

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27608>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27608

NullPointerException when initialising page property

           Summary: NullPointerException when initialising page property
           Product: Tapestry
           Version: 3.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Framework
        AssignedTo: tapestry-dev@jakarta.apache.org
        ReportedBy: petter.mahlen@chello.se


I got a null pointer exception with the following (partial) stack trace:

org.apache.tapestry.Tapestry.fireObservedChange(Tapestry.java:1373) 
org.apache.tapestry.AbstractComponent.fireObservedChange
(AbstractComponent.java:345) 
se.elevance.timer.web.EditTaskPage$Enhance_0.setTask
(EditTaskPage$Enhance_0.java) 
se.elevance.timer.web.EditTaskPage.initialize(EditTaskPage.java:35) 
org.apache.tapestry.AbstractPage.<init>(AbstractPage.java:165) 
org.apache.tapestry.html.BasePage.<init>(BasePage.java:73) 
se.elevance.timer.web.EditTaskPage.<init>(EditTaskPage.java:31) 
se.elevance.timer.web.EditTaskPage$Enhance_0.<init>
(EditTaskPage$Enhance_0.java) 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39) 

It appears that the following line in Tapestry.java is the problem:

        ChangeObserver observer = component.getPage().getChangeObserver();

Looking a bit into the code, it would seem that component.getPage() returns 
null for a page. I can see two possible ways to solve this:

1. modify the AbstractPage() constructor to:
    public AbstractPage()
    {
        setPage(this);
        initialize();
    }

2. Modify the fireObservedChange() methods along the following lines:
    public static void fireObservedChange(
        IComponent component,
        String propertyName,
        Object newValue)
    {
        IPage page = component.getPage(); // will be null for a page

        if (component instanceof IPage) { // maybe only overwrite page if it 
is in fact null?
           page = (IPage) component;
        }

        ChangeObserver observer = page.getChangeObserver();

        if (observer == null)
            return;

        ObservedChangeEvent event = new ObservedChangeEvent(component, 
propertyName, newValue);

        observer.observeChange(event);
    }


I don't know what the side effects would be of either alternative. In my case, 
the page specification contains the following and the line in 
EditTaskPage.initialize() that is the cause for the exception is a call to 
setTask(null) - which I think should be no problem(?).

  <property-specification name="task"         
type="se.elevance.timer.data.Task" persistent="yes" />

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org