Package railo.transformer.library.tag

Examples of railo.transformer.library.tag.TagLibTag


  private final Tag _propertyStatement(ExprData data,Body parent) throws TemplateException  {
    if(data.context!=CTX_CFC || !data.cfml.forwardIfCurrent("property "))
      return null;
    Position line = data.cfml.getPosition();
   
    TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,"property");
    Tag property=new TagOther(line,null);
    addMetaData(data, property,IGNORE_LIST_PROPERTY);
   

    boolean hasName=false,hasType=false;
View Full Code Here


  private Tag _paramStatement(ExprData data,Body parent) throws TemplateException  {
    if(!data.cfml.forwardIfCurrent("param "))
      return null;
    Position line = data.cfml.getPosition();
   
    TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,"param");
    TagParam param=new TagParam(line,null);
   
    // type
    boolean hasType=false;
    int pos = data.cfml.getPos();
View Full Code Here

  public void evaluate(Tag tag,TagLibTag libTag) throws EvaluatorException {
    if(tag.containsAttribute("query")) {
       
     
        TagLib lib = libTag.getTagLib();
        TagLibTag outputTag = lib.getTag("output");
       
        TagOutput output=new TagOutput(tag.getStart(),null);
        output.setFullname(outputTag.getFullName());
        output.setTagLibTag(outputTag);
        output.addAttribute(new Attribute(false,"output",LitBoolean.TRUE,"boolean"));
        output.addAttribute(new Attribute(false,"formail",LitBoolean.TRUE,"boolean"));
       
        Body body=new BodyBase();//output.getBody();
View Full Code Here

      //args.set(KeyConstants._CALLER, Duplicator.duplicate(pageContext.undefinedScope(),false));
  }

  private static void validateAttributes(Component cfc,StructImpl attributesScope,String tagName) throws ApplicationException, ExpressionException {
   
    TagLibTag tag=getAttributeRequirments(cfc,false);
    if(tag==null) return;
   
    if(tag.getAttributeType()==TagLibTag.ATTRIBUTE_TYPE_FIXED || tag.getAttributeType()==TagLibTag.ATTRIBUTE_TYPE_MIXED){
      Iterator<Entry<String, TagLibTagAttr>> it = tag.getAttributes().entrySet().iterator();
      int count=0;
      Collection.Key key;
      TagLibTagAttr attr;
      Object value;
      Entry<String, TagLibTagAttr> entry;
      // check existing attributes
      while(it.hasNext()){
        entry = it.next();
        count++;
        key=KeyImpl.toKey(entry.getKey(),null);
        attr=entry.getValue();
        value=attributesScope.get(key,null);
        if(value==null){
          if(attr.getDefaultValue()!=null){
            value=attr.getDefaultValue();
            attributesScope.setEL(key, value);
          }
          else if(attr.isRequired())
            throw new ApplicationException("attribute ["+key.getString()+"] is required for tag ["+tagName+"]");
        }
        if(value!=null) {
          if(!Decision.isCastableTo(attr.getType(),value,true,true,-1))
            throw new CasterException(createMessage(attr.getType(), value));
       
        }
      }
     
      // check if there are attributes not supported
      if(tag.getAttributeType()==TagLibTag.ATTRIBUTE_TYPE_FIXED && count<attributesScope.size()){
        Collection.Key[] keys = attributesScope.keys();
        for(int i=0;i<keys.length;i++){
          if(tag.getAttribute(keys[i].getLowerString())==null)
            throw new ApplicationException("attribute ["+keys[i].getString()+"] is not supported for tag ["+tagName+"]");
        }
       
         //Attribute susi is not allowed for tag cfmail
      }
View Full Code Here

        Member mem = ComponentUtil.toComponentAccess(cfc).getMember(Component.ACCESS_PRIVATE, KeyConstants._metadata,true,false);
        if(mem!=null)meta = Caster.toStruct(mem.getValue(),null,false);
    //}catch (PageException e) {e.printStackTrace();}
      if(meta==null) return null;
     
      TagLibTag tag=new TagLibTag(null);
    // TAG

      // type     
      String type=Caster.toString(meta.get(ATTRIBUTE_TYPE,"dynamic"),"dynamic");
     
      if("fixed".equalsIgnoreCase(type))tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_FIXED);
      //else if("mixed".equalsIgnoreCase(type))tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_MIXED);
      //else if("noname".equalsIgnoreCase(type))tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_NONAME);
      else tag.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_DYNAMIC);
     
      if(!runtime){
        // hint
        String hint=Caster.toString(meta.get(KeyConstants._hint,null),null);
        if(!StringUtil.isEmpty(hint))tag.setDescription(hint);
      }
     
    // ATTRIBUTES
      Struct attributes=Caster.toStruct(meta.get(KeyConstants._ATTRIBUTES,null),null,false);
      if(attributes!=null) {
        Iterator<Entry<Key, Object>> it = attributes.entryIterator();
        //Iterator it = attributes.entrySet().iterator();
        Entry<Key, Object> entry;
        TagLibTagAttr attr;
        Struct sct;
        String name;
        Object defaultValue;
        while(it.hasNext()){
          entry=it.next();
          name=Caster.toString(entry.getKey(),null);
          if(StringUtil.isEmpty(name)) continue;
          attr=new TagLibTagAttr(tag);
          attr.setName(name);
         
          sct=Caster.toStruct(entry.getValue(),null,false);
          if(sct!=null){
            attr.setRequired(Caster.toBooleanValue(sct.get(KeyConstants._required,Boolean.FALSE),false));
            attr.setType(Caster.toString(sct.get(KeyConstants._type,"any"),"any"));
           
            defaultValue= sct.get(KeyConstants._default,null);
            if(defaultValue!=null)attr.setDefaultValue(defaultValue);
           
           
            if(!runtime){
              attr.setDescription(Caster.toString(sct.get(KeyConstants._hint,null),null));
              attr.setRtexpr(Caster.toBooleanValue(sct.get(RT_EXPR_VALUE,Boolean.TRUE),true));
            }
          }
          tag.setAttribute(attr);
         
        }
      }
      return tag;
  }
View Full Code Here

      ThreadLocalPageContext.register(pc);
        try{
        TagLibTagAttr attrFileName,attrIsWeb;
          String filename;
        Boolean isWeb;
        TagLibTag tlt;
       
        TagLib[] tlds = cw.getTLDs();
        for(int i=0;i<tlds.length;i++){
          Map<String, TagLibTag> tags = tlds[i].getTags();
          Iterator<TagLibTag> it = tags.values().iterator();
          while(it.hasNext()){
            tlt = it.next();
            if("railo.runtime.tag.CFTagCore".equals(tlt.getTagClassName())) {
              attrFileName = tlt.getAttribute("__filename");
              attrIsWeb = tlt.getAttribute("__isweb");
              if(attrFileName!=null && attrIsWeb!=null) {
                filename = Caster.toString(attrFileName.getDefaultValue(),null);
                isWeb=Caster.toBoolean(attrIsWeb.getDefaultValue(),null);
                if(filename!=null && isWeb!=null) {
                  addTagMetaData(pc, tlds[i], tlt, filename,isWeb.booleanValue());
View Full Code Here

    }

    protected void addTag(String nameSpace, String nameSpaceSeperator,String name, String clazz){
      for(int i=0;i<tlds.length;i++) {
          if(tlds[i].getNameSpaceAndSeparator().equalsIgnoreCase(nameSpace+nameSpaceSeperator)){
            TagLibTag tlt = new TagLibTag(tlds[i]);
            tlt.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_DYNAMIC);
            tlt.setBodyContent("free");
            tlt.setTagClass(clazz);
            tlt.setName(name);
            tlds[i].setTag(tlt    );
          }
        }
    }
View Full Code Here

    }
   
    public void createTag(TagLib tl,String filename) {// Jira 1298
      String name=toName(filename);//filename.substring(0,filename.length()-(getCFCExtension().length()+1));
       
      TagLibTag tlt = new TagLibTag(tl);
        tlt.setName(name);
        tlt.setTagClass("railo.runtime.tag.CFTagCore");
        tlt.setHandleExceptions(true);
        tlt.setBodyContent("free");
        tlt.setParseBody(false);
        tlt.setDescription("");
        tlt.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_MIXED);


        TagLibTagAttr tlta = new TagLibTagAttr(tlt);
        tlta.setName("__filename");
        tlta.setRequired(true);
        tlta.setRtexpr(true);
        tlta.setType("string");
        tlta.setHidden(true);
        tlta.setDefaultValue(filename);
        tlt.setAttribute(tlta);
       
        tlta = new TagLibTagAttr(tlt);
        tlta.setName("__name");
        tlta.setRequired(true);
        tlta.setRtexpr(true);
        tlta.setHidden(true);
        tlta.setType("string");
        tlta.setDefaultValue(name);
        tlt.setAttribute(tlta);
       
        tlta = new TagLibTagAttr(tlt);
        tlta.setName("__isweb");
        tlta.setRequired(true);
        tlta.setRtexpr(true);
        tlta.setHidden(true);
        tlta.setType("boolean");
        tlta.setDefaultValue(this instanceof ConfigWeb?"true":"false");
        tlt.setAttribute(tlta);
       
        tl.setTag(tlt);
    }
View Full Code Here

  public static void throwIfNotEmpty(Tag tag) throws EvaluatorException {
    Body body = tag.getBody();
    List<Statement> statments = body.getStatements();
    Statement stat;
    Iterator<Statement> it = statments.iterator();
    TagLibTag tlt;
   
    while(it.hasNext()) {
      stat=it.next();
      if(stat instanceof Tag) {
        tlt = ((Tag)stat).getTagLibTag();
        if(!tlt.getTagClassName().equals("railo.runtime.tag.Argument"))
          throw new EvaluatorException("tag "+tlt.getFullName()+" is not allowed inside a function declaration");
      }
      /*else if(stat instanceof PrintOut) {
        //body.remove(stat);
      }*/
    }
 
View Full Code Here

    }
   
    // if cfc has no component tag or is script without cfscript
    if(p.isPage() && ResourceUtil.getExtension(sf.getResource(),"").equalsIgnoreCase(config.getCFCExtension())){
      cfml.setPos(0);
      TagLibTag tlt;
      CFMLString original = cfml;
     
      // try inside a cfscript
      tlt = CFMLTransformer.getTLT(original,"script");
      String text="<"+tlt.getFullName()+">"+original.getText()+"</"+tlt.getFullName()+">";
      cfml=new CFMLString(text,charset,writeLog,sf);
     
      try {
        while(true){
          if(cfml==null){
            cfml=new CFMLString(sf,charset,writeLog);
            text="<"+tlt.getFullName()+">"+cfml.getText()+"</"+tlt.getFullName()+">";
            cfml=new CFMLString(text,charset,writeLog,sf);
          }
          try {
            p= transform(config,cfml,tlibs,flibs,sf.getResource().lastModified(),dotUpper);
            break;
          }
          catch(ProcessingDirectiveException pde) {
            if(pde.getWriteLog()!=null)writeLog=pde.getWriteLog().booleanValue();
            if(pde.getDotNotationUpperCase()!=null)dotUpper=pde.getDotNotationUpperCase().booleanValue();
            if(!StringUtil.isEmpty(pde.getCharset()))charset=pde.getCharset();
            cfml=null;
          }
        }
      }
      catch (ComponentTemplateException e) {
        throw e.getTemplateException();
      }
      catch (TemplateException e) {
        //print.printST(e);
      }
     
     
     
     
      // try inside a component
      if(p.isPage()){
        tlt = CFMLTransformer.getTLT(original,"component");
        text="<"+tlt.getFullName()+">"+original.getText()+"</"+tlt.getFullName()+">";
        cfml=new CFMLString(text,charset,writeLog,sf);
           
        while(true){
          if(cfml==null){
            cfml=new CFMLString(sf,charset,writeLog);
            text="<"+tlt.getFullName()+">"+cfml.getText()+"</"+tlt.getFullName()+">";
            cfml=new CFMLString(text,charset,writeLog,sf);
          }
          try {
            p= transform(config,cfml,tlibs,flibs,sf.getResource().lastModified(),dotUpper);
            break;
View Full Code Here

TOP

Related Classes of railo.transformer.library.tag.TagLibTag

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.