You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Oscar Besga Arcauz <ob...@isdefe.es> on 2012/11/25 13:28:15 UTC

After/before creation or serialization

 

Hi wickers !

Is there a method on Wicket components that is called before creation/load(f.e. from disk, deserialization) and another method called before destroy/save(to disk, serialization)

Would it be methods onInitialize()   and onDetach()  of org.apache.wicket.Component ?

Thanks !


    > > > Oscar Besga Arcauz  < < < 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: After/before creation or serialization

Posted by Martin Grigorov <mg...@apache.org>.
The proxy does effectively the same as your code - it uses a transient bean
and if it is not available then it looks it up in the bean repository.

I'm not sure what performance loss you experience.


On Sun, Nov 25, 2012 at 11:15 PM, Oscar Besga Arcauz <ob...@isdefe.es>wrote:

> Hi Martin
>
>
> Yes, I've tried @SpringBean but I don't like it because I noticed a (not
> very big) performace loss when using it; because the dynamicly-created
> serializable proxy.
> Or at least that seems to me.
>
> IMHO, the proxy is an overwhelming solution, I prefer a combination of
> transients and 'if (dao==null) dao = (
> ((MyApplicattion)getApplication()).getDao());'
>
> Simply if this can be done in another way.
>
> Thanks
>
>
>
>
>     > > > Oscar Besga Arcauz  < < <
>
> -----Martin Grigorov <mg...@apache.org> escribió: -----
> Para: users@wicket.apache.org
> De: Martin Grigorov <mg...@apache.org>
> Fecha: 25/11/2012  15:57
> Asunto: Re: After/before creation or serialization
>
> Hi,
>
> onInitialize is called just once for any Component. As its javadoc says it
> is called some time before the first call of #onConfigure.
> #onDetach() is called before passing the Page to serialization but it can
> be called at any time and several times per request cycle, so it is not
> good idea to do your task there too.
>
> The solution you are looking for is wicket-ioc module. It is the base for
> @SpringBean and @Inject support in Wicket. It injects serializable proxy
> instead of your real DAO/Service/... So it is very cheap for serialization
> and doesn't require your real dao/service to be Serializable itself.
>
>
> On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz <obesga@isdefe.es
> >wrote:
>
> >  Thanks
> >
> > Yes, I can use both methos onInitialize + onRead and onDetach + onSave
> >
> > Perhaps I should ask if onInitialize and onDetach are used when component
> > is serialized /deserialized on wicket 6
> >
> > My plan is to do avoid this
> >
> >     MyPanel(String id){
> >         super(id)
> >         ((MyApplicattion)getApplication()).getDao().getData();
> >    }
> >
> > and turn into this
> >
> >
> >     MyPanel(String id){
> >         super(id)
> >     }
> >
> >     private transient Dao dao;
> >
> >     void onCreateOrRead(){
> >         dao = ((MyApplicattion)getApplication()).getDao();
> >     }
> >
> >
> >    void onCreateOrRead(){
> >         dao = null; // Not necessary
> >    }
> >
> >
> >     > > > Oscar Besga Arcauz  < < <
> >
> > -----Cedric Gatay <ga...@gmail.com> escribió: -----
> > Para: users@wicket.apache.org
> > De: Cedric Gatay <ga...@gmail.com>
> > Fecha: 25/11/2012  13:36
> > Asunto: Re: After/before creation or serialization
> >
> > Hi,
> > I don't know if there is a special Wicket thing, but you can use the
> > standard Java way like this :
> >     private void writeObject(ObjectOutputStream out) throws IOException {
> >         //provide your own logic
> >     }
> >
> >     private void readObject(ObjectInputStream in) throws IOException,
> > ClassNotFoundException {
> >         //provide your own logic
> >     }
> >
> > Regards,
> >
> > __
> > Cedric Gatay
> > http://www.bloggure.info | http://cedric.gatay.fr |
> > @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
> >
> >
> >
> > On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz <obesga@isdefe.es
> > >wrote:
> >
> > >
> > >
> > > Hi wickers !
> > >
> > > Is there a method on Wicket components that is called before
> > > creation/load(f.e. from disk, deserialization) and another method
> called
> > > before destroy/save(to disk, serialization)
> > >
> > > Would it be methods onInitialize()   and onDetach()  of
> > > org.apache.wicket.Component ?
> > >
> > > Thanks !
> > >
> > >
> > >     > > > Oscar Besga Arcauz  < < <
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: After/before creation or serialization

Posted by Oscar Besga Arcauz <ob...@isdefe.es>.
Hi Martin 

 
Yes, I've tried @SpringBean but I don't like it because I noticed a (not very big) performace loss when using it; because the dynamicly-created serializable proxy. 
Or at least that seems to me.

IMHO, the proxy is an overwhelming solution, I prefer a combination of transients and 'if (dao==null) dao = (
((MyApplicattion)getApplication()).getDao());'

Simply if this can be done in another way.

Thanks 




    > > > Oscar Besga Arcauz  < < < 

-----Martin Grigorov <mg...@apache.org> escribió: -----
Para: users@wicket.apache.org
De: Martin Grigorov <mg...@apache.org>
Fecha: 25/11/2012  15:57
Asunto: Re: After/before creation or serialization

Hi,

onInitialize is called just once for any Component. As its javadoc says it
is called some time before the first call of #onConfigure.
#onDetach() is called before passing the Page to serialization but it can
be called at any time and several times per request cycle, so it is not
good idea to do your task there too.

The solution you are looking for is wicket-ioc module. It is the base for
@SpringBean and @Inject support in Wicket. It injects serializable proxy
instead of your real DAO/Service/... So it is very cheap for serialization
and doesn't require your real dao/service to be Serializable itself.


On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz <ob...@isdefe.es>wrote:

>  Thanks
>
> Yes, I can use both methos onInitialize + onRead and onDetach + onSave
>
> Perhaps I should ask if onInitialize and onDetach are used when component
> is serialized /deserialized on wicket 6
>
> My plan is to do avoid this
>
>     MyPanel(String id){
>         super(id)
>         ((MyApplicattion)getApplication()).getDao().getData();
>    }
>
> and turn into this
>
>
>     MyPanel(String id){
>         super(id)
>     }
>
>     private transient Dao dao;
>
>     void onCreateOrRead(){
>         dao = ((MyApplicattion)getApplication()).getDao();
>     }
>
>
>    void onCreateOrRead(){
>         dao = null; // Not necessary
>    }
>
>
>     > > > Oscar Besga Arcauz  < < <
>
> -----Cedric Gatay <ga...@gmail.com> escribió: -----
> Para: users@wicket.apache.org
> De: Cedric Gatay <ga...@gmail.com>
> Fecha: 25/11/2012  13:36
> Asunto: Re: After/before creation or serialization
>
> Hi,
> I don't know if there is a special Wicket thing, but you can use the
> standard Java way like this :
>     private void writeObject(ObjectOutputStream out) throws IOException {
>         //provide your own logic
>     }
>
>     private void readObject(ObjectInputStream in) throws IOException,
> ClassNotFoundException {
>         //provide your own logic
>     }
>
> Regards,
>
> __
> Cedric Gatay
> http://www.bloggure.info | http://cedric.gatay.fr |
> @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
>
>
>
> On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz <obesga@isdefe.es
> >wrote:
>
> >
> >
> > Hi wickers !
> >
> > Is there a method on Wicket components that is called before
> > creation/load(f.e. from disk, deserialization) and another method called
> > before destroy/save(to disk, serialization)
> >
> > Would it be methods onInitialize()   and onDetach()  of
> > org.apache.wicket.Component ?
> >
> > Thanks !
> >
> >
> >     > > > Oscar Besga Arcauz  < < <
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: After/before creation or serialization

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

onInitialize is called just once for any Component. As its javadoc says it
is called some time before the first call of #onConfigure.
#onDetach() is called before passing the Page to serialization but it can
be called at any time and several times per request cycle, so it is not
good idea to do your task there too.

The solution you are looking for is wicket-ioc module. It is the base for
@SpringBean and @Inject support in Wicket. It injects serializable proxy
instead of your real DAO/Service/... So it is very cheap for serialization
and doesn't require your real dao/service to be Serializable itself.


On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz <ob...@isdefe.es>wrote:

>  Thanks
>
> Yes, I can use both methos onInitialize + onRead and onDetach + onSave
>
> Perhaps I should ask if onInitialize and onDetach are used when component
> is serialized /deserialized on wicket 6
>
> My plan is to do avoid this
>
>     MyPanel(String id){
>         super(id)
>         ((MyApplicattion)getApplication()).getDao().getData();
>    }
>
> and turn into this
>
>
>     MyPanel(String id){
>         super(id)
>     }
>
>     private transient Dao dao;
>
>     void onCreateOrRead(){
>         dao = ((MyApplicattion)getApplication()).getDao();
>     }
>
>
>    void onCreateOrRead(){
>         dao = null; // Not necessary
>    }
>
>
>     > > > Oscar Besga Arcauz  < < <
>
> -----Cedric Gatay <ga...@gmail.com> escribió: -----
> Para: users@wicket.apache.org
> De: Cedric Gatay <ga...@gmail.com>
> Fecha: 25/11/2012  13:36
> Asunto: Re: After/before creation or serialization
>
> Hi,
> I don't know if there is a special Wicket thing, but you can use the
> standard Java way like this :
>     private void writeObject(ObjectOutputStream out) throws IOException {
>         //provide your own logic
>     }
>
>     private void readObject(ObjectInputStream in) throws IOException,
> ClassNotFoundException {
>         //provide your own logic
>     }
>
> Regards,
>
> __
> Cedric Gatay
> http://www.bloggure.info | http://cedric.gatay.fr |
> @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
>
>
>
> On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz <obesga@isdefe.es
> >wrote:
>
> >
> >
> > Hi wickers !
> >
> > Is there a method on Wicket components that is called before
> > creation/load(f.e. from disk, deserialization) and another method called
> > before destroy/save(to disk, serialization)
> >
> > Would it be methods onInitialize()   and onDetach()  of
> > org.apache.wicket.Component ?
> >
> > Thanks !
> >
> >
> >     > > > Oscar Besga Arcauz  < < <
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: After/before creation or serialization

Posted by Oscar Besga Arcauz <ob...@isdefe.es>.
 Thanks

Yes, I can use both methos onInitialize + onRead and onDetach + onSave

Perhaps I should ask if onInitialize and onDetach are used when component is serialized /deserialized on wicket 6

My plan is to do avoid this

    MyPanel(String id){
        super(id)
        ((MyApplicattion)getApplication()).getDao().getData();
   }

and turn into this


    MyPanel(String id){
        super(id)
    }

    private transient Dao dao;

    void onCreateOrRead(){
        dao = ((MyApplicattion)getApplication()).getDao();
    }


   void onCreateOrRead(){
        dao = null; // Not necessary
   }


    > > > Oscar Besga Arcauz  < < < 

-----Cedric Gatay <ga...@gmail.com> escribió: -----
Para: users@wicket.apache.org
De: Cedric Gatay <ga...@gmail.com>
Fecha: 25/11/2012  13:36
Asunto: Re: After/before creation or serialization

Hi,
I don't know if there is a special Wicket thing, but you can use the
standard Java way like this :
    private void writeObject(ObjectOutputStream out) throws IOException {
        //provide your own logic
    }

    private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
        //provide your own logic
    }

Regards,

__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatay<http://twitter.com/Cedric_Gatay>



On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz <ob...@isdefe.es>wrote:

>
>
> Hi wickers !
>
> Is there a method on Wicket components that is called before
> creation/load(f.e. from disk, deserialization) and another method called
> before destroy/save(to disk, serialization)
>
> Would it be methods onInitialize()   and onDetach()  of
> org.apache.wicket.Component ?
>
> Thanks !
>
>
>     > > > Oscar Besga Arcauz  < < <
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: After/before creation or serialization

Posted by Cedric Gatay <ga...@gmail.com>.
Hi,
I don't know if there is a special Wicket thing, but you can use the
standard Java way like this :
    private void writeObject(ObjectOutputStream out) throws IOException {
        //provide your own logic
    }

    private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
        //provide your own logic
    }

Regards,

__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatay<http://twitter.com/Cedric_Gatay>



On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz <ob...@isdefe.es>wrote:

>
>
> Hi wickers !
>
> Is there a method on Wicket components that is called before
> creation/load(f.e. from disk, deserialization) and another method called
> before destroy/save(to disk, serialization)
>
> Would it be methods onInitialize()   and onDetach()  of
> org.apache.wicket.Component ?
>
> Thanks !
>
>
>     > > > Oscar Besga Arcauz  < < <
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>