You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by chrisd <ch...@mxtelecom.com> on 2004/11/15 19:21:35 UTC

meaning of IPropertySelectionModel::translateValue

I'm using drop-down list boxes with my own implementations of
IPropertySelectionModel.

My question is what should the translateValue method in the
IPropertySelectionModel interface return?

I assumed it was meant to return the same kind of object as it would
return for getOption(int), but looking at the PropertySelection
component in the tapestry component library, the PropertySelection class
is expecting an object of the same type as returned by getValue(int)!

Is this a bug or a feature?

Now this isn't a major problem for me, but the first time I ran into it
I was getting a NumberFormatException from deep inside tapestry as my
Values were of type Integer and my Options were of some exotic type.

Chris Dawes 
chrisd@mxtelecom.com
Systems Analyst, MX Telecom Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: meaning of IPropertySelectionModel::translateValue

Posted by chrisd <ch...@mxtelecom.com>.
Ok I've worked out what I was doing wrong,
simply put: my tapestry .page file was binding the value of the
PropertySelection to a primary-key property of my page class, while the
value from the model was actually an object from my database.

-- 
Chris Dawes
chrisd@mxtelecom.com
Systems Analyst, MX Telecom Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: meaning of IPropertySelectionModel::translateValue

Posted by Markus Wiederkehr <ma...@gmail.com>.
I don't know which PropertySelection component you are refering to,
but maybe I can answer your question anyway.

IPropertySelectionModel can handle objects of arbitrary type. Now
getValue(int) has to provide a textual representation for a given
index. translateValue(String) has to reverse that and return the
object that corresponds with a given textual representation.
getOption(int) has to return the object for the given index.

Now, if a IPropertySelectionModel happens to deal with Strings the
textual representation might be identical to the internal objects and
translateValue() might return the same String as getValue().

Look into LocaleModel.java (Workbench example) for an example how this
can be used with Locales instead of Strings.

hth
Markus


On Mon, 15 Nov 2004 18:21:35 +0000, chrisd <ch...@mxtelecom.com> wrote:
> I'm using drop-down list boxes with my own implementations of
> IPropertySelectionModel.
> 
> My question is what should the translateValue method in the
> IPropertySelectionModel interface return?
> 
> I assumed it was meant to return the same kind of object as it would
> return for getOption(int), but looking at the PropertySelection
> component in the tapestry component library, the PropertySelection class
> is expecting an object of the same type as returned by getValue(int)!
> 
> Is this a bug or a feature?
> 
> Now this isn't a major problem for me, but the first time I ran into it
> I was getting a NumberFormatException from deep inside tapestry as my
> Values were of type Integer and my Options were of some exotic type.
> 
> Chris Dawes
> chrisd@mxtelecom.com
> Systems Analyst, MX Telecom Ltd.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org