Serban, I really wouldn't trying and mess with detachable models unless you were dealing with 100s of individual Strings that were climbing up beyond 4k each or something like that -- if you are literally talking about UI labels, that is so few bytes that leaving them static references is going to far out-weigh the extra byte code written to try and manage loading them each time they are needed, even if it's from something fast like a local properties file.
As for your last question, I think the answer is "yes" -- a stateful page is a page that maintains state -- some dynamic state based on something the user has done. In the case of a static label, there is no *state*. The label "Username" always is the label "Username" no matter what, so it's not stateful. That's my 2 cents atleast. On Tue, Feb 23, 2010 at 2:08 AM, Serban Balamaci <serban.balam...@asf.ro>wrote: > > Yes you are right, if we set the variable in the constructor but make it > null > on detach, we will not have it on getObject on next render, so we need to > keep a reference to it. I guess the only choice would be to the > LoadableDetachableModel, which could be thought detrimental for code > clearness outweighing the storage impact, maybe would make sense maybe for > a > large string - for ex. setting some generated javascript on a label. > But is a page consider stateless if we only have this static string ending > in the page store? > > > bgooren wrote: > > > > Well, a couple of strings more or less usually don't make that much of a > > difference. I personally prefer to save some typing and have better > > readability then to save a few bytes here and there. > > > > Furthermore, if you were to create an implementation of IModel > > specifically for this case, you would always need to store the string as > > an instance variable, thus creating the "problem" you are trying to > solve. > > > > > > Serban Balamaci wrote: > >> > >> Hello. > >> I've always used > >> add(new Label("alabel", new Model("A message")); - does this not save > the > >> "A message" string in the page store? > >> Is it not better to do add(new Label("alabel", new > >> LoadableDetachableModel<String>() { > >> > >> @Override > >> protected String load() { > >> return "A message"; > >> } > >> })); - while this option does not save it in the page store. > >> Is it because of the coding amount that nobody is using this? I guess > not > >> because we could extend IModel and create a "label model" with a string > >> property that is cleared on detach. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >> For additional commands, e-mail: users-h...@wicket.apache.org > >> > >> > >> > > > > > > -- > View this message in context: > http://old.nabble.com/Model-to-use-for-static-Label-text-tp27695054p27700379.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >