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 <obe...@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 <gata...@gmail.com> escribió: -----
> Para: users@wicket.apache.org
> De: Cedric Gatay <gata...@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 <obe...@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-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
>
>


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

Reply via email to