示例#1
0
 @Override
 public FacesId inferType() throws CallbackException {
   // For renderers with template - try to determine type by template file.
   if (null != this.renderer.getTemplate()) {
     for (ComponentModel component : this.library.getComponents()) {
       if (null != component.getRendererTemplate()
           && this.renderer
               .getTemplate()
               .getTemplatePath()
               .endsWith(component.getRendererTemplate())) {
         if (null != component.getRendererType()) {
           return component.getRendererType();
         } else {
           FacesId rendererType = namingConventions.inferRendererType(component.getId());
           component.setRendererType(rendererType);
           return rendererType;
         }
       }
     }
     // No component found, try to infer from template path.
     return namingConventions.inferRendererTypeByTemplatePath(
         this.renderer.getTemplate().getTemplatePath());
   }
   // If previvious attempt fall, try to infer renderer type from family.
   if (null != this.renderer.getFamily()) {
     return namingConventions.inferRendererType(this.renderer.getFamily());
   }
   throw new CallbackException("Cannot determine renderer type");
 }
示例#2
0
  protected void vefifyRenderer(final ComponentLibrary library, final RendererModel renderer) {

    String baseName = renderer.getBaseClass().getSimpleName().replaceFirst("Base$", "");

    // Check renderer-type
    if (null == renderer.getId()) {
      if (null == renderer.getTemplate().getTemplatePath()) {
        throw new IllegalArgumentException("templatePath must not be null");
      }
      renderer.setId(
          namingConventions.inferRendererTypeByTemplatePath(
              renderer.getTemplate().getTemplatePath()));
    }
    // Check family.
    if (null == renderer.getFamily()) {
      renderer.setFamily(namingConventions.inferRendererFamily(renderer.getId()));
    }
    // Check type.
    verifyTypes(renderer, new RendererTypeCallback(library, renderer));
    // Check component type.
    for (ComponentModel component : library.getComponents()) {
      if (renderer.getId().equals(component.getRendererType())) {
        copyRendererAttributes(renderer, component);
      } else if (hasRendererSameBaseNameAsComponent(renderer, component)) {
        copyRendererAttributes(renderer, component);
        component.setRendererType(renderer.getId());
      }
    }
    // Check template
    if (renderer.getTemplate() != null && renderer.getTemplate().getInterface() != null) {
      if (null == renderer.getTemplate().getInterface().getJavaClass()) {
        renderer.getTemplate().getInterface().setJavaClass(renderer.getTargetClass());
      }
    }
  }
示例#3
0
 protected void verifyTaglib(ComponentLibrary library) {
   Taglib taglib = library.getTaglib();
   if (null == taglib) {
     // Oops, create taglib model
     taglib = new Taglib();
     library.setTaglib(taglib);
   }
   // Verify URI
   String uri = taglib.getUri();
   if (null == uri) {
     // infer default value.
     uri = namingConventions.inferTaglibUri(library);
     taglib.setUri(uri);
     // log.error("No uri defined for taglib");
   }
   String shortName = taglib.getShortName();
   if (null == shortName) {
     shortName = namingConventions.inferTaglibName(uri);
     taglib.setShortName(shortName);
     // log.error("No short defined for taglib");
   }
   // Verify tags. If we have renderer-specific component, it should have a tag ?
   for (ComponentModel component : library.getComponents()) {
     if (null != component.getRendererType() && component.getTags().isEmpty()) {
       TagModel tag = new TagModel();
       verifyTag(tag, component.getId(), DEFAULT_COMPONENT_HANDLER);
       component.getTags().add(tag);
     }
   }
 }