I18N modification(1)

There is a bean set in xml, and has a method called getAllShareScopes which return a collection has a map of select element.

I found the getAllShareScopes method is simple, just return allShareScopes.

So where and when dose it get the value?

I found afterPropertiesSet methods, and knew the allShareScopes get value there.

And what's new to me is that, the afterPropertiesSet methods is invoked when the service is started, that is to say, when the server starts, the settings in xml files will be setted, and all the values may be stored in application!

 

The I18N work seems to be done when the server starts:

 

ctx.getMessage(scope.getLabelKey(), null, Locale.getDefault());

 

It's absolutely wrong, because we should get the client locale instead of the server's locale.

So the I18N work shouldn't be done here.

What we can do here is fetch the key value: String label = scope.getLabelKey();

Then do the i18n work in jsp file like:

 <c:forEach var="scope" items="${allShareScopes}">
         <option value="${scope.name}"><fmt:message key="${scope.label}"/></option>
 </c:forEach>

 

This may be simple to others, but I learnt some from the research and fixing, so I record it.

你可能感兴趣的:(C++,c,bean,jsp,xml)