2
votes

Setting the locale on every date field component/editbox component/view column is time consuming. Is it possible to set them in a theme?

EDIT: To be more clear: We ship an application to several customers to be run on their servers. Customers have different needs on how date should be displayed and entered depending on the regional setting applicable for their country of origin. We have many views displaying data with dates and today we set all date columns converter locale to whatever the client's country is; Swedish (sv), Netherland(nl), Denmark (da)… Whenever we install the application at a new customer we need to modify every date column's converter locale setting. I'd like it to be more of a central setting and I thought why not in a theme?

1
I suggest you use context.setLocaleString to set it on XPage level as we discussed last time. And don't use getComponent especially if it gives you trouble: timtripcony.com/blog.nsf/d6plinks/TTRY-942UPQPanu Haaramo
@PanuHaaramo: I don't get it. The blog post is about bypassing the component/controller and access the data model directly, and the question is about setting the locale/converter of a component, or did I miss something?Sven Hasselbach
@SvenHasselbach I was referring to Mikael's previous post where getComponent is not returning expected value even when the page level html/djConfig locale is set correctly: stackoverflow.com/questions/14626897/…Panu Haaramo
@PanuHaaramo: Ahh, OK. I thought about it for a while, now it makes sense ;-)Sven Hasselbach
Also take a look at Sven's answer here: stackoverflow.com/questions/14640981/…Panu Haaramo

1 Answers

2
votes

I am not sure what you are meaning with the "locale" setting. Do you mean a converter? To set a converter from a Theme, you can use the property converter and fill it with SSJS code:

<control>
  <name>DateConverter</name>
  <property mode="override">
     <name>converter</name>
     <value>#{javascript:
         var converter = new com.ibm.xsp.convert.DateTimeConverter();
         converter.setPattern("MMMM yy");
         return converter
     }</value>
   </property>
</control>

Then you can add the themeId to every component you want:

<xp:inputText id="inputText1" value="#{javascript:@Now()}" themeId="DateConverter" />