StringResourceModel without resourcebundle
------------------------------------------

                 Key: WICKET-2716
                 URL: https://issues.apache.org/jira/browse/WICKET-2716
             Project: Wicket
          Issue Type: Wish
          Components: wicket
         Environment: ALL
            Reporter: Pas Filip
            Priority: Minor


Is it possible to add a class to wicket that works exactly like the 
StringResourceModel with the sole exception that the string it uses to format 
is not localized.

I was trying to create panel that would display fields of a customer.
The line displaying the street of the customer is build up using several fields.
Currently I have to use a messageformat or a stringbuilder via an overridden 
IModel to concatenate the message or a StringResourceModel along with aan entry 
in the propertyFile.
It would be much more elegant if it would be possible to specify either a 
resourcekey or a resourcevalue.
I was thinking of introducing an additional class which StringResourceModel 
could inherit from.
By default that new model would just format the string and not do any lookup in 
resourcebundles.
StringResourceModel could then inherit from this class and perform a lookup in 
resource bundles.
Another option would be to add yet another constructor to StringResourceModel 
which would not take the resourceKey but directly the value to format.
I ask this because i'm a great fan of the way that wicket supports property 
substitutions and I find it a shame I cannot use it without having to add a 
resourcebundle.

For Example:

Suppose you have an Address object with the fields street , housenumber, pobox, 
appartmentblock,...

On one line you have to show the full info. Possible solutions:

1) For every field create a label and bind every property to each label.
2) Create a single label and override the getObject of Model:
 public Object getObject(){
   StringBuilder buf = new StringBuilder();
  buf.append( address.getStreetName() ).append(" ");
  buf.append( address.getHouseNumber() ).append(" ");
  buf.append( address.getPoBox() ).append(" ");
etc...
return buf.toString();
}
3)Create a single label with a StringResourceModel and a property file:
In the propertyFile you could have something like this {streetName} 
{houseNumber} {poBox}.

I find solution 1 or 2 a bit heavyweight.
Solution 3 is most elegant but if you don't neet internationalization it's 
annoying to have to create a propert file with your panel.

==> For this reason it would be nice to be able to get the samefunctionality 
from StringResourceModel in another class except no lookup is done in the
resourcebundle and the string is just formatted.

Is possible to add such a model to wicket? Or refactor StringResourceModel to 
support my request?







-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to