You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tom Eugelink <tb...@tbee.org> on 2012/05/02 13:47:17 UTC

constant strings

The Wicket application I'm developing is an internal app which will only be available in English. In order to not unnecessarily bloat the code and the project, I'm often use hardcoded labels. I know this is not convention, but there is no reason for me to introduce a resource file and use the ResourceModel. So my code has a number of lines like:

.setLabel(new Model("Valid from"))

All these models result are being stored in the state, I presume, while there is no reason because the value is hardcoded. Wouldn't it be practical to have a model that never stores anything in the state, for example a ConstantModel<T>? Being a newbie to Wicket I have problems envisioning if and how this would work.

Tom





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


Re: constant strings

Posted by Tom Eugelink <tb...@tbee.org>.
On 2-5-2012 17:07, Eric Jablow wrote:
> Actually, there are reasons to use resource files.  If you use a label on
> more than one page, or even more than once on a single page, and if your
> application is changing as you develop it, you may want to change the text
> for a label, and you probably will want to change all the labels at once.
> So, you can do a multi-file search/replace, or you may change just one
> properties file. And, there's a value in consistency too. Some people go to
> the extreme of never including any plain text in an html file at all.
>

I know. I use resources file often, but the scenario that I'm in now lets me lean towards not using them; "Java applications are always bloated" and arguments like that. Here the additional layer of a resource file it is not really needed.

Conceptual discussion aside, the question of not storing constant values in the state seems valid to me.

Tom



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


Re: constant strings

Posted by Eric Jablow <er...@gmail.com>.
On Wed, May 2, 2012 at 7:47 AM, Tom Eugelink <tb...@tbee.org> wrote:

>
> The Wicket application I'm developing is an internal app which will only
> be available in English. In order to not unnecessarily bloat the code and
> the project, I'm often use hardcoded labels. I know this is not convention,
> but there is no reason for me to introduce a resource file and use the
> ResourceModel. So my code has a number of lines like:
>
> .setLabel(new Model("Valid from"))
>
>
> Actually, there are reasons to use resource files.  If you use a label on
more than one page, or even more than once on a single page, and if your
application is changing as you develop it, you may want to change the text
for a label, and you probably will want to change all the labels at once.
So, you can do a multi-file search/replace, or you may change just one
properties file. And, there's a value in consistency too. Some people go to
the extreme of never including any plain text in an html file at all.

Respectfully,
Eric Jablow


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

Re: constant strings

Posted by Tom Eugelink <tb...@tbee.org>.
AH! Ok. Makes sense! Thanks.

Tom


On 2012-05-02 17:23, Igor Vaynberg wrote:
> no. if you do not want to store the string then instead of a new Model
> use new AbstratReadOnlyModel().
>
> -igor
>



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


Re: constant strings

Posted by Igor Vaynberg <ig...@gmail.com>.
no. if you do not want to store the string then instead of a new Model
use new AbstratReadOnlyModel().

-igor

On Wed, May 2, 2012 at 8:25 AM, Tom Eugelink <tb...@tbee.org> wrote:
>
> On 2012-05-02 17:16, Igor Vaynberg wrote:
>>
>> if it doesnt store anything then where would it get the value from
>> when the second request needs to be processed? wicket components live
>> across many requests.
>>
>
> Don't know. That exactly was my question. Is it possible to not store
> constant values in the state? Maybe because they are recreated when the post
> reexecutes the java code setting up the components? The answer can very well
> be "no".
>
>
> Tom
>
>
>
> ---------------------------------------------------------------------
> 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: constant strings

Posted by Tom Eugelink <tb...@tbee.org>.
On 2012-05-02 17:16, Igor Vaynberg wrote:
> if it doesnt store anything then where would it get the value from
> when the second request needs to be processed? wicket components live
> across many requests.
>

Don't know. That exactly was my question. Is it possible to not store constant values in the state? Maybe because they are recreated when the post reexecutes the java code setting up the components? The answer can very well be "no".

Tom



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


Re: constant strings

Posted by Igor Vaynberg <ig...@gmail.com>.
if it doesnt store anything then where would it get the value from
when the second request needs to be processed? wicket components live
across many requests.

-igor

On Wed, May 2, 2012 at 4:47 AM, Tom Eugelink <tb...@tbee.org> wrote:
>
> The Wicket application I'm developing is an internal app which will only be
> available in English. In order to not unnecessarily bloat the code and the
> project, I'm often use hardcoded labels. I know this is not convention, but
> there is no reason for me to introduce a resource file and use the
> ResourceModel. So my code has a number of lines like:
>
> .setLabel(new Model("Valid from"))
>
> All these models result are being stored in the state, I presume, while
> there is no reason because the value is hardcoded. Wouldn't it be practical
> to have a model that never stores anything in the state, for example a
> ConstantModel<T>? Being a newbie to Wicket I have problems envisioning if
> and how this would work.
>
> Tom
>
>
>
>
>
> ---------------------------------------------------------------------
> 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