Cloneing Wicket Objects

2012-11-25 Thread Colin Rogers
Wicketeers,

I was wondering what the best was to duplicate or clone wicket components. I 
need guidance as to the best way to do this.

I have, on my screen two 'navigation panels' that are identical - one at the 
top of the page, another at the bottom. They contain dropdown choice fields 
that, when 'onchange' event occurs, it triggers an ajax request that redirects 
the user to another page.

As, in order to create the navigation panels - I have to visit the DB, and 
create them dynamically, so it doesn't make sense to perform this operation 
twice. Also they generate a large amount of HTML, in order render them, so it 
seems sensible to do as much as I can on the client side.

The idea was - I generate the components once, and then clone them on the 
client side. This saves going to the DB twice and rendering them twice. I've 
attempted to use jquery's clone function as; clone(), clone(true) and 
clone(true, true) - but none work. The elements are copied, but the ajax 
actions never execute onchange.

Is there another way to do this that works? A more wicket-centric way?

Cheers,
Col.


EMAIL DISCLAIMER This email message and its attachments are confidential and 
may also contain copyright or privileged material. If you are not the intended 
recipient, you may not forward the email or disclose or use the information 
contained in it. If you have received this email message in error, please 
advise the sender immediately by replying to this email and delete the message 
and any associated attachments. Any views, opinions, conclusions, advice or 
statements expressed in this email message are those of the individual sender 
and should not be relied upon as the considered view, opinion, conclusions, 
advice or statement of this company except where the sender expressly, and with 
authority, states them to be the considered view, opinion, conclusions, advice 
or statement of this company. Every care is taken but we recommend that you 
scan any attachments for viruses.


RE: Cloneing Wicket Objects

2012-11-25 Thread Paul Bors
Can't you crate the "navigation panel" once and call add() on it twice by
passing the same reference to it from within your page hierarchy?

On the client side I don't see why you would push this cloning to the
client. Just let the page contain the same panel (html/js) via a single
reference.
You should be fine as long as you handle the db trip in the constructor or
your own "init()" method.

~ Thank you,
  Paul Bors

-Original Message-
From: Colin Rogers [mailto:colin.rog...@objectconsulting.com.au] 
Sent: Sunday, November 25, 2012 6:28 PM
To: users@wicket.apache.org
Subject: Cloneing Wicket Objects

Wicketeers,

I was wondering what the best was to duplicate or clone wicket components. I
need guidance as to the best way to do this.

I have, on my screen two 'navigation panels' that are identical - one at the
top of the page, another at the bottom. They contain dropdown choice fields
that, when 'onchange' event occurs, it triggers an ajax request that
redirects the user to another page.

As, in order to create the navigation panels - I have to visit the DB, and
create them dynamically, so it doesn't make sense to perform this operation
twice. Also they generate a large amount of HTML, in order render them, so
it seems sensible to do as much as I can on the client side.

The idea was - I generate the components once, and then clone them on the
client side. This saves going to the DB twice and rendering them twice. I've
attempted to use jquery's clone function as; clone(), clone(true) and
clone(true, true) - but none work. The elements are copied, but the ajax
actions never execute onchange.

Is there another way to do this that works? A more wicket-centric way?

Cheers,
Col.


EMAIL DISCLAIMER This email message and its attachments are confidential and
may also contain copyright or privileged material. If you are not the
intended recipient, you may not forward the email or disclose or use the
information contained in it. If you have received this email message in
error, please advise the sender immediately by replying to this email and
delete the message and any associated attachments. Any views, opinions,
conclusions, advice or statements expressed in this email message are those
of the individual sender and should not be relied upon as the considered
view, opinion, conclusions, advice or statement of this company except where
the sender expressly, and with authority, states them to be the considered
view, opinion, conclusions, advice or statement of this company. Every care
is taken but we recommend that you scan any attachments for viruses.


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



Re: Cloneing Wicket Objects

2012-11-26 Thread Martin Grigorov
Hi,

You cannot add a component twice. A component can have just one parent.

I think jQuery clone() should work, but I'm not totally sure.

You can use WicketObjects#clone() method to clone any kind of Object. It
uses Java Serialization to do it.
Just make sure you clone it before adding the component to its parent,
because the relation will be cloned too.


On Mon, Nov 26, 2012 at 12:53 AM, Paul Bors  wrote:

> Can't you crate the "navigation panel" once and call add() on it twice by
> passing the same reference to it from within your page hierarchy?
>
> On the client side I don't see why you would push this cloning to the
> client. Just let the page contain the same panel (html/js) via a single
> reference.
> You should be fine as long as you handle the db trip in the constructor or
> your own "init()" method.
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: Colin Rogers [mailto:colin.rog...@objectconsulting.com.au]
> Sent: Sunday, November 25, 2012 6:28 PM
> To: users@wicket.apache.org
> Subject: Cloneing Wicket Objects
>
> Wicketeers,
>
> I was wondering what the best was to duplicate or clone wicket components.
> I
> need guidance as to the best way to do this.
>
> I have, on my screen two 'navigation panels' that are identical - one at
> the
> top of the page, another at the bottom. They contain dropdown choice fields
> that, when 'onchange' event occurs, it triggers an ajax request that
> redirects the user to another page.
>
> As, in order to create the navigation panels - I have to visit the DB, and
> create them dynamically, so it doesn't make sense to perform this operation
> twice. Also they generate a large amount of HTML, in order render them, so
> it seems sensible to do as much as I can on the client side.
>
> The idea was - I generate the components once, and then clone them on the
> client side. This saves going to the DB twice and rendering them twice.
> I've
> attempted to use jquery's clone function as; clone(), clone(true) and
> clone(true, true) - but none work. The elements are copied, but the ajax
> actions never execute onchange.
>
> Is there another way to do this that works? A more wicket-centric way?
>
> Cheers,
> Col.
>
>
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and
> may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are those
> of the individual sender and should not be relied upon as the considered
> view, opinion, conclusions, advice or statement of this company except
> where
> the sender expressly, and with authority, states them to be the considered
> view, opinion, conclusions, advice or statement of this company. Every care
> is taken but we recommend that you scan any attachments for viruses.
>
>
> -
> 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/>


RE: Cloneing Wicket Objects

2012-11-26 Thread Paul Bors
I stand corrected, Martin is right.

We cache our SQL results hence why this is not a problem for us.

~ Thank you,
  Paul Bors

-Original Message-
From: Martin Grigorov [mailto:mgrigo...@apache.org] 
Sent: Monday, November 26, 2012 3:33 AM
To: users@wicket.apache.org
Subject: Re: Cloneing Wicket Objects

Hi,

You cannot add a component twice. A component can have just one parent.

I think jQuery clone() should work, but I'm not totally sure.

You can use WicketObjects#clone() method to clone any kind of Object. It uses 
Java Serialization to do it.
Just make sure you clone it before adding the component to its parent, because 
the relation will be cloned too.


On Mon, Nov 26, 2012 at 12:53 AM, Paul Bors  wrote:

> Can't you crate the "navigation panel" once and call add() on it twice 
> by passing the same reference to it from within your page hierarchy?
>
> On the client side I don't see why you would push this cloning to the 
> client. Just let the page contain the same panel (html/js) via a 
> single reference.
> You should be fine as long as you handle the db trip in the 
> constructor or your own "init()" method.
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: Colin Rogers [mailto:colin.rog...@objectconsulting.com.au]
> Sent: Sunday, November 25, 2012 6:28 PM
> To: users@wicket.apache.org
> Subject: Cloneing Wicket Objects
>
> Wicketeers,
>
> I was wondering what the best was to duplicate or clone wicket components.
> I
> need guidance as to the best way to do this.
>
> I have, on my screen two 'navigation panels' that are identical - one 
> at the top of the page, another at the bottom. They contain dropdown 
> choice fields that, when 'onchange' event occurs, it triggers an ajax 
> request that redirects the user to another page.
>
> As, in order to create the navigation panels - I have to visit the DB, 
> and create them dynamically, so it doesn't make sense to perform this 
> operation twice. Also they generate a large amount of HTML, in order 
> render them, so it seems sensible to do as much as I can on the client side.
>
> The idea was - I generate the components once, and then clone them on 
> the client side. This saves going to the DB twice and rendering them twice.
> I've
> attempted to use jquery's clone function as; clone(), clone(true) and 
> clone(true, true) - but none work. The elements are copied, but the 
> ajax actions never execute onchange.
>
> Is there another way to do this that works? A more wicket-centric way?
>
> Cheers,
> Col.
>
>
> EMAIL DISCLAIMER This email message and its attachments are 
> confidential and may also contain copyright or privileged material. If 
> you are not the intended recipient, you may not forward the email or 
> disclose or use the information contained in it. If you have received 
> this email message in error, please advise the sender immediately by 
> replying to this email and delete the message and any associated 
> attachments. Any views, opinions, conclusions, advice or statements 
> expressed in this email message are those of the individual sender and 
> should not be relied upon as the considered view, opinion, 
> conclusions, advice or statement of this company except where the 
> sender expressly, and with authority, states them to be the considered 
> view, opinion, conclusions, advice or statement of this company. Every 
> care is taken but we recommend that you scan any attachments for viruses.
>
>
> -
> 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/>


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



RE: Cloneing Wicket Objects

2012-11-26 Thread Colin Rogers
Martin,

For some reason JQuery clone doesn't work - even with the withDataAndEvents and 
deepWithDataAndEvents flags set to true... :/

But - thank you for your suggestion - sounds just the thing - will give it a 
spin tonight :)

Cheers,
Col.

-Original Message-
From: Martin Grigorov [mailto:mgrigo...@apache.org]
Sent: Monday, 26 November 2012 7:33 PM
To: users@wicket.apache.org
Subject: Re: Cloneing Wicket Objects

Hi,

You cannot add a component twice. A component can have just one parent.

I think jQuery clone() should work, but I'm not totally sure.

You can use WicketObjects#clone() method to clone any kind of Object. It uses 
Java Serialization to do it.
Just make sure you clone it before adding the component to its parent, because 
the relation will be cloned too.


On Mon, Nov 26, 2012 at 12:53 AM, Paul Bors  wrote:

> Can't you crate the "navigation panel" once and call add() on it twice
> by passing the same reference to it from within your page hierarchy?
>
> On the client side I don't see why you would push this cloning to the
> client. Just let the page contain the same panel (html/js) via a
> single reference.
> You should be fine as long as you handle the db trip in the
> constructor or your own "init()" method.
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: Colin Rogers [mailto:colin.rog...@objectconsulting.com.au]
> Sent: Sunday, November 25, 2012 6:28 PM
> To: users@wicket.apache.org
> Subject: Cloneing Wicket Objects
>
> Wicketeers,
>
> I was wondering what the best was to duplicate or clone wicket components.
> I
> need guidance as to the best way to do this.
>
> I have, on my screen two 'navigation panels' that are identical - one
> at the top of the page, another at the bottom. They contain dropdown
> choice fields that, when 'onchange' event occurs, it triggers an ajax
> request that redirects the user to another page.
>
> As, in order to create the navigation panels - I have to visit the DB,
> and create them dynamically, so it doesn't make sense to perform this
> operation twice. Also they generate a large amount of HTML, in order
> render them, so it seems sensible to do as much as I can on the client side.
>
> The idea was - I generate the components once, and then clone them on
> the client side. This saves going to the DB twice and rendering them twice.
> I've
> attempted to use jquery's clone function as; clone(), clone(true) and
> clone(true, true) - but none work. The elements are copied, but the
> ajax actions never execute onchange.
>
> Is there another way to do this that works? A more wicket-centric way?
>
> Cheers,
> Col.
>
>
> EMAIL DISCLAIMER This email message and its attachments are
> confidential and may also contain copyright or privileged material. If
> you are not the intended recipient, you may not forward the email or
> disclose or use the information contained in it. If you have received
> this email message in error, please advise the sender immediately by
> replying to this email and delete the message and any associated
> attachments. Any views, opinions, conclusions, advice or statements
> expressed in this email message are those of the individual sender and
> should not be relied upon as the considered view, opinion,
> conclusions, advice or statement of this company except where the
> sender expressly, and with authority, states them to be the considered
> view, opinion, conclusions, advice or statement of this company. Every
> care is taken but we recommend that you scan any attachments for viruses.
>
>
> -
> 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/>
EMAIL DISCLAIMER This email message and its attachments are confidential and 
may also contain copyright or privileged material. If you are not the intended 
recipient, you may not forward the email or disclose or use the information 
contained in it. If you have received this email message in error, please 
advise the sender immediately by replying to this email and delete the message 
and any associated attachments. Any views, opinions, conclusions, advice or 
statements expressed in this email message are those of the individual sender 
and should not be relied upon as the considered view, opinion, conclusions, 
advice or statement of this company except where the sender expressly, and with 
authority, states them to be the considered view, opinion, conclusions, advice 
or statement of this company. Every care is taken but we recommend that you 
scan any attachments for viruses.