On Tue, Sep 25, 2018 at 3:35 PM Korbinian Bachl <
korbinian.ba...@whiskyworld.de> wrote:

> Hi,
>
> take a look at
> https://ci.apache.org/projects/wicket/guide/8.x/single.html#_components_lifecycle
>
> You might want to move the code from constructor to
> onInitialize()
>

The benefit of using onInitialize() over the constructor is that you have
access to the parent component (getParent() != null) and to the associated
markup.
In case of a Page there is no parent.


> and you can use
> onRemove()
> to free it up as this is called when the component gets removed from the
> page / the page itself gets removed;
>

"the page itself gets removed"
I think this is not correct.


> Keep in mind that wicket stores old pages by default. In your case you
> might also want to have a look at LoadableDetachableModel, so that the
> model can react with "activation"/"passivation" of its data;
>
> The goal should usually be to not store any data at all that can be
> retrieved, so to not waste memory - said, it might be necessary in your
> case to store it with the page as it might be very expensive to (re)create
> the data, then the above onInitialize/ onRemove on the page level would be
> good to use;
>
> Best,
>
> KB
>
>
>
> ----- Ursprüngliche Mail -----
> > Von: "yvus" <yves.courvois...@enata.com>
> > An: users@wicket.apache.org
> > Gesendet: Dienstag, 25. September 2018 11:22:15
> > Betreff: Demo Page with User Related Data
>
> > Dear All,
> >
> > I have the complex task to develop a webpage GUI for a java/c++ app, i.e.
> > the java app contains objects that wrap c++ classes of a .so library. For
> > example the Frame.java class wraps a corresponding c++ class frame.h
> (which
> > does the math). Therefore we call in the constructor of the Frame.java
> class
> > a c++ constructor through JNA and store the Pointer in a field.
> >
> > public class Frame {
> >    private Pointer cppPointer;
> >    public Frame() {
> >        cppPointer = Wrapper.INSTANCE.frameConstructor(...)  // JNA call
> to
> > c++ constructor retrieving the c++ pointer.
> >    }
> > }
> >
> > On the webpage, I have the following scenario in which we display a demo
> > page which renders a 3d view. The user is able to displace an object
> which
> > position is determined by the fields of Frame.java and hence the c++
> > classes. Moving the object is done by changing 'values' in a form. Each
> of
> > these 'values' directly modify the Frames and hence the Frame c++-class's
> > attributes.
> >
> > In order to have the pointers created only once per page, we construct
> all
> > the pointers in the constructor of the page and store them in a model
> which
> > serializes the addresses. This allows to have the c++ side created only
> once
> > on the page. This seems fine until we have to destroy the pointers
> memory.
> >
> > How to determine when we leave the page in order to destroy the Pointers?
> > How would you manage this scenario? is it a good thing to construct the
> > pointers in the constructors of the page? When would you allow to destroy
> > the c++ allocated memory?
> >
> > Thanks
> >
> > --
> > Sent from:
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to