本文整理汇总了Java中org.springframework.beans.propertyeditors.LocaleEditor.setAsText方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleEditor.setAsText方法的具体用法?Java LocaleEditor.setAsText怎么用?Java LocaleEditor.setAsText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.propertyeditors.LocaleEditor
的用法示例。
在下文中一共展示了LocaleEditor.setAsText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preHandle
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
if (request.getUserPrincipal() != null) {
String codiIdioma = request.getParameter(this.paramName);
if (codiIdioma != null) {
personaService.savePrefIdioma(codiIdioma);
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver == null)
throw new IllegalStateException ("No LocaleResolver found: not in a DispatcherServlet request?");
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(codiIdioma);
localeResolver.setLocale(request, response, (Locale)localeEditor.getValue());
}
}
return true;
}
示例2: resolveLocale
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
public Locale resolveLocale(HttpServletRequest request) {
Locale locale = null;
LocaleEditor localeEditor = new LocaleEditor();
ParellaCodiNom parella = (ParellaCodiNom)WebUtils.getSessionAttribute(request, SESSION_IDIOMA_ACTUAL);
if (parella != null) {
localeEditor.setAsText(parella.getCodi());
locale = (Locale)localeEditor.getValue();
} else {
if (request.getUserPrincipal() != null) {
UsuariPreferencies preferencies = personaService.getUsuariPreferencies();
if (preferencies != null && preferencies.getIdioma() != null) {
String idioma = preferencies.getIdioma();
localeEditor.setAsText(idioma);
locale = (Locale)localeEditor.getValue();
}
if (locale == null || !esIdiomaDisponible(locale)) {
locale = determinarIdiomaDefecte(request);
}
} else {
locale = determinarIdiomaDefecte(request);
}
setLocale(request, locale);
}
return locale;
}
示例3: preHandle
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws ServletException {
LocaleResolver localeResolver = RequestContextUtils
.getLocaleResolver(request);
if (localeResolver == null) {
throw new IllegalStateException(
"No LocaleResolver found: not in a DispatcherServlet request?");
}
// CmsSite site = CmsUtils.getSite(request);
CmsSite site=CmsThreadVariable.getSite();
String newLocale = site.getLocaleAdmin();
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(newLocale);
localeResolver.setLocale(request, response, (Locale) localeEditor
.getValue());
// Proceed in any case.
return true;
}
示例4: preHandle
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws ServletException {
LocaleResolver localeResolver = RequestContextUtils
.getLocaleResolver(request);
if (localeResolver == null) {
throw new IllegalStateException(
"No LocaleResolver found: not in a DispatcherServlet request?");
}
CmsSite site = CmsUtils.getSite(request);
String newLocale = site.getLocaleFront();
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(newLocale);
localeResolver.setLocale(request, response, (Locale) localeEditor
.getValue());
// Proceed in any case.
return true;
}
示例5: preHandle
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws ServletException {
LocaleResolver localeResolver = RequestContextUtils
.getLocaleResolver(request);
if (localeResolver == null) {
throw new IllegalStateException(
"No LocaleResolver found: not in a DispatcherServlet request?");
}
CmsSite site = CmsUtils.getSite(request);
String newLocale = site.getLocaleAdmin();
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(newLocale);
localeResolver.setLocale(request, response, (Locale) localeEditor
.getValue());
// Proceed in any case.
return true;
}
示例6: setIdiomaDefecte
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
public void setIdiomaDefecte(String idiomaDefecte) {
if ( idiomaDefecte!=null ) {
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(idiomaDefecte);
this.idiomaDefecte = (Locale)localeEditor.getValue();
if ( ! esIdiomaDisponible(this.idiomaDefecte) )
this.idiomesDisponibles.add(0, this.idiomaDefecte);
}
}
示例7: setIdiomesDisponibles
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
public void setIdiomesDisponibles(String idiomesDisponibles) {
if ( idiomesDisponibles!=null && idiomesDisponibles!="" ) {
this.idiomesDisponibles = new ArrayList<Locale>();
LocaleEditor localeEditor = new LocaleEditor();
String idiomes[] = idiomesDisponibles.split(",");
for ( String idioma: idiomes ) {
localeEditor.setAsText(idioma);
this.idiomesDisponibles.add( (Locale)localeEditor.getValue() );
}
if ( this.idiomaDefecte==null )
this.idiomaDefecte = this.idiomesDisponibles.get(0);
}
}
示例8: setLocale
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
protected void setLocale(HttpServletRequest request, HttpServletResponse response, String newLocale) {
if (newLocale != null) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver == null) {
logger.debug("No LocaleResolver found: not in a DispatcherServlet request?");
return;
}
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(newLocale);
localeResolver.setLocale(request, response, (Locale) localeEditor.getValue());
}
}
示例9: getTplPath
import org.springframework.beans.propertyeditors.LocaleEditor; //导入方法依赖的package包/类
/**
* 获得模板路径。将对模板文件名称进行本地化处理。
*
* @param messageSource
* @param lang
* 本地化语言
* @param solution
* 方案路径
* @param dir
* 模板目录。不本地化处理。
* @param name
* 模板名称。本地化处理。
* @return
*/
public static String getTplPath(MessageSource messageSource, String lang,
String solution, String dir, String name) {
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(lang);
Locale locale = (Locale) localeEditor.getValue();
return solution + "/" + dir + "/"
+ messageSource.getMessage(name, null, locale) + TPL_SUFFIX;
}