Java Code Examples for javax.servlet.jsp.tagext.TagSupport#SKIP_BODY

The following examples show how to use javax.servlet.jsp.tagext.TagSupport#SKIP_BODY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeTag.java    From webcurator with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public int doStartTag() throws JspException {
           rowAlt = 0;
	try {
		
		//NodeTree theTree = (NodeTree) ExpressionUtil.evalNotNull("tree", "tree", tree, NodeTree.class, this, pageContext);
		NodeTree theTree = getTree();
		Iterator<Node> rootIterator = theTree.getRootNodes().iterator();
		
		pageContext.getOut().println("<table cellspacing=\"0\" cellpadding=\"0\">");
		
		displayHeader(pageContext.getOut());
		
		while (rootIterator.hasNext()) {
			display(pageContext.getOut(), rootIterator.next(), 0);
		}
		pageContext.getOut().println("</table>");
	} 
	catch (IOException ex) {
		throw new JspException(ex.getMessage(), ex);
	}

	// Never process the body.
	return TagSupport.SKIP_BODY;
}
 
Example 2
Source File: GrpNameTag.java    From webcurator with Apache License 2.0 6 votes vote down vote up
@Override
public int doStartTag() throws JspException {
	try {
		if (name.contains(subGroupSeparator)) {
			int sepIndex = name.lastIndexOf(subGroupSeparator);
			String parentName = name.substring(0, sepIndex);
			String subGroupName = name.substring(sepIndex + subGroupSeparator.length());

			pageContext.getOut().print("<div class=\"subGroupParent\">");
			pageContext.getOut().print(parentName);
			pageContext.getOut().print("</div>");

			pageContext.getOut().print(subGroupSeparator);
			pageContext.getOut().print("<div class=\"subGroupChild\">");
			pageContext.getOut().print(subGroupName);
			pageContext.getOut().print("</div>");
		} else {
			pageContext.getOut().print(name);
		}
	} catch (IOException ex) {
		throw new JspException(ex);
	}

	return TagSupport.SKIP_BODY;
}
 
Example 3
Source File: HasAgencyOwnedPrivTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    if (ownedObject instanceof AgencyOwnable) {
        if (authorityManager.hasPrivilege(ownedObject, privilege)) {
            return TagSupport.EVAL_BODY_INCLUDE;
        } 
        return TagSupport.SKIP_BODY;
    }
    throw new JspException("authority:hasAgencyOwnedPriv tag called but ownedObject was not of type AgencyOwnable");
}
 
Example 4
Source File: HasPermissionTag.java    From jeecg with Apache License 2.0 5 votes vote down vote up
public int doStartTag() throws JspException {
       boolean show = showTagBody(code);
       if (show) {
           return TagSupport.SKIP_BODY;
       } else {
           return TagSupport.EVAL_BODY_INCLUDE;
       }
}
 
Example 5
Source File: HarvestResultChain.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
	try {
		doIt(0);
		return TagSupport.SKIP_BODY;
	}
	catch(IOException ex) { 
		throw new JspException(ex);
	}
}
 
Example 6
Source File: QaIndicatorUnitTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
    *	Output a value and the measurement unit with appropriate scaling 
    */
	@Override
public int doStartTag() throws JspException  {
			
	String output = null;
	
	if (unit.equals("integer")) {
		output = new Integer((new Float(value)).intValue()).toString();
	} else if (unit.equals("millisecond")) {
		output = getElapsedTime();
	} else if (unit.equals("byte")) {
		Long bytes;
		// scale the number of bytes as appropriate
		String[] decimal = value.split("\\.");
		if (decimal.length > 1) {
			bytes = Long.parseLong(decimal[0]);
		} else {
			bytes = Long.parseLong(value);
		}
		output = ConverterUtil.formatBytes(bytes);
	}
	
	try {
		pageContext.getOut().print(output);
	} catch (IOException e) {
		throw new JspException(e);
	}
	
	return TagSupport.SKIP_BODY;
}
 
Example 7
Source File: CustomListTypeTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public int doStartTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
	
	
	WCTTreeSet entries = list.getCopy();
	entries.add(currentValue);
	
	if(onChangeFunction != null && !onChangeFunction.isEmpty())
	{
		writer.println("<select id=\"" + paramName + "\" name=\"" + paramName + "\" onchange=\""+onChangeFunction+"\">");
	}
	else
	{
		writer.println("<select id=\"" + paramName + "\" name=\"" + paramName + "\">");
	}
	
	for (String entry : entries) {
		if (entry.equals(currentValue)) {
			writer.println("<option value=\"" + entry +"\" selected>" + entry +"</option>");
		}
		else {
			writer.println("<option value=\"" + entry +"\">" + entry +"</option>");
		}
	}
	writer.println("</select>");
} 
catch (IOException e) {
	throw new JspException(e.getMessage(), e);
}

return TagSupport.SKIP_BODY;
  }
 
Example 8
Source File: DateTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException  {
	try {
		if("fullDateTime".equals(type)) {
			pageContext.getOut().print(DateUtils.get().formatFullDateTime(value));
		}
		else if("shortDateTime".equals(type)) { 
			pageContext.getOut().print(DateUtils.get().formatShortDateTime(value));
		}
		else if("shortDate".equals(type)) { 
			pageContext.getOut().print(DateUtils.get().formatShortDate(value));
		}
		else if("longDateTime".equals(type)) {
			pageContext.getOut().print(DateUtils.get().formatLongDateTime(value));
		}
		else if("fullDate".equals(type)) {
			pageContext.getOut().print(DateUtils.get().formatFullDate(value));
		}
		else if("fullTime".equals(type)) {
			pageContext.getOut().print(DateUtils.get().formatFullTime(value));
		}			
		else {
			throw new IllegalArgumentException("Illegal Type provided");
		}
	}
	catch(IOException ex) { 
		throw new JspException(ex);
	}
	
	return TagSupport.SKIP_BODY;
}
 
Example 9
Source File: HasPrivilegeTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    if (hasPrivilege(getPrivilege(),getScope()) == true) {
        return TagSupport.EVAL_BODY_INCLUDE;
    } else {
        return TagSupport.SKIP_BODY;
    }
}
 
Example 10
Source File: HideByPermissionTag.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
    * permission control
    */
   @Override
public int doStartTag() throws JspException {
   	ComAdmin aAdmin = AgnUtils.getAdmin(pageContext);
	try {
		if (aAdmin != null && aAdmin.permissionAllowed(Permission.getPermissionsByToken(token))) {
			return TagSupport.SKIP_BODY;
		}
	} catch (Exception e) {
		releaseException(e,token);
	}
	return EVAL_BODY_INCLUDE;
}
 
Example 11
Source File: ShowControlFalseTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {  
	if(getParent() instanceof ShowControlTag) {
		if(((ShowControlTag)getParent()).isShowControl()) {
			return TagSupport.SKIP_BODY;
		}
		else {
			return TagSupport.EVAL_BODY_INCLUDE;
		}
	}
	else {
		throw new JspTagException("True outside ShowControl");
	}
}
 
Example 12
Source File: HasAtLeastOnePrivTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {  
    String[] privArray = getPrivilegeKeys();
    if (authorityManager.hasAtLeastOnePrivilege(privArray)) {
        return TagSupport.EVAL_BODY_INCLUDE;
    }
   	return TagSupport.SKIP_BODY;
}
 
Example 13
Source File: NoPrivilegeTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    User user = AuthUtil.getRemoteUserObject();
    HashMap privs = authorityManager.getPrivilegesForUser(user);
    if (privs.containsKey(getPrivilege())) {
        RolePrivilege rp = (RolePrivilege)privs.get(getPrivilege());
        int usersPrivScope = rp.getPrivilegeScope();
        if (usersPrivScope <= getScope()) {
            return TagSupport.SKIP_BODY;
        }
    }
    return TagSupport.EVAL_BODY_INCLUDE;
}
 
Example 14
Source File: HasUserOwnedPrivTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    if (ownedObject instanceof UserOwnable) {
        if (authorityManager.hasPrivilege(ownedObject, privilege)) {
            return TagSupport.EVAL_BODY_INCLUDE;
        } 
    	// release the object (usually its a target which references tis) from the tag to prevent a memory leak (Tags are pooled)
        ownedObject = null;
        return TagSupport.SKIP_BODY;
    }
    throw new JspException("authority:hasUserOwnedPriv tag called but ownedObject was not of type UserOwnable");
}
 
Example 15
Source File: ShowControlTrueTag.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {  
	if(getParent() instanceof ShowControlTag) {
		if(((ShowControlTag)getParent()).isShowControl()) {
			return TagSupport.EVAL_BODY_INCLUDE;
		}
		else {
			return TagSupport.SKIP_BODY;
		}
	}
	else {
		throw new JspTagException("True outside ShowControl");
	}
}
 
Example 16
Source File: ExtensionI18NTag.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
	try {
		I18NResourceBundle bundle = ExtensionUtils.getExtensionSystem( pageContext.getServletContext()).getPluginI18NResourceBundle( plugin);
		boolean fallback = false;

		if (bundle != null) {
			// This code uses Struts
			String translation = bundle.getMessage( key, getUserLocale());

			if (translation == null) {
				fallback = true;
				logger.warn("Key '" + key + "' not defined in i18n bundle for plugin '" + plugin + "'");
			} else {
				print(translation);
			}
		} else {
			fallback = true;
			logger.warn( "No i18n bundle for plugin '" + plugin + "' defined");
		}

		if (fallback) {
			if (I18nString.hasMessageForKey(key)) {
				print(I18nString.getLocaleString(key, getUserLocale()));
			} else {
				print("?? Missing key " + key + " for plugin " + plugin + " ??");
			}
		}
	} catch( Exception e) {
		logger.error( "Error handling i18n for plugin '" + plugin + "', key '" + key + "'", e);
	}
	
	return TagSupport.SKIP_BODY;
}
 
Example 17
Source File: JSPPageExecuter.java    From ontopia with Apache License 2.0 4 votes vote down vote up
/**
 * Executes the children of this node.
 */
protected void runTag(TagSupport parentTag, JSPTreeNodeIF node)
  throws JspException, IOException {

  //System.out.println("Running: " + node);
  
  List<JSPTreeNodeIF> children = node.getChildren();
  for (JSPTreeNodeIF curNode : children) {
    TagSupport curTag = curNode.getTag();

    // if content tag just put it out and proceed with next
    if (curTag == null) {
      pageContext.getOut().write(curNode.getContent());
      continue;
    }

    // initialize tag
    //! curTag.setParent(node.getTag());
    curTag.setParent(parentTag);
    curTag.setPageContext(pageContext);
    setAttributeValues(curNode, curTag);
    
    // run tag
    int startTagToken = curTag.doStartTag();
    if (startTagToken != TagSupport.SKIP_BODY) {

      if (startTagToken == BodyTagSupport.EVAL_BODY_BUFFERED) {
        // check if BodyTagSupport instance  
        BodyTagSupport btag = (BodyTagSupport) curTag;
        BodyContent body = pageContext.pushBody();
        body.clearBody(); // TOMCAT MADE ME DO IT :-(
        btag.setBodyContent(body);
        btag.doInitBody();

        loopTag(btag, curNode);

        // Release the body
        pageContext.popBody();
      } else if (startTagToken == BodyTagSupport.EVAL_BODY_INCLUDE) {
        loopTag(curTag, curNode);
      } else {
        throw new OntopiaRuntimeException("Internal error: unknown doStartTag token: " + startTagToken);
      }
      
    }
    // FIXME: Handle SKIP_PAGE;
    curTag.doEndTag();
    //tag.release(); FIXME: having this call here can't possibly be correct
  } // for i
}
 
Example 18
Source File: LangTag.java    From HongsCORE with MIT License 4 votes vote down vote up
@Override
public int doStartTag() throws JspException {
  JspWriter out = this.pageContext.getOut();

  if (this.lang == null) {
    lang = CoreLocale.getInstance().clone();
  }

  if (this.load != null) {
    lang.load(this.load);
  }

  if (this.key  != null) {
    String str;
    if (this.repMap != null) {
      str = lang.translate(this.key, this.repMap);
    }
    else if (this.repLst != null) {
      str = lang.translate(this.key, this.repLst);
    }
    else if (this.repArr != null) {
      str = lang.translate(this.key, this.repArr);
    }
    else {
      str = lang.translate(this.key);
    }

    if (this.esc != null
    && ! "".equals(this.esc)
    && ! "no".equals(this.esc)) {
      if ("yes".equals(this.esc)) {
        str = Syno.escape(str);
      }
      else if ("xml".equals(this.esc)) {
        str = Pagelet.escapeXML (str);
      }
      else if ("url".equals(this.esc)) {
        str = Pagelet.encodeURL (str);
      }
      else if ("jss".equals(this.esc)) {
        str = Pagelet.escapeJSS (str);
      }
      else {
        str = Syno.escape(str, this.esc);
      }
    }

    try {
      out.print(str);
    } catch (java.io.IOException ex) {
      throw new JspException("Error in LangTag", ex);
    }
  }

  return TagSupport.SKIP_BODY;
}
 
Example 19
Source File: EllipsisTag.java    From webcurator with Apache License 2.0 4 votes vote down vote up
@Override
public int doStartTag() throws JspException  {
	
		StringBuilder builder = new StringBuilder();
		Integer listSize = strings.size();
		
		Iterator<String> it = strings.iterator();
		int count = 0;
		// build the output string
		while (it.hasNext()) {
			count++;
			String value = it.next();
			if (listSize < 2 || listSize == count) {
				builder.append(value);
			} else {
				builder.append(value).append(", ");
			}
		}
		
		StringBuilder output = new StringBuilder();
		int stringLength;
		if (length > builder.length()) {
			output.append(builder);
		} else {
			// apply ellipsis
			stringLength = length;
			output.append(builder.substring(0, stringLength));
			output.append(ELLIPSIS);
			
	 		// count the spaces
	 		String[] words = output.toString().split(" ");
	 		int spaces = words.length - 1;
	 		
	 		// calculate the value for the "(+n others)" suffix
	 		int others = listSize - spaces - 1;
	 		
			// append the suffix
	 		if (others == 1) {
	 			output.append(" (+");
	 			output.append(others);
	 			output.append(" other)");
	 		} else if (others > 1) {
	 			output.append(" (+");
	 			output.append(others);
	 			output.append(" others)");
	 		}
		}
		
	try {
		pageContext.getOut().print(output);
	} catch (IOException e) {
		throw new JspException(e);
	}
	
	// release resources to prevent memory leak
	strings = null;
	length = null;
	
	return TagSupport.SKIP_BODY;
}
 
Example 20
Source File: ConfTag.java    From HongsCORE with MIT License 4 votes vote down vote up
@Override
public int doStartTag() throws JspException {
  JspWriter out = this.pageContext.getOut();

  if (this.conf == null) {
    conf = CoreConfig.getInstance().clone();
  }

  if (this.load != null) {
    conf.load(this.load);
  }

  if (this.key  != null) {
    String str = conf.getProperty(this.key , this.def != null ? this.def : "");

    if (this.esc  != null
    &&  !    "".equals(this.esc)
    &&  !  "no".equals(this.esc)) {
      if ("yes".equals(this.esc)) {
        str = Syno.escape(str);
      }
      else if ("xml".equals(this.esc)) {
        str = Pagelet.escapeXML (str);
      }
      else if ("url".equals(this.esc)) {
        str = Pagelet.encodeURL (str);
      }
      else if ("jss".equals(this.esc)) {
        str = Pagelet.escapeJSS (str);
      }
      else {
        str = Syno.escape(str, this.esc);
      }
    }

    try {
      out.print(str);
    } catch (java.io.IOException ex) {
      throw new JspException("Error in ConfTag", ex);
    }
  }

  return TagSupport.SKIP_BODY;
}