org.apache.wicket.request.Request.getLocale()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.apache.wicket.request.Request.getLocale方法的一些代码示例,展示了Request.getLocale的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getLocale方法的具体详情如下:
包路径:org.apache.wicket.request.Request
类名称:Request
方法名:getLocale

Request.getLocale介绍

[英]Returns locale for this request.
[中]返回此请求的区域设置。

代码示例

代码示例来源:origin: apache/wicket

@Override
public Locale getLocale()
{
  return Request.this.getLocale();
}

代码示例来源:origin: org.apache.wicket/wicket-request

@Override
public Locale getLocale()
{
  return Request.this.getLocale();
}

代码示例来源:origin: org.jabylon/rest.ui

public static Locale getUserLocale(Request request)
{
  return request.getLocale();
}

代码示例来源:origin: apache/wicket

/**
 * Constructor. Note that {@link RequestCycle} is not available until this constructor returns.
 * 
 * @param request
 *            The current request
 */
public Session(Request request)
{
  Locale locale = request.getLocale();
  if (locale == null)
  {
    throw new IllegalStateException(
      "Request#getLocale() cannot return null, request has to have a locale set on it");
  }
  this.locale = new AtomicReference<>(locale);
  pageAccessSynchronizer = new PageAccessSynchronizerProvider();
}

代码示例来源:origin: org.apache.wicket/wicket-core

/**
 * Constructor. Note that {@link RequestCycle} is not available until this constructor returns.
 * 
 * @param request
 *            The current request
 */
public Session(Request request)
{
  Locale locale = request.getLocale();
  if (locale == null)
  {
    throw new IllegalStateException(
      "Request#getLocale() cannot return null, request has to have a locale set on it");
  }
  this.locale = new AtomicReference<>(locale);
  pageAccessSynchronizer = new PageAccessSynchronizerProvider();
}

代码示例来源:origin: micromata/projectforge

/**
 * Sets or updates the locale of the user's session. Takes the locale of the user account or if not given the locale
 * of the given request.
 *
 * @param request
 */
public void setLocale(final Request request)
{
 setLocale(ThreadLocalUserContext.getLocale(request.getLocale()));
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-wicket-impl

@Programmatic
@Override
public Locale getLocale() {
  // Request Cycle can be null, e.g. during the start of an application
  RequestCycle requestCycle = RequestCycle.get();
  if (!Application.exists() || requestCycle == null) {
    // eg if request from RO viewer
    return null;
  }
  return RequestCycle.get().getRequest().getLocale();
}

代码示例来源:origin: apache/wicket

/**
 * Override {@link #resolveLocale()} to return the result of this method if you want to use
 * the user's session or request locale for parsing numbers from the page parameters
 *
 * @return the Session or Request's locale to use for parsing any numbers in the request parameters
 */
protected Locale resolveUserLocale()
{
  Locale locale = super.resolveLocale();
  if (Session.exists())
  {
    locale = Session.get().getLocale();
  }
  else
  {
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null)
    {
      Request request = requestCycle.getRequest();
      if (request != null)
      {
        locale = request.getLocale();
      }
    }
  }
  return locale;
}

代码示例来源:origin: org.apache.wicket/wicket-core

/**
 * Override {@link #resolveLocale()} to return the result of this method if you want to use
 * the user's session or request locale for parsing numbers from the page parameters
 *
 * @return the Session or Request's locale to use for parsing any numbers in the request parameters
 */
protected Locale resolveUserLocale()
{
  Locale locale = super.resolveLocale();
  if (Session.exists())
  {
    locale = Session.get().getLocale();
  }
  else
  {
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null)
    {
      Request request = requestCycle.getRequest();
      if (request != null)
      {
        locale = request.getLocale();
      }
    }
  }
  return locale;
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-wicket-impl

@Before
public void setUp() throws Exception {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
}

代码示例来源:origin: org.apache.isis.core/isis-core-viewer-wicket-impl

@Before
public void setUp() throws Exception {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
}

代码示例来源:origin: org.apache.isis.core/isis-core-viewer-wicket-impl

@Before
public void setUp() throws Exception {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-wicket-impl

@Before
public void setUp() throws Exception {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
}

代码示例来源:origin: org.apache.isis.core/isis-core-viewer-wicket-impl

@Test
public void canInstantiateIfProvideRequest() {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
  new AuthenticatedWebSessionForIsis(stubRequest);
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-wicket-impl

@Test
public void canInstantiateIfProvideRequest() {
  context.checking(new Expectations() {
    {
      // must provide explicit expectation, since Locale is final.
      allowing(stubRequest).getLocale();
      will(returnValue(Locale.getDefault()));
      // stub everything else out
      ignoring(stubRequest);
    }
  });
  new AuthenticatedWebSessionForIsis(stubRequest);
}

相关文章