Package org.apache.wicket.util.resource

Examples of org.apache.wicket.util.resource.UrlResourceStream


                // try to load the resource from the web context
                URL url = getServletContext().getResource(location);
               
                if (url != null)
                {
                    return new UrlResourceStream(url);
                }
            }
            catch (MalformedURLException e)
            {
                throw new WicketRuntimeException(e);
View Full Code Here


  @Test
  public void testUrlResource() throws Exception
  {
    IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class);

    UrlResourceStream urs = new UrlResourceStream(new URL("file:///"));

    when(resourceStreamLocator.locate(String.class, "path")).thenReturn(urs);

    CachingResourceStreamLocator cachingLocator = new CachingResourceStreamLocator(
      resourceStreamLocator);
View Full Code Here

      String absolutePath = fileResourceStream.getFile().getAbsolutePath();
      cache.put(key, new FileResourceStreamReference(absolutePath));
    }
    else if (stream instanceof UrlResourceStream)
    {
      UrlResourceStream urlResourceStream = (UrlResourceStream)stream;
      String url = urlResourceStream.getURL().toExternalForm();
      cache.put(key, new UrlResourceStreamReference(url));
    }
  }
View Full Code Here

    public UrlResourceStream getReference()
    {
      try
      {
        return new UrlResourceStream(new URL(url));
      }
      catch (MalformedURLException e)
      {
        // should not ever happen. The cached url is created by previously existing URL
        // instance
View Full Code Here

      private static final long serialVersionUID = 1L;

      @Override
      protected IResourceStream getTemplateResource()
      {
        return new UrlResourceStream(getClass().getResource("testWithMarkup.html"));
      }

      @Override
      public boolean parseGeneratedMarkup()
      {
View Full Code Here

  public VelocityPage()
  {
    HashMap<String, String> values = new HashMap<String, String>();
    values.put("message", TEST_STRING);
    add(VelocityPanel.forTemplateResource("velocityPanel", new Model<HashMap<String, String>>(
      values), new UrlResourceStream(this.getClass().getResource("test.html"))));
  }
View Full Code Here

    values.put("labelId", "message");
    VelocityPanel velocityPanel = new VelocityPanel("velocityPanel", new Model(values))
    {
      protected IStringResourceStream getTemplateResource()
      {
        return new UrlResourceStream(getClass().getResource("testWithMarkup.html"));
      }

      public boolean parseGeneratedMarkup()
      {
        return true;
View Full Code Here

   *            the url
   * @return the imported contents
   */
  private final String importUrl(URL url)
  {
    UrlResourceStream resourceStream = new UrlResourceStream(url);
    String content = resourceStream.asString();
    return content;
  }
View Full Code Here

  @Test
  public void testUrlResource() throws Exception
  {
    IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class);

    UrlResourceStream urs = new UrlResourceStream(new URL("file:///"));

    when(resourceStreamLocator.locate(String.class, "path")).thenReturn(urs);

    CachingResourceStreamLocator cachingLocator = new CachingResourceStreamLocator(
      resourceStreamLocator);
View Full Code Here

   *            the url
   * @return the imported contents
   */
  private final String importUrl(URL url)
  {
    UrlResourceStream resourceStream = new UrlResourceStream(url);
    String content = resourceStream.asString();
    return content;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.resource.UrlResourceStream

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.