本文整理汇总了Java中javax.faces.component.UIViewRoot.setLocale方法的典型用法代码示例。如果您正苦于以下问题:Java UIViewRoot.setLocale方法的具体用法?Java UIViewRoot.setLocale怎么用?Java UIViewRoot.setLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.component.UIViewRoot
的用法示例。
在下文中一共展示了UIViewRoot.setLocale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyViewLocale
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
private static void verifyViewLocale(FacesContext fc) {
HttpServletRequest request = (HttpServletRequest) fc
.getExternalContext().getRequest();
String localeString = localeStringFrom(request);
// if the view locale differs from the users locale change the view
// locale
UIViewRoot viewRoot = fc.getViewRoot();
if (localeString != null
&& !viewRoot.getLocale().toString().equals(localeString)) {
Iterator<Locale> it = fc.getApplication().getSupportedLocales();
while (it.hasNext()) {
Locale locale = it.next();
if (locale.toString().equals(localeString)) {
viewRoot.setLocale(locale);
return;
}
}
// we use the default locale if the requested locale was not
// found
if (!viewRoot.getLocale().equals(
fc.getApplication().getDefaultLocale())) {
viewRoot.setLocale(fc.getApplication().getDefaultLocale());
}
}
}
示例2: _defaultCreateView
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
private UIViewRoot _defaultCreateView(FacesContext context, String viewId)
{
UIViewRoot result = (UIViewRoot) context.getApplication()
.createComponent(UIViewRoot.COMPONENT_TYPE);
Locale locale = null;
String renderKitId = null;
// use the locale from the previous view if is was one which will be
// the case if this is called from NavigationHandler. There wouldn't be
// one for the initial case.
if (context.getViewRoot() != null)
{
locale = context.getViewRoot().getLocale();
renderKitId = context.getViewRoot().getRenderKitId();
}
if (locale == null)
{
locale = context.getApplication().getViewHandler().calculateLocale(context);
}
if (renderKitId == null)
{
renderKitId = context.getApplication().getViewHandler().calculateRenderKitId(context);
}
result.setLocale(locale);
result.setRenderKitId(renderKitId);
result.setViewId(viewId);
return result;
}
示例3: _doTestPickedUpClientByteLengthValidator
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
private void _doTestPickedUpClientByteLengthValidator(
String encoding,
String expectedConstructorName
)
{
Mock mockComponent = buildMockUIComponent();
UIComponent component = (UIComponent) mockComponent.proxy();
UIViewRoot uiRoot = new UIViewRoot();
uiRoot.setLocale(Locale.US);
for (int i = 0; i < 4; i++)
facesContext.setViewRoot(uiRoot);
ByteLengthValidator blv = new ByteLengthValidator();
blv.setEncoding(encoding);
String libKey = (String)(blv.getClientImportNames().toArray()[0]);
String constructorInfo = blv.getClientValidation(facesContext, component);
String clientScript = blv.getClientScript(facesContext, component);
assertEquals(null, clientScript);
assertEquals(true, libKey.equals(expectedConstructorName + "()"));
assertEquals(true, constructorInfo.startsWith("new "
+ expectedConstructorName));
}
示例4: createUIViewRoot
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
static public UIViewRoot createUIViewRoot(MFacesContext context)
{
UIViewRoot root = new UIViewRoot();
root.setRenderKitId("org.apache.myfaces.trinidad.core");
root.setViewId("/test-view-id.jspx");
root.setLocale(context.getLocale());
return root;
}
示例5: setUp
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
protected void setUp() throws Exception
{
RequestContext rc = RequestContext.getCurrentInstance();
if (rc != null)
{
rc.release();
}
_bootstrap = new RenderKitBootstrap();
_bootstrap.init();
RenderKitBootstrap.clearFactories();
RenderKitBootstrap.setFactories(_bootstrap.getFacesConfigInfo());
_facesContext = new MFacesContext(MApplication.sharedInstance(), true);
_requestContext = new MRequestContext();
_requestContext.setSkinFamily("minimal");
_requestContext.setAgent(RenderKitBootstrap.getGeckoAgent());
_requestContext.setRightToLeft(false);
_requestContext.setAccessibilityMode(null);
_facesContext.getExternalContext().getApplicationMap().put(TrinidadSkinProvider.TRINDIAD_SKIN_PROVIDER_KEY, new TrinidadSkinProvider());
_facesContext.getExternalContext().getApplicationMap().put(ExternalSkinProvider.EXTERNAL_SKIN_PROVIDER_KEY, new ExternalSkinProvider());
_facesContext.getExternalContext().getApplicationMap().put(SkinProvider.SKIN_PROVIDER_INSTANCE_KEY, new SkinProviderRegistry());
UIViewRoot root = RenderKitBootstrap.createUIViewRoot(_facesContext);
root.setRenderKitId("org.apache.myfaces.trinidad.core");
root.setLocale(Locale.getDefault());
_facesContext.setViewRoot(root);
try
{
new CoreRenderingContext();
}
catch (IllegalStateException ex)
{
return;
}
}
示例6: testCustomMessageIsSet
import javax.faces.component.UIViewRoot; //导入方法依赖的package包/类
public void testCustomMessageIsSet()
{
String[] failingValues = {"222.22.2", "3,", "23.3.3", "10e.04"};
String[] types = {"number", "percent", "currency", "pattern"};
String[] customMessage = {"number", "percent", "currency", "pattern"};
for (int i = 0; i < failingValues.length ; i++)
{
MockFacesContext12 context = new MockFacesContext12(externalContext,
lifecycle,
application);
try
{
Mock mock = buildMockUIComponent(3);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
org.apache.myfaces.trinidad.convert.NumberConverter converter =
new org.apache.myfaces.trinidad.convert.NumberConverter();
UIViewRoot root = facesContext.getViewRoot();
root.setLocale(Locale.US);
for (int j = 0; j < 3; j++)
{
context.setViewRoot(root);
}
try
{
// ADF Converter is not lenient.
converter.setMessageDetailConvertNumber(customMessage[0]);
converter.setMessageDetailConvertPercent(customMessage[1]);
converter.setMessageDetailConvertCurrency(customMessage[2]);
converter.setMessageDetailConvertPattern(customMessage[3]);
if ("pattern".equals(types[i]))
converter.setPattern("##.000");
else
converter.setType(types[i]);
Object obj = converter.getAsObject(context, component, failingValues[i]);
fail("Expected converter exception");
}
catch (ConverterException ce)
{
// We expected a exception to occur
assertEquals(ce.getFacesMessage().getDetail(), customMessage[i]);
}
}
finally
{
context.release();
}
}
}