Package org.apache.wicket

Examples of org.apache.wicket.Application


   * Covariant override for easy getting the current {@link WebApplication} without having to cast
   * it.
   */
  public static WebApplication get()
  {
    Application application = Application.get();

    if (application instanceof WebApplication == false)
    {
      throw new WicketRuntimeException(
        "The application attached to the current thread is not a " +
View Full Code Here


   *      org.apache.wicket.RequestCycle)
   */
  public void respond(RuntimeException e, RequestCycle requestCycle)
  {
    // If application doesn't want debug info showing up for users
    final Application application = Application.get();
    final IExceptionSettings settings = application.getExceptionSettings();
    final Page responsePage = requestCycle.getResponsePage();

    Page override = onRuntimeException(responsePage, e);
    if (override != null)
    {
      throw new RestartResponseException(override);
    }
    else if (e instanceof AuthorizationException)
    {
      // are authorization exceptions always thrown before the real
      // render?
      // else we need to make a page (see below) or set it hard to a
      // redirect.
      Class accessDeniedPageClass = application.getApplicationSettings()
        .getAccessDeniedPage();

      throw new RestartResponseAtInterceptPageException(accessDeniedPageClass);
    }
    else if (e instanceof PageExpiredException)
    {
      Class pageExpiredErrorPageClass = application.getApplicationSettings()
        .getPageExpiredErrorPage();
      boolean mounted = isPageMounted(pageExpiredErrorPageClass);
      RequestCycle.get().setRedirect(mounted);
      throw new RestartResponseException(pageExpiredErrorPageClass);
    }
    else if (settings.getUnexpectedExceptionDisplay() != IExceptionSettings.SHOW_NO_EXCEPTION_PAGE)
    {
      // we do not want to redirect - we want to inline the error output
      // and preserve the url so when the refresh button is pressed we
      // rerun the code that caused the error
      requestCycle.setRedirect(false);

      // figure out which error page to show
      Class internalErrorPageClass = application.getApplicationSettings()
        .getInternalErrorPage();
      Class responseClass = responsePage != null ? responsePage.getClass() : null;

      if (responseClass != internalErrorPageClass &&
        settings.getUnexpectedExceptionDisplay() == IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
View Full Code Here

   */
  protected IRequestTarget resolveHomePageTarget(final RequestCycle requestCycle,
    final RequestParameters requestParameters)
  {
    Session session = requestCycle.getSession();
    Application application = session.getApplication();
    try
    {
      // Get the home page class
      Class<? extends Page> homePageClass = application.getHomePage();

      PageParameters parameters = new PageParameters(requestParameters.getParameters());
      // and create a dummy target for looking up whether the home page is
      // mounted
      BookmarkablePageRequestTarget homepageTarget = new BookmarkablePageRequestTarget(
View Full Code Here

    if (valueParser.matches())
    {
      final String imageReferenceName = valueParser.getImageReferenceName();
      final String specification = Strings.replaceHtmlEscapeNumber(valueParser.getSpecification());
      final String factoryName = valueParser.getFactoryName();
      final Application application = component.getApplication();

      // Do we have a reference?
      if (!Strings.isEmpty(imageReferenceName))
      {
        // Is resource already available via the application?
        if (application.getSharedResources().get(Application.class, imageReferenceName,
          locale, style, true) == null)
        {
          // Resource not available yet, so create it with factory and
          // share via Application
          final Resource imageResource = getResourceFactory(application, factoryName).newResource(
            specification, locale, style);
          application.getSharedResources().add(Application.class, imageReferenceName,
            locale, style, imageResource);
        }

        // Create resource reference
        resourceReference = new ResourceReference(Application.class, imageReferenceName);
View Full Code Here

    String relativePath = getRelativePath(httpServletRequest);

    if (isWicketRequest(relativePath))
    {
      Application previous = null;
      if (Application.exists())
      {
        previous = Application.get();
      }
      try
View Full Code Here

    // Begin encoding URL
    final AppendingStringBuffer url = new AppendingStringBuffer(64);

    // Get page Class
    final Class<? extends Page> pageClass = requestTarget.getPageClass();
    final Application application = Application.get();

    // Find pagemap name
    String pageMapName = requestTarget.getPageMapName();
    if (pageMapName == null)
    {
      IRequestTarget currentTarget = requestCycle.getRequestTarget();
      if (currentTarget instanceof IPageRequestTarget)
      {
        Page currentPage = ((IPageRequestTarget)currentTarget).getPage();
        final IPageMap pageMap = currentPage.getPageMap();
        if (pageMap.isDefault())
        {
          pageMapName = "";
        }
        else
        {
          pageMapName = pageMap.getName();
        }
      }
      else
      {
        pageMapName = "";
      }
    }

    WebRequestEncoder encoder = new WebRequestEncoder(url);
    if (!application.getHomePage().equals(pageClass) ||
      !"".equals(pageMapName) ||
      (application.getHomePage().equals(pageClass) && requestTarget instanceof BookmarkableListenerInterfaceRequestTarget))
    {
      /*
       * Add <page-map-name>:<bookmarkable-page-class>
       *
       * Encode the url so it is correct even for class names containing non ASCII characters,
View Full Code Here

    // Begin encoding URL
    final AppendingStringBuffer url = new AppendingStringBuffer(64);

    // Get page Class
    final Class pageClass = requestTarget.getPageClass();
    final Application application = Application.get();

    // Find pagemap name
    String pageMapName = requestTarget.getPageMapName();
    if (pageMapName == null)
    {
      IRequestTarget currentTarget = requestCycle.getRequestTarget();
      if (currentTarget instanceof IPageRequestTarget)
      {
        Page currentPage = ((IPageRequestTarget)currentTarget).getPage();
        final IPageMap pageMap = currentPage.getPageMap();
        if (pageMap.isDefault())
        {
          pageMapName = "";
        }
        else
        {
          pageMapName = pageMap.getName();
        }
      }
      else
      {
        pageMapName = "";
      }
    }

    WebRequestEncoder encoder = new WebRequestEncoder(url);
    if (!application.getHomePage().equals(pageClass) ||
        !"".equals(pageMapName) ||
        (application.getHomePage().equals(pageClass) && requestTarget instanceof BookmarkableListenerInterfaceRequestTarget))
    {
      /*
       * Add <page-map-name>:<bookmarkable-page-class>
       *
       * Encode the url so it is correct even for class names containing
View Full Code Here

    // Begin encoding URL
    final AppendingStringBuffer url = new AppendingStringBuffer(64);

    // Get page Class
    final Class<? extends Page> pageClass = requestTarget.getPageClass();
    final Application application = Application.get();

    // Find pagemap name
    String pageMapName = requestTarget.getPageMapName();
    if (pageMapName == null)
    {
      IRequestTarget currentTarget = requestCycle.getRequestTarget();
      if (currentTarget instanceof IPageRequestTarget)
      {
        Page currentPage = ((IPageRequestTarget)currentTarget).getPage();
        final IPageMap pageMap = currentPage.getPageMap();
        if (pageMap.isDefault())
        {
          pageMapName = "";
        }
        else
        {
          pageMapName = pageMap.getName();
        }
      }
      else
      {
        pageMapName = "";
      }
    }

    WebRequestEncoder encoder = new WebRequestEncoder(url);
    if (!application.getHomePage().equals(pageClass) ||
      !"".equals(pageMapName) ||
      (application.getHomePage().equals(pageClass) && requestTarget instanceof BookmarkableListenerInterfaceRequestTarget))
    {
      /*
       * Add <page-map-name>:<bookmarkable-page-class>
       *
       * Encode the url so it is correct even for class names containing non ASCII characters,
View Full Code Here

   *      org.apache.wicket.RequestCycle)
   */
  public void respond(RuntimeException e, RequestCycle requestCycle)
  {
    // If application doesn't want debug info showing up for users
    final Application application = Application.get();
    final IExceptionSettings settings = application.getExceptionSettings();
    final Page responsePage = requestCycle.getResponsePage();

    Page override = onRuntimeException(responsePage, e);
    if (override != null)
    {
      throw new RestartResponseException(override);
    }
    else if (e instanceof AuthorizationException)
    {
      // are authorization exceptions always thrown before the real
      // render?
      // else we need to make a page (see below) or set it hard to a
      // redirect.
      Class accessDeniedPageClass = application.getApplicationSettings()
          .getAccessDeniedPage();

      throw new RestartResponseAtInterceptPageException(accessDeniedPageClass);
    }
    else if (e instanceof PageExpiredException)
    {
      Class pageExpiredErrorPageClass = application.getApplicationSettings()
          .getPageExpiredErrorPage();
      throw new RestartResponseException(pageExpiredErrorPageClass);
    }
    else if (settings.getUnexpectedExceptionDisplay() != IExceptionSettings.SHOW_NO_EXCEPTION_PAGE)
    {
      // we do not want to redirect - we want to inline the error output
      // and preserve the url so when the refresh button is pressed we
      // rerun the code that caused the error
      requestCycle.setRedirect(false);

      // figure out which error page to show
      Class internalErrorPageClass = application.getApplicationSettings()
          .getInternalErrorPage();
      Class responseClass = responsePage != null ? responsePage.getClass() : null;

      if (responseClass != internalErrorPageClass
          && settings.getUnexpectedExceptionDisplay() == IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
View Full Code Here

   */
  protected IRequestTarget resolveHomePageTarget(final RequestCycle requestCycle,
      final RequestParameters requestParameters)
  {
    Session session = requestCycle.getSession();
    Application application = session.getApplication();
    try
    {
      // Get the home page class
      Class homePageClass = application.getHomePage();

      PageParameters parameters = new PageParameters(requestParameters.getParameters());
      // and create a dummy target for looking up whether the home page is
      // mounted
      BookmarkablePageRequestTarget homepageTarget = new BookmarkablePageRequestTarget(
View Full Code Here

TOP

Related Classes of org.apache.wicket.Application

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.