问题
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 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" />
来源:https://stackoverflow.com/questions/14715649/set-locale-on-view-columns-date-fields-in-theme-xpages