Package org.ajax4jsf.resource

Examples of org.ajax4jsf.resource.InternetResourceBuilder


    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

        UIResource userXcssComponent = createLoadStyleComponent();

        userXcssComponent.setSrc(RESOURCE_URI_PREFIX + userXcss);
        childrenList.add(userXcssComponent);

        InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();

        childrenList.add(new ResourceDependentComponent(false, resourceBuilder.getResourceForKey(componentXcss),
                resourceBuilder.getResourceForKey(userXcss)));

        UIResource componentXcssComponent = createLoadStyleComponent();

        componentXcssComponent.setSrc(RESOURCE_URI_PREFIX + componentXcss);
        childrenList.add(componentXcssComponent);
View Full Code Here

    @Override
    public void setUp() throws Exception {
        super.setUp();

        InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();

        try {
            resourceBuilder.getResource(SIMULATION_SCRIPT_NAME);
        } catch (ResourceNotFoundException e) {
            resourceBuilder.createResource(null, SIMULATION_SCRIPT_NAME);
        }

        UIViewRoot viewRoot = facesContext.getViewRoot();
        UIResource resource;
        UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
View Full Code Here

        throw new FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"uriAttribute",component.getClientId(context)));
      }
    }
    writer.startElement(element,mmedia);
    getUtils().encodeId(context,component);
    InternetResourceBuilder internetResourceBuilder = InternetResourceBuilder.getInstance();
    InternetResource resource = internetResourceBuilder.createUserResource(mmedia.isCacheable(),mmedia.isSession(),mmedia.getMimeType());
    StringBuffer uri = new StringBuffer(resource.getUri(context,mmedia));
    // Append parameters to resource Uri
    boolean haveQestion = uri.indexOf("?")>=0;
        Iterator kids = component.getChildren().iterator();
        while (kids.hasNext()) {
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

            viewResources.setProcessStyles(false);
          }
        } catch (SkinNotFoundException e) {
          log.warn("Current Skin is not found", e);
        }
        InternetResourceBuilder internetResourceBuilder = InternetResourceBuilder.getInstance();
        // Check init parameters for a resources processing.
        String scriptStrategy = externalContext.getInitParameter(InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM);
        if(null != scriptStrategy){
          if(InternetResourceBuilder.LOAD_NONE.equals(scriptStrategy)){
            viewResources.setProcessScripts(false);
          } else if (InternetResourceBuilder.LOAD_ALL.equals(scriptStrategy)) {
            viewResources.setProcessScripts(false);
            viewResources.addScript(internetResourceBuilder.createResource(this, InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT).getUri(context, null));
            viewResources.addScript(internetResourceBuilder.createResource(this, InternetResourceBuilder.COMMON_UI_SCRIPT).getUri(context, null));
          }
        }
        String styleStrategy = externalContext.getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
        if(null != styleStrategy){
          if(InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)){
            viewResources.setProcessStyles(false);
          } else if (InternetResourceBuilder.LOAD_ALL.equals(styleStrategy)) {
            viewResources.setProcessStyles(false);
            viewResources.addStyle(internetResourceBuilder.createResource(this, InternetResourceBuilder.COMMON_STYLE).getUri(context, null));
          }
        }
        viewResources.collect(context);
        Set scripts = viewResources.getScripts();
        if (scripts.size() > 0) {
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

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.