StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Chris Lintz

Hi all,
I swapped beta3 for beta4 and to my surprise all of my StringResourceModels
that have worked (even back to 1.2) suddenly dont work.  The toString() call
no longer returns the resource String. I dont see this in the release notes
so to say the least, this was a very frustrating find.

For example, this use to work:

public String getPageTitle()
{
   return new StringResourceModel(page.title, this, new
Model(this)).toString();
}

Now I have to say:

public String getPageTitle()
{
StringResourceModel(page.title, this, new Model(this)).getString();
}

A subtle change that that took some time to finally track down... Why did
this change?  I believe the toString() is referenced in many docs.


chris

-- 
View this message in context: 
http://www.nabble.com/StringResourceModel-toString%28%29-changed-in-Beta4---why-Must-use-getString%28%29-now.-tf4638851.html#a13249098
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Jan Kriesten

Hi Thomas,

 The javadoc pretty clearly says that this is useful for debugging and
 so on What lead you to believe this would always return a
 user-readable string?

actually, I stumbled over this, too. I used StringResourceModel for
IChoiceRenderer- and IOptionRenderer-Lists (where one assumes String within
getDisplayValue/getIdValue). Now I have to do an

if( obj instanceof StringResourceModel )
  return( ((StringResourceModel) obj).getString() );

whereas for all other cases I just return 'toString()'.

This wasn't a nice surprise actually.

Regards, --- Jan.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Jan Kriesten

Hi Thomas,

 Yes, but you were relying on an implementation detail which was in no
 way promised to remain stable. You should not have done that and you got
 properly burned.

not really. The API of StringResourceModel.toString() says:

Override of the default method to return the resource string represented by
this string resource model.

So, I would say it's an unforeseeable API change!

Regards, --- Jan.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Maeder Thomas
Fair enough, was I reading more importance into the second sentence
(useful for debugging...). I still would not rely on toString() for
anything but debugging purposes unless someone passes me an object of a
well known, final class

cheers

Thomas

 -Original Message-
 From: Jan Kriesten [mailto:[EMAIL PROTECTED] 
 Sent: Mittwoch, 17. Oktober 2007 12:40
 To: users@wicket.apache.org
 Subject: Re: StringResourceModel toString() changed in Beta4 
 - why??? Must use getString() now.
 
 
 Hi Thomas,
 
  Yes, but you were relying on an implementation detail which 
 was in no 
  way promised to remain stable. You should not have done 
 that and you 
  got properly burned.
 
 not really. The API of StringResourceModel.toString() says:
 
 Override of the default method to return the resource string 
 represented by this string resource model.
 
 So, I would say it's an unforeseeable API change!
 
 Regards, --- Jan.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Jan Kriesten

Hi Thomas,

 Fair enough, was I reading more importance into the second sentence
 (useful for debugging...). I still would not rely on toString() for
 anything but debugging purposes unless someone passes me an object of a
 well known, final class

right - but there are exceptions to rules. :-)

In my case, the documentation for IChoiceRenderer.getIdValue() explicitely
suggest using toString().

Anyway, clearifcation of the API or a return to the old behavior is needed:

https://issues.apache.org/jira/browse/WICKET-1080

Regards, --- Jan.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Gwyn Evans
Beta3 said this for toString()

/**
 * Override of the default method to return the resource string 
represented
 * by this string resource model. Useful in debugging and so on, to 
avoid
 * the explicit need to call the getString() method.
 * 
 * @return The string for this model object
 */

and this for getString()

/**
 * Gets the string currently represented by this string resource model. 
The
 * string that is returned may vary for each call to this method 
depending
 * on the values contained in the model and an the parameters that were
 * passed when this string resource model was created.
 * 
 * @return The string
 */


It's arguable that it is/was saying that it could be used to avoid
the explicit getString() call but as it no longer can (as it's being
used to expose internal details for logging/debugging), then it should
really be mentioned in a change note somewhere.

/Gwyn
 
On Wednesday, October 17, 2007, 11:21:56 AM, Maeder [EMAIL PROTECTED] wrote:

 Yes, but you were relying on an implementation detail which was in no
 way promised to remain stable. You should not have done that and you got
 properly burned. It's like when you call one of these public methods
 which are marked as not part of the Wicket API, don't call this. What
 my question was aimed at was more finding out whether the doc specifies
 anything about the return value of StringResourceModel.toString().

 Thomas

 -Original Message-
 From: Jan Kriesten [mailto:[EMAIL PROTECTED] 
 Sent: Mittwoch, 17. Oktober 2007 12:07
 To: users@wicket.apache.org
 Subject: Re: StringResourceModel toString() changed in Beta4 
 - why??? Must use getString() now.
 
 
 Hi Thomas,
 
  The javadoc pretty clearly says that this is useful for 
 debugging and 
  so on What lead you to believe this would always return a 
  user-readable string?
 
 actually, I stumbled over this, too. I used StringResourceModel for
 IChoiceRenderer- and IOptionRenderer-Lists (where one assumes 
 String within getDisplayValue/getIdValue). Now I have to do an
 
 if( obj instanceof StringResourceModel )
   return( ((StringResourceModel) obj).getString() );
 
 whereas for all other cases I just return 'toString()'.
 
 This wasn't a nice surprise actually.
 
 Regards, --- Jan.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



/Gwyn


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Igor Vaynberg
actually the check you should be doing is:

if (obj instanceof imodel) { return ((imodel)obj.getobject()).tostring(); }

that is the model contract and that is how it is used properly.

-igor


On 10/17/07, Jan Kriesten [EMAIL PROTECTED] wrote:

 Hi Thomas,

  The javadoc pretty clearly says that this is useful for debugging and
  so on What lead you to believe this would always return a
  user-readable string?

 actually, I stumbled over this, too. I used StringResourceModel for
 IChoiceRenderer- and IOptionRenderer-Lists (where one assumes String within
 getDisplayValue/getIdValue). Now I have to do an

 if( obj instanceof StringResourceModel )
   return( ((StringResourceModel) obj).getString() );

 whereas for all other cases I just return 'toString()'.

 This wasn't a nice surprise actually.

 Regards, --- Jan.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: StringResourceModel toString() changed in Beta4 - why??? Must use getString() now.

2007-10-17 Thread Chris Lintz

I also read documentation - it may have been on the Pro Wicket book.. I dont
recall.  Nonetheless I thought it was strange to also reley on toString()..
but seeing documentation and examples of toString() pushed me into using it
without much thought.  And like I said this worked all the way back to
Wicket 1.2 .  I dont care what it is.. I'll refactor to getString().  It
would just be nice to know ahead of time whats coming.  


Jan Kriesten wrote:
 
 
 Hi Thomas,
 
 Fair enough, was I reading more importance into the second sentence
 (useful for debugging...). I still would not rely on toString() for
 anything but debugging purposes unless someone passes me an object of a
 well known, final class
 
 right - but there are exceptions to rules. :-)
 
 In my case, the documentation for IChoiceRenderer.getIdValue() explicitely
 suggest using toString().
 
 Anyway, clearifcation of the API or a return to the old behavior is
 needed:
 
 https://issues.apache.org/jira/browse/WICKET-1080
 
 Regards, --- Jan.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/StringResourceModel-toString%28%29-changed-in-Beta4---why-Must-use-getString%28%29-now.-tf4638851.html#a13255680
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]