FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Jul 15, 2011, 11:26 AM
122 Posts

xp:link with converter. Converting text or value property?

  • Category: APIs
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: xp:link,converter
  • Replies: 2
I'm trying to use a date/time converter on an xp:link to convert the label to dateStyle="short". However, the date is still showing in the default "Jul 15, 2011" format.
 
From the Java being generated, it looks like the converter is being applied to the result, comparing with a computed text control which is working fine. However, I notice the setConverter method originates in the UIOutput class, and is not extended by the XspOutputLink or UIOutputLink classes. Does this mean it's trying to apply the converter to the value property of the Link, in the same way the converter is applied to the value property of the Computed Text control?
 
If so, it seems a bit strange to add a converter on the URL being mapped to. I cannot see a viable use case for applying a converter to the value property of a link, but can see many for a converter being applied to the text property.
Jul 16, 2011, 3:27 AM
129 Posts
Re: xp:link with converter. Converting text or value property?
If you don't mind a little SSJS, you can use this:
http://dontpanic82.blogspot.com/2010/04/xpages-code-snippet-for-datestring.html 
Jul 19, 2011, 8:32 AM
122 Posts
Re: xp:link with converter. Converting text or value property?
Thanks, Tommy, that's a useful workaround. I needed a locale-based format, but thanks to your code and a bit of hunting I found java.text.DateFormat and managed to amend your example to get it to work perfectly. I'll blog about it later, but thanks for your help.
 
Personally I'd prefer that the Link class gets updated to convert the text property or at least the converter property removed for clarity (the value attribute gets escaped, so the converter doesn't work on it from what I've seen), but we'll see if that happens. I'm hoping someone can confirm my suspicions and either say it will be looked at or that we have to accept it's the case. That's the only reason I'm not marking the question answered as yet, but your workaround is perfect.

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.