Package org.apache.wicket

Examples of org.apache.wicket.RequestListenerInterface


   * @return the encoded url
   */
  protected CharSequence encode(RequestCycle requestCycle,
      IListenerInterfaceRequestTarget requestTarget)
  {
    final RequestListenerInterface rli = requestTarget.getRequestListenerInterface();

    // Start string buffer for url
    final AppendingStringBuffer url = new AppendingStringBuffer(64);
    url.append('?');
    url.append(INTERFACE_PARAMETER_NAME);
    url.append('=');

    // Get component and page for request target
    final Component component = requestTarget.getTarget();
    final Page page = component.getPage();

    // Add pagemap
    final IPageMap pageMap = page.getPageMap();
    if (!pageMap.isDefault())
    {
      url.append(pageMap.getName());
    }
    url.append(Component.PATH_SEPARATOR);

    // Add path to component
    url.append(component.getPath());
    url.append(Component.PATH_SEPARATOR);

    // Add version
    final int versionNumber = component.getPage().getCurrentVersionNumber();
    if (!rli.getRecordsPageVersion())
    {
      url.append(Page.LATEST_VERSION);
    }
    else if (versionNumber > 0)
    {
      url.append(versionNumber);
    }
    url.append(Component.PATH_SEPARATOR);

    // Add listener interface
    final String listenerName = rli.getName();
    if (!IRedirectListener.INTERFACE.getName().equals(listenerName))
    {
      url.append(listenerName);
    }
    url.append(Component.PATH_SEPARATOR);
View Full Code Here


   * @return the encoded url
   */
  protected CharSequence encode(RequestCycle requestCycle,
      IListenerInterfaceRequestTarget requestTarget)
  {
    final RequestListenerInterface rli = requestTarget.getRequestListenerInterface();

    // Start string buffer for url
    final AppendingStringBuffer url = new AppendingStringBuffer(64);
    url.append('?');
    url.append(INTERFACE_PARAMETER_NAME);
    url.append('=');

    // Get component and page for request target
    final Component component = requestTarget.getTarget();
    final Page page = component.getPage();

    // Add pagemap
    final IPageMap pageMap = page.getPageMap();
    if (!pageMap.isDefault())
    {
      url.append(pageMap.getName());
    }
    url.append(Component.PATH_SEPARATOR);

    String listenerName = rli.getName();
    // Add path to component
    if (page instanceof WebPage && !"IResourceListener".equals(listenerName))
    {
      url.append(page.getId());
      url.append(Component.PATH_SEPARATOR);
      url.append(((WebPage)page).getUrlCompressor().getUIDForComponentAndInterface(component,
          listenerName));
      listenerName = null;
    }
    else
    {
      url.append(component.getPath());
    }
    url.append(Component.PATH_SEPARATOR);

    // Add version
    final int versionNumber = component.getPage().getCurrentVersionNumber();
    if (!rli.getRecordsPageVersion())
    {
      url.append(Page.LATEST_VERSION);
    }
    else if (versionNumber > 0)
    {
View Full Code Here

   *
   * @see org.apache.wicket.Request#mergeVersion()
   */
  public boolean mergeVersion()
  {
    RequestListenerInterface intface = getRequestParameters().getInterface();
    return isAjax() || intface == IRedirectListener.INTERFACE;
  }
View Full Code Here

          INewBrowserWindowListener.INTERFACE, requestParameters);
    }
    else
    {
      // Get the listener interface we need to call
      final RequestListenerInterface listener = RequestListenerInterface
          .forName(interfaceName);
      if (listener == null)
      {
        throw new WicketRuntimeException(
            "Attempt to access unknown request listener interface " + interfaceName);
      }

      // Get component
      Component component = null;
      final String pageRelativeComponentPath = Strings.afterFirstPathComponent(componentPath,
          Component.PATH_SEPARATOR);
      if (Strings.isEmpty(pageRelativeComponentPath))
      {
        component = page;
      }
      else
      {
        component = page.get(pageRelativeComponentPath);
      }

      if (component == null)
      {
        throw new WicketRuntimeException("component " + pageRelativeComponentPath
            + " not found on page " + page.getClass().getName() + "[id = "
            + page.getNumericId() + "], listener interface = " + listener);
      }

      if (!component.isEnableAllowed())
      {
        throw new UnauthorizedActionException(component, Component.ENABLE);
      }

      // Ask the request listener interface object to create a request
      // target
      return listener.newRequestTarget(page, component, listener, requestParameters);
    }
  }
View Full Code Here

      // see if we can replace our manual listener url with a properly generated one...

      try
      {
        RequestListenerInterface rli = (RequestListenerInterface)clazz.getField("INTERFACE")
          .get(clazz);

        String auto = component.getRequestCycle().urlFor(component, rli).toString();
        int idx = auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
        if (idx >= 0)
View Full Code Here

   * @return the encoded url
   */
  protected CharSequence encode(RequestCycle requestCycle,
    IListenerInterfaceRequestTarget requestTarget)
  {
    final RequestListenerInterface rli = requestTarget.getRequestListenerInterface();

    // Start string buffer for url
    final AppendingStringBuffer url = new AppendingStringBuffer(64);
    url.append('?');
    url.append(INTERFACE_PARAMETER_NAME);
    url.append('=');

    // Get component and page for request target
    final Component component = requestTarget.getTarget();
    final Page page = component.getPage();

    // Add pagemap
    final IPageMap pageMap = page.getPageMap();
    if (!pageMap.isDefault())
    {
      url.append(pageMap.getName());
    }
    url.append(Component.PATH_SEPARATOR);

    String listenerName = rli.getName();
    // Add path to component
    if (page instanceof WebPage && !"IResourceListener".equals(listenerName))
    {
      url.append(page.getId());
      url.append(Component.PATH_SEPARATOR);
      url.append(((WebPage)page).getUrlCompressor().getUIDForComponentAndInterface(component,
        listenerName));
      listenerName = null;
    }
    else
    {
      url.append(component.getPath());
    }
    url.append(Component.PATH_SEPARATOR);

    // Add version
    final int versionNumber = component.getPage().getCurrentVersionNumber();
    if (!rli.getRecordsPageVersion())
    {
      url.append(Page.LATEST_VERSION);
    }
    else if (versionNumber > 0)
    {
      url.append(versionNumber);
    }
    url.append(Component.PATH_SEPARATOR);

    // Add listener interface
    if (listenerName != null && !IRedirectListener.INTERFACE.getName().equals(listenerName))
    {
      url.append(listenerName);
    }

    url.append(Component.PATH_SEPARATOR);

    // Add behaviourId
    RequestParameters params = requestTarget.getRequestParameters();
    if (params != null && params.getBehaviorId() != null)
    {
      url.append(params.getBehaviorId());
    }
    url.append(Component.PATH_SEPARATOR);

    // Add URL depth
    if (params != null && params.getUrlDepth() != 0)
    {
      url.append(params.getUrlDepth());
    }
    if (IActivePageBehaviorListener.INTERFACE.getName().equals(rli.getName()))
    {
      url.append(url.indexOf("?") > -1 ? "&" : "?").append(
        IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true");
    }
    return requestCycle.getOriginalResponse().encodeURL(url);
View Full Code Here

        url = encode(requestCycle, (IListenerInterfaceRequestTarget)requestTarget);
      }
      if (portletRequest)
      {
        IListenerInterfaceRequestTarget iliRequestTarget = (IListenerInterfaceRequestTarget)requestTarget;
        RequestListenerInterface rli = iliRequestTarget.getRequestListenerInterface();
        if (IResourceListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()) ||
          IBehaviorListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()))
        {
          url = requestContext.encodeResourceURL(url);
        }
        else if (IRedirectListener.class.isAssignableFrom(rli.getMethod()
          .getDeclaringClass()))
        {
          if (((WebRequestCycle)requestCycle).getWebRequest().isAjax())
          {
            // TODO: Probably not all Ajax based redirects need to break out of
View Full Code Here

   * @return the encoded url
   */
  protected CharSequence encode(RequestCycle requestCycle,
    IListenerInterfaceRequestTarget requestTarget)
  {
    final RequestListenerInterface rli = requestTarget.getRequestListenerInterface();

    // Start string buffer for url
    final AppendingStringBuffer url = new AppendingStringBuffer(64);
    url.append('?');
    url.append(INTERFACE_PARAMETER_NAME);
    url.append('=');

    // Get component and page for request target
    final Component component = requestTarget.getTarget();
    final Page page = component.getPage();

    // Add pagemap
    final IPageMap pageMap = page.getPageMap();
    if (!pageMap.isDefault())
    {
      url.append(pageMap.getName());
    }
    url.append(Component.PATH_SEPARATOR);

    // Add path to component
    url.append(component.getPath());
    url.append(Component.PATH_SEPARATOR);

    // Add version
    final int versionNumber = component.getPage().getCurrentVersionNumber();
    if (!rli.getRecordsPageVersion())
    {
      url.append(Page.LATEST_VERSION);
    }
    else if (versionNumber > 0)
    {
      url.append(versionNumber);
    }
    url.append(Component.PATH_SEPARATOR);

    // Add listener interface
    final String listenerName = rli.getName();
    if (!IRedirectListener.INTERFACE.getName().equals(listenerName))
    {
      url.append(listenerName);
    }
    url.append(Component.PATH_SEPARATOR);
View Full Code Here

            " on stateless page " +
            page +
            " it could be that the component is inside a repeater make your component return false in getStatelessHint()");
      }
    }
    RequestListenerInterface listenerInterface = RequestListenerInterface.forName(interfaceName);
    if (listenerInterface == null)
    {
      throw new WicketRuntimeException("unable to find listener interface " + interfaceName);
    }
    listenerInterface.invoke(page, component);
  }
View Full Code Here

        INewBrowserWindowListener.INTERFACE, requestParameters);
    }
    else
    {
      // Get the listener interface we need to call
      final RequestListenerInterface listener = RequestListenerInterface.forName(interfaceName);
      if (listener == null)
      {
        throw new WicketRuntimeException(
          "Attempt to access unknown request listener interface " + interfaceName);
      }

      // Get component
      Component component;
      final String pageRelativeComponentPath = Strings.afterFirstPathComponent(componentPath,
        Component.PATH_SEPARATOR);
      if (Strings.isEmpty(pageRelativeComponentPath))
      {
        component = page;
      }
      else
      {
        component = page.get(pageRelativeComponentPath);
      }

      if (component == null)
      {
        throw new WicketRuntimeException("component " + pageRelativeComponentPath +
          " not found on page " + page.getClass().getName() + "[id = " +
          page.getNumericId() + "], listener interface = " + listener);
      }

      if (!component.isEnableAllowed())
      {
        throw new UnauthorizedActionException(component, Component.ENABLE);
      }

      // Ask the request listener interface object to create a request
      // target
      return listener.newRequestTarget(page, component, listener, requestParameters);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.RequestListenerInterface

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.