You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Decebal Suiu <de...@asf.ro> on 2012/01/10 15:44:20 UTC

PropertyModel with x.y as property name (from a properties file)

Hello

I have a form with new CompoundPropertyModel<ValueMap>(properties) as model
where properties are loaded from a properties file (legacy). My problem is
that in properties file I have keys like x.y
and I cannot use form.add(new TextField<String>("body.background-color"));

How do I solve this problem?

Thanks,
Decebal

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/PropertyModel-with-x-y-as-property-name-from-a-properties-file-tp4282146p4282146.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: PropertyModel with x.y as property name (from a properties file)

Posted by James Carman <jc...@carmanconsulting.com>.
or don't use cpm
On Jan 10, 2012 11:10 AM, "Sven Meier" <sv...@meiers.net> wrote:

> Write you own model:
>
> public class PropertiesModel extends AbstractReadOnlyModel<String> {
>
>  private Properties properties;
>
>  private String key;
>
>  // constructor ...
>
>  public String getObject() {
>    return properties.get(key);
>  }
> }
>
> You can implement IComponentInheritedModel if you want to have the same
> magic supported by CompoundPropertyModel, e.g.:
>
> Form form = new Form("form", new MyPropertiesModel(properties))**;
> form.add(new TextField<String>("body.**background-color"));
>
> Hope this helps
> Sven
>
> Am 10.01.2012 15:44, schrieb Decebal Suiu:
>
>> Hello
>>
>> I have a form with new CompoundPropertyModel<**ValueMap>(properties) as
>> model
>> where properties are loaded from a properties file (legacy). My problem is
>> that in properties file I have keys like x.y
>> and I cannot use form.add(new TextField<String>("body.**
>> background-color"));
>>
>> How do I solve this problem?
>>
>> Thanks,
>> Decebal
>>
>> --
>> View this message in context: http://apache-wicket.1842946.**
>> n4.nabble.com/PropertyModel-**with-x-y-as-property-name-**
>> from-a-properties-file-**tp4282146p4282146.html<http://apache-wicket.1842946.n4.nabble.com/PropertyModel-with-x-y-as-property-name-from-a-properties-file-tp4282146p4282146.html>
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: PropertyModel with x.y as property name (from a properties file)

Posted by Sven Meier <sv...@meiers.net>.
Write you own model:

public class PropertiesModel extends AbstractReadOnlyModel<String> {

   private Properties properties;

   private String key;

   // constructor ...

   public String getObject() {
     return properties.get(key);
   }
}

You can implement IComponentInheritedModel if you want to have the same 
magic supported by CompoundPropertyModel, e.g.:

Form form = new Form("form", new MyPropertiesModel(properties));
form.add(new TextField<String>("body.background-color"));

Hope this helps
Sven

Am 10.01.2012 15:44, schrieb Decebal Suiu:
> Hello
>
> I have a form with new CompoundPropertyModel<ValueMap>(properties) as model
> where properties are loaded from a properties file (legacy). My problem is
> that in properties file I have keys like x.y
> and I cannot use form.add(new TextField<String>("body.background-color"));
>
> How do I solve this problem?
>
> Thanks,
> Decebal
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/PropertyModel-with-x-y-as-property-name-from-a-properties-file-tp4282146p4282146.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