I am trying to write custom code that can interact with view objects.
For example:
// ===================== public double getmode () { double getmode;
getmode = 111.23;
getmode = _view.plate.getX();
// The view contains a 3d drawing panel with a cylinder named "plate"
return getmode; }
// =====================
This gives a run time error like this:
===================== Exception in thread "main" java.lang.NullPointerException at users.__psb.simple_plate_pkg.simple_plate.getmode(simple_plate.java:458) at users.__psb.simple_plate_pkg.simple_plate.(simple_plate.java:251) at users.__psb.simple_plate_pkg.simple_plate.(simple_plate.java:137) at users.__psb.simple_plate_pkg.simple_plate.main(simple_plate.java:126) =====================
Re: Custom Page : code to access object properties -
Francisco Esquembre
237 Posts
Hi Praveen,
The problem is that you are calling getmode() too early.
Ejs first declares the variables, then the view elements. In the variable table you try to call getmode() to give the variable showmode its initial value.
But getmode() calls _view.plate.getX(), and at that time, plate does not exist.
The getmode() function can be called in the initialisation and later on. But calling it that early can give no real value.