You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Davli <li...@gmail.com> on 2012/12/05 11:40:14 UTC

Possible to use static IBehavior/ReadOnlyModels?

Well as the title says... 
Would this be possible assuming that they have have no real relation to a
value in a session?
For example:

An AttributeAppender that always appends the same value.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Possible-to-use-static-IBehavior-ReadOnlyModels-tp4654507.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Possible to use static IBehavior/ReadOnlyModels?

Posted by Igor Vaynberg <ig...@gmail.com>.
true, but you can override writereplace() and readresolve() to keep it
a singleton. further, even though it is no longer a singleton within a
given page there will be only one instance of it even when
serialized/deserialized, so you still get some memory savings.

-igor

On Wed, Dec 5, 2012 at 9:37 AM, Dan Retzlaff <dr...@gmail.com> wrote:
> Might be worth noting that as soon as it goes through a serialization
> round-trip it's no longer a singleton. Not a concern for a trivial
> AttributeAppender, but it's a Wicket+static+serialization gotcha we learned
> the hard way. :)
>
> On Wed, Dec 5, 2012 at 4:40 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> yes, you can use singleton instances as long as they are threadsafe.
>>
>> -igor
>>
>> On Wed, Dec 5, 2012 at 2:40 AM, Davli <li...@gmail.com> wrote:
>> > Well as the title says...
>> > Would this be possible assuming that they have have no real relation to a
>> > value in a session?
>> > For example:
>> >
>> > An AttributeAppender that always appends the same value.
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Possible-to-use-static-IBehavior-ReadOnlyModels-tp4654507.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>

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


Re: Possible to use static IBehavior/ReadOnlyModels?

Posted by Dan Retzlaff <dr...@gmail.com>.
Might be worth noting that as soon as it goes through a serialization
round-trip it's no longer a singleton. Not a concern for a trivial
AttributeAppender, but it's a Wicket+static+serialization gotcha we learned
the hard way. :)

On Wed, Dec 5, 2012 at 4:40 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> yes, you can use singleton instances as long as they are threadsafe.
>
> -igor
>
> On Wed, Dec 5, 2012 at 2:40 AM, Davli <li...@gmail.com> wrote:
> > Well as the title says...
> > Would this be possible assuming that they have have no real relation to a
> > value in a session?
> > For example:
> >
> > An AttributeAppender that always appends the same value.
> >
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Possible-to-use-static-IBehavior-ReadOnlyModels-tp4654507.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > 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: Possible to use static IBehavior/ReadOnlyModels?

Posted by Igor Vaynberg <ig...@gmail.com>.
yes, you can use singleton instances as long as they are threadsafe.

-igor

On Wed, Dec 5, 2012 at 2:40 AM, Davli <li...@gmail.com> wrote:
> Well as the title says...
> Would this be possible assuming that they have have no real relation to a
> value in a session?
> For example:
>
> An AttributeAppender that always appends the same value.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Possible-to-use-static-IBehavior-ReadOnlyModels-tp4654507.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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