Package org.ajax4jsf.resource

Examples of org.ajax4jsf.resource.InternetResourceBuilder


      public WebResponse getResponse(WebRequestSettings settings)
      throws IOException {
        String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
            request.getContextPath().length()));
        if (resourceKey != null) {
          InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
         
          InternetResource resource = resourceBuilder.getResourceForKey(resourceKey);
          Object resourceData = resourceBuilder.getResourceDataForKey(resourceKey);

          final MockFacesResourceContext resourceContext = new MockFacesResourceContext(facesContext);
          resourceContext.setResourceData(resourceData);

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here


   * Set JavaScript renderer and modification time to application-startup time.
   */
  public ClientScript() {
    super();
    setRenderer(new ScriptRenderer());
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
    String key = this.getClass().getName();
    try {
      // Search already registered resource for this class.
      InternetResource resource = resourceBuilder.getResource(key);
      this.setKey(resource.getKey());
    } catch(ResourceNotFoundException ex){
      // If script not registered, append it to builder.
      setLastModified(new Date(resourceBuilder.getStartTime()));
      resourceBuilder.addResource(key,this);
    }
    String script ;
    if (getJavaScript().startsWith("/")) {
      // remove lead / for classloader covention.
      script = getJavaScript().substring(1);
View Full Code Here

        String styleAttr = div2.getAttributeValue("style");
        assertTrue(styleAttr.contains("org.richfaces.renderkit.html.images.BevelSeparatorImage"));
    }

    public void testRenderImage() throws Exception {
        InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();

        ui.setLineType(SeparatorRendererBase.LINE_TYPE_BEVEL);
        renderView();
        InternetResource resource = builder.getResource("org.richfaces.renderkit.html.images.BevelSeparatorImage");
        assertNotNull(resource);
        String uri = "http:" + resource.getUri(facesContext, ui);
        Page page = webClient.getPage(uri);
        assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
        ImageInfo info = new ImageInfo();
        info.setInput(page.getWebResponse().getContentAsStream());
        //image recognizable?
        assertTrue(info.check());
        assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());

        ui.setLineType(SeparatorRendererBase.LINE_TYPE_SOLID);
        renderView();
        resource = builder.getResource("org.richfaces.renderkit.html.images.SimpleSeparatorImage");
        assertNotNull(resource);
        uri = "http:" + resource.getUri(facesContext, ui);
        page = webClient.getPage(uri);
        assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
        info = new ImageInfo();
        info.setInput(page.getWebResponse().getContentAsStream());
        //image recognizable?
        assertTrue(info.check());
        assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());

        ui.setLineType(SeparatorRendererBase.LINE_TYPE_DOTTED);
        renderView();
        resource = builder.getResource("org.richfaces.renderkit.html.images.SimpleSeparatorImage");
        assertNotNull(resource);
        uri = "http:" + resource.getUri(facesContext, ui);
        page = webClient.getPage(uri);
        assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
        info = new ImageInfo();
        info.setInput(page.getWebResponse().getContentAsStream());
        //image recognizable?
        assertTrue(info.check());
        assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
       
        ui.setLineType(SeparatorRendererBase.LINE_TYPE_DASHED);
        renderView();
        resource = builder.getResource("org.richfaces.renderkit.html.images.SimpleSeparatorImage");
        assertNotNull(resource);
        uri = "http:" + resource.getUri(facesContext, ui);
        page = webClient.getPage(uri);
        assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
        info = new ImageInfo();
        info.setInput(page.getWebResponse().getContentAsStream());
        //image recognizable?
        assertTrue(info.check());
        assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
       
        ui.setLineType(SeparatorRendererBase.LINE_TYPE_DOUBLE);
        renderView();
        resource = builder.getResource("org.richfaces.renderkit.html.images.SimpleSeparatorImage");
        assertNotNull(resource);
        uri = "http:" + resource.getUri(facesContext, ui);
        page = webClient.getPage(uri);
        assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
        info = new ImageInfo();
View Full Code Here

   * @return InputStream of the resource, if resource present
   *
   * @throws IOException - if resource not available
   */
  protected InputStream getResourceIfPresent(String path) throws IOException {
    InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
    InternetResource resource = builder.getResource(path);
    if (resource != null) {
      String uri = HTTP_PREFIX + resource.getUri(facesContext, null);
      Page page = webClient.getPage(uri);
      if (page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK) {
        return page.getWebResponse().getContentAsStream();
View Full Code Here

      public WebResponse getResponse(WebRequestSettings settings)
      throws IOException {
        String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
            request.getContextPath().length()));
        if (resourceKey != null) {
          InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
         
          InternetResource resource = resourceBuilder.getResourceForKey(resourceKey);
          Object resourceData = resourceBuilder.getResourceDataForKey(resourceKey);

          final MockFacesResourceContext resourceContext = new MockFacesResourceContext(facesContext);
          resourceContext.setResourceData(resourceData);

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

      path.append('/');
    }
   
    path.append(resourceName);
   
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
    try {
      final InternetResource resource = resourceBuilder.getResource(path.toString());
      return new Resource() {
       
        @Override
        public boolean userAgentNeedsUpdate(FacesContext context) {
          return true;
View Full Code Here

  public LoadResourceComponentTest(String name) {
    super(name);
  }
 
  private void registerResource(String path) {
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();

    try {
      resourceBuilder.getResource(path);
    } catch (ResourceNotFoundException e) {
      resourceBuilder.createResource(null, path);
    }
  }
View Full Code Here

    scripts = selectScriptsBySrc(page, componentJs);
    assertEquals(0, scripts.size());
  }
 
  public void testRenderScriptResource() throws Exception {
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
    createAndAddScriptResource(resourceBuilder.getResourceForKey(userJs));
    createAndAddScriptResource(resourceBuilder.getResourceForKey(componentJs)).setRendered(false);

    HtmlPage page = renderView();
    List<HtmlScript> scripts;
   
    scripts = selectScriptsBySrc(page, userJs);
View Full Code Here

    styles = selectStylesByHhref(page, componentXcss);
    assertEquals(0, styles.size());
  }
 
  public void testRenderStyleResource() throws Exception {
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
    createAndAddStyleResource(resourceBuilder.getResourceForKey(userXcss));
    createAndAddStyleResource(resourceBuilder.getResourceForKey(componentXcss)).setRendered(false);

    UIResource styleComponent = createLoadStyleComponent();
    styleComponent.setSrc(InternetResourceBuilder.getInstance().getResourceForKey(userXcss));
    facesContext.getViewRoot().getChildren().add(styleComponent);
   
View Full Code Here

    UIResource userJsComponent = createLoadScriptComponent();
    userJsComponent.setSrc(RESOURCE_URI_PREFIX + userJs);
    childrenList.add(userJsComponent);
   
    InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
   
    childrenList.add(new ResourceDependentComponent(true,
        resourceBuilder.getResourceForKey(componentJs),
        resourceBuilder.getResourceForKey(userJs)));

    UIResource componentJsComponent = createLoadScriptComponent();
    componentJsComponent.setSrc(RESOURCE_URI_PREFIX + componentJs);
    childrenList.add(componentJsComponent);
   
View Full Code Here

TOP

Related Classes of org.ajax4jsf.resource.InternetResourceBuilder

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.