Package org.apache.wicket.request.resource

Examples of org.apache.wicket.request.resource.ResourceReference


      Class<?> scope = resolveClass(className);

      if (scope != null && scope.getPackage() != null)
      {
        ResourceReference res = getContext().getResourceReferenceRegistry()
          .getResourceReference(scope, name.toString(), attributes.getLocale(),
            attributes.getStyle(), attributes.getVariation(), true, true);

        if (res != null)
        {
View Full Code Here


  public Url mapHandler(IRequestHandler requestHandler)
  {
    if (requestHandler instanceof ResourceReferenceRequestHandler)
    {
      ResourceReferenceRequestHandler referenceRequestHandler = (ResourceReferenceRequestHandler)requestHandler;
      ResourceReference reference = referenceRequestHandler.getResourceReference();

      Url url;

      if (reference instanceof ResourceBundleReference)
      {
        // unwrap the bundle to render the url for the actual reference
        reference = ((ResourceBundleReference)reference).getBundleReference();
      }

      if (reference instanceof MetaInfStaticResourceReference)
      {
        url = ((MetaInfStaticResourceReference)reference).mapHandler(referenceRequestHandler);
        // if running on Servlet 3.0 engine url is not null
        if (url != null)
        {
          return url;
        }
        // otherwise it has to be served by the standard wicket way
      }
      else if (reference instanceof UrlResourceReference)
      {
        UrlResourceReference urlReference = (UrlResourceReference)reference;
        url = urlReference.getUrl();
        return url;
      }

      if (reference.canBeRegistered())
      {
        ResourceReferenceRegistry resourceReferenceRegistry = getContext().getResourceReferenceRegistry();
        resourceReferenceRegistry.registerResourceReference(reference);
      }

      url = new Url();

      List<String> segments = url.getSegments();
      segments.add(getContext().getNamespace());
      segments.add(getContext().getResourceIdentifier());
      segments.add(getClassName(reference.getScope()));

      // setup resource parameters
      PageParameters parameters = referenceRequestHandler.getPageParameters();

      if (parameters == null)
      {
        parameters = new PageParameters();
      }
      else
      {
        parameters = new PageParameters(parameters);

        // need to remove indexed parameters otherwise the URL won't be able to decode
        parameters.clearIndexed();
      }
      encodeResourceReferenceAttributes(url, reference);

      StringTokenizer tokens = new StringTokenizer(reference.getName(), "/");

      while (tokens.hasMoreTokens())
      {
        String token = tokens.nextToken();

        // on the last component of the resource path
        if (tokens.hasMoreTokens() == false && Strings.isEmpty(token) == false)
        {
          final IResource resource = reference.getResource();

          // is resource supposed to be cached?
          if (resource instanceof IStaticCacheableResource)
          {
            final IStaticCacheableResource cacheable = (IStaticCacheableResource)resource;
View Full Code Here

    super.renderHead(response);

    CoreLibrariesContributor.contributeAjax(getApplication(), response);
    response.render(JavaScriptHeaderItem.forReference(JAVASCRIPT));

    ResourceReference cssResource = newCssResource();
    if (cssResource != null)
    {
      response.render(CssHeaderItem.forReference(cssResource));
    }
  }
View Full Code Here

  @Override
  public Iterable<? extends HeaderItem> getDependencies()
  {
    IJavaScriptLibrarySettings ajaxSettings = Application.get().getJavaScriptLibrarySettings();
    ResourceReference wicketEventReference = ajaxSettings.getWicketEventReference();
    return Collections.singletonList(JavaScriptHeaderItem.forReference(wicketEventReference));
  }
View Full Code Here

    @Override
    public ResourceReference resourceReferenceForSpec(final ObjectSpecification spec) {
        if(spec == null) {
            return fallbackResourceReference();
        }
        ResourceReference resourceReference = resourceReferenceBySpec.get(spec);
        if(resourceReference != null) {
            return resourceReference;
        }
       
        resourceReference = lookupResourceReferenceFor(spec);
View Full Code Here

    private ResourceReference lookupResourceReferenceFor(final ObjectSpecification spec) {
        final Class<?> correspondingClass = spec.getCorrespondingClass();
        final String specName = correspondingClass.getSimpleName();
       
        final ResourceReference resourceReference = resourceReferenceFor(specName);
        if(resourceReference != null) {
            return resourceReference;
        }
       
        // search up hierarchy
View Full Code Here

   */
  @Override
  public void renderHead(final IHeaderResponse response)
  {
    response.render(JavaScriptHeaderItem.forReference(JAVASCRIPT));
    ResourceReference css = getCSS();
    if (css != null)
    {
      response.render(CssHeaderItem.forReference(css));
    }
  }
View Full Code Here

      Class<?> scope = resolveClass(className);

      if (scope != null && scope.getPackage() != null)
      {
        ResourceReference res = getContext().getResourceReferenceRegistry()
          .getResourceReference(scope, name.toString(), attributes.getLocale(),
            attributes.getStyle(), attributes.getVariation(), true, true);

        if (res != null)
        {
View Full Code Here

  public Url mapHandler(IRequestHandler requestHandler)
  {
    if (requestHandler instanceof ResourceReferenceRequestHandler)
    {
      ResourceReferenceRequestHandler referenceRequestHandler = (ResourceReferenceRequestHandler)requestHandler;
      ResourceReference reference = referenceRequestHandler.getResourceReference();

      Url url;

      if (reference instanceof ResourceBundleReference)
      {
        // unwrap the bundle to render the url for the actual reference
        reference = ((ResourceBundleReference)reference).getBundleReference();
      }

      if (reference instanceof MetaInfStaticResourceReference)
      {
        url = ((MetaInfStaticResourceReference)reference).mapHandler(referenceRequestHandler);
        // if running on Servlet 3.0 engine url is not null
        if (url != null)
        {
          return url;
        }
        // otherwise it has to be served by the standard wicket way
      }
      else if (reference instanceof ExternalUrlResourceReference)
      {
        ExternalUrlResourceReference externalUrlReference = (ExternalUrlResourceReference)reference;
        url = externalUrlReference.getUrl();
        return url;
      }

      url = new Url();

      List<String> segments = url.getSegments();
      segments.add(getContext().getNamespace());
      segments.add(getContext().getResourceIdentifier());
      segments.add(getClassName(reference.getScope()));

      // setup resource parameters
      PageParameters parameters = referenceRequestHandler.getPageParameters();

      if (parameters == null)
      {
        parameters = new PageParameters();
      }
      else
      {
        parameters = new PageParameters(parameters);

        // need to remove indexed parameters otherwise the URL won't be able to decode
        parameters.clearIndexed();
      }
      encodeResourceReferenceAttributes(url, reference);

      StringTokenizer tokens = new StringTokenizer(reference.getName(), "/");

      while (tokens.hasMoreTokens())
      {
        String token = tokens.nextToken();

        // on the last component of the resource path
        if (tokens.hasMoreTokens() == false && Strings.isEmpty(token) == false)
        {
          final IResource resource = reference.getResource();

          // is resource supposed to be cached?
          if (resource instanceof IStaticCacheableResource)
          {
            final IStaticCacheableResource cacheable = (IStaticCacheableResource)resource;
View Full Code Here

   *            the resource to test
   * @return the used {@link ResourceReference} for the simulation
   */
  public ResourceReference startResource(final IResource resource)
  {
    return startResourceReference(new ResourceReference("testResourceReference")
    {
      private static final long serialVersionUID = 1L;

      @Override
      public IResource getResource()
View Full Code Here

TOP

Related Classes of org.apache.wicket.request.resource.ResourceReference

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.