本文整理汇总了Java中org.apache.velocity.runtime.parser.node.Node.render方法的典型用法代码示例。如果您正苦于以下问题:Java Node.render方法的具体用法?Java Node.render怎么用?Java Node.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.velocity.runtime.parser.node.Node
的用法示例。
在下文中一共展示了Node.render方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
// get the bean
ValueStack stack = (ValueStack) ctx.get("stack");
HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
Component bean = getBean(stack, req, res);
Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
container.inject(bean);
// get the parameters
Map params = createPropertyMap(ctx, node);
bean.copyParams(params);
//bean.addAllParameters(params);
bean.start(writer);
if (getType() == BLOCK) {
Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1);
body.render(ctx, writer);
}
bean.end(writer, "");
return true;
}
示例2: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
Object value = node.jjtGetChild(0).value(context);
boolean isEmpty = false ;
if(value == null){
isEmpty = true ;
}else{
if(value instanceof String){
isEmpty = StringUtil.isEmpty((String) value) ;
}else if(value instanceof Collection){
isEmpty = ((Collection) value).isEmpty() ;
}else if(value.getClass().isArray()){
isEmpty = Array.getLength(value) > 0 ;
}
}
if (isEmpty) {
Node content = node.jjtGetChild(1);
content.render(context, writer);
}
return true;
}
示例3: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
Object value = node.jjtGetChild(0).value(context);
boolean isEmpty = false ;
if(value == null){
isEmpty = true ;
}else{
if(value instanceof String){
isEmpty = StringUtil.isEmpty((String) value) ;
}else if(value instanceof Collection){
isEmpty = ((Collection) value).isEmpty() ;
}else if(value.getClass().isArray()){
isEmpty = Array.getLength(value) > 0 ;
}
}
if (!isEmpty) {
Node content = node.jjtGetChild(1);
content.render(context, writer);
}
return true;
}
示例4: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer,
Node node) throws IOException, ResourceNotFoundException,
ParseErrorException, MethodInvocationException {
Node bodyNode = getBodyNode(context, node);
if (AsynchronousContain.isAsyncConext()) {
StringWriter sw = new StringWriter();
bodyNode.render(context, sw);
PipelineTask task = (PipelineTask) context
.get(PipelineTask.ATTR_KEY);
task.addJsCode(sw.toString());
} else {
writer.write("<script type=\"text/javascript\">\r\n");
bodyNode.render(context, writer);
writer.write("</script>\r\n");
}
return true;
}
示例5: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
protected Params getParams(InternalContextAdapter context, Node node) throws IOException {
final Params params = new Params();
params.setPrefix("WHERE");
params.setPrefixOverrides("AND |OR |AND\n|OR\n|AND\r|OR\r");
if (node.jjtGetNumChildren() == 1) {
final Node child = node.jjtGetChild(0);
if (child instanceof ASTBlock) {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
params.setBody(blockContent.toString().trim());
return params;
}
}
return null;
}
示例6: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
protected Params getParams(InternalContextAdapter context, Node node) throws IOException {
final Params params = new Params();
params.setPrefix("SET");
params.setSuffixOverrides(",");
if (node.jjtGetNumChildren() == 1) {
final Node child = node.jjtGetChild(0);
if (child instanceof ASTBlock) {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
params.setBody(blockContent.toString().trim());
return params;
}
}
return null;
}
示例7: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException,
ResourceNotFoundException, ParseErrorException, MethodInvocationException {
final Params params = new Params();
final int nodes = node.jjtGetNumChildren();
for (int i = 0; i < nodes; i++) {
Node child = node.jjtGetChild(i);
if (child != null) {
if (!(child instanceof ASTBlock)) {
if (i == 0) {
params.setPrefix(String.valueOf(child.value(context)));
} else if (i == 1) {
params.setPrefixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH));
} else if (i == 2) {
params.setSuffix(String.valueOf(child.value(context)));
} else if (i == 3) {
params.setSuffixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH));
} else {
break;
}
} else {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
if ("".equals(blockContent.toString().trim())) {
return null;
}
params.setBody(blockContent.toString().trim());
break;
}
}
}
return params;
}
示例8: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException {
final Params params = new Params();
final int nodes = node.jjtGetNumChildren();
for (int i = 0; i < nodes; i++) {
Node child = node.jjtGetChild(i);
if (child != null) {
if (!(child instanceof ASTBlock)) {
if (i == 0) {
params.setPrefix(String.valueOf(child.value(context)));
}
else if (i == 1) {
params.setPrefixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH));
}
else if (i == 2) {
params.setSuffix(String.valueOf(child.value(context)));
}
else if (i == 3) {
params.setSuffixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH));
}
else {
break;
}
}
else {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
params.setBody(blockContent.toString().trim());
break;
}
}
}
return params;
}