本文整理汇总了Java中org.apache.jasper.compiler.tagplugin.TagPluginContext.generateJavaSource方法的典型用法代码示例。如果您正苦于以下问题:Java TagPluginContext.generateJavaSource方法的具体用法?Java TagPluginContext.generateJavaSource怎么用?Java TagPluginContext.generateJavaSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jasper.compiler.tagplugin.TagPluginContext
的用法示例。
在下文中一共展示了TagPluginContext.generateJavaSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
String condV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("boolean " + condV + "=");
ctxt.generateAttribute("test");
ctxt.generateJavaSource(";");
if (ctxt.isAttributeSpecified("var")) {
String scope = "PageContext.PAGE_SCOPE";
if (ctxt.isAttributeSpecified("scope")) {
String scopeStr = ctxt.getConstantAttribute("scope");
if ("request".equals(scopeStr)) {
scope = "PageContext.REQUEST_SCOPE";
} else if ("session".equals(scopeStr)) {
scope = "PageContext.SESSION_SCOPE";
} else if ("application".equals(scopeStr)) {
scope = "PageContext.APPLICATION_SCOPE";
}
}
ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
ctxt.generateAttribute("var");
ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");");
}
ctxt.generateJavaSource("if (" + condV + "){");
ctxt.generateBody();
ctxt.generateJavaSource("}");
}
示例2: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
//scope flag
boolean hasScope = ctxt.isAttributeSpecified("scope");
//the value of the "var"
String strVar = ctxt.getConstantAttribute("var");
//remove attribute from certain scope.
//default scope is "page".
if(hasScope){
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
}else{
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
}
}
示例3: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Get the parent context to determine if this is the first <c:when>
TagPluginContext parentContext = ctxt.getParentContext();
if (parentContext == null) {
ctxt.dontUseTagPlugin();
return;
}
if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
ctxt.generateJavaSource("} else if(");
// See comment below for the reason we generate the extra "}" here.
} else {
ctxt.generateJavaSource("if(");
parentContext.setPluginAttribute("hasBeenHere", "true");
}
ctxt.generateAttribute("test");
ctxt.generateJavaSource("){");
ctxt.generateBody();
// We don't generate the closing "}" for the "if" here because there
// may be whitespaces in between <c:when>'s. Instead we delay
// generating it until the next <c:when> or <c:otherwise> or
// <c:choose>
}
示例4: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
String condV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("boolean " + condV + "=");
ctxt.generateAttribute("test");
ctxt.generateJavaSource(";");
if (ctxt.isAttributeSpecified("var")) {
String scope = "PageContext.PAGE_SCOPE";
if (ctxt.isAttributeSpecified("scope")) {
String scopeStr = ctxt.getConstantAttribute("scope");
if ("request".equals(scopeStr)) {
scope = "PageContext.REQUEST_SCOPE";
} else if ("session".equals(scopeStr)) {
scope = "PageContext.SESSION_SCOPE";
} else if ("application".equals(scopeStr)) {
scope = "PageContext.APPLICATION_SCOPE";
}
}
ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
ctxt.generateAttribute("var");
ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");");
}
ctxt.generateJavaSource("if (" + condV + "){");
ctxt.generateBody();
ctxt.generateJavaSource("}");
}
示例5: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
public void doTag(TagPluginContext ctxt) {
//scope flag
boolean hasScope = ctxt.isAttributeSpecified("scope");
//the value of the "var"
String strVar = ctxt.getConstantAttribute("var");
//remove attribute from certain scope.
//default scope is "page".
if(hasScope){
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
}else{
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
}
}
示例6: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
//scope flag
boolean hasScope = ctxt.isAttributeSpecified("scope");
//the value of the "var"
String strVar = ctxt.getConstantAttribute("var");
//remove attribute from certain scope.
//default scope is "page".
if(hasScope){
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
}else{
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
}
}
示例7: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Get the parent context to determine if this is the first <c:when>
TagPluginContext parentContext = ctxt.getParentContext();
if (parentContext == null) {
ctxt.dontUseTagPlugin();
return;
}
if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
ctxt.generateJavaSource("} else if(");
// See comment below for the reason we generate the extra "}" here.
}
else {
ctxt.generateJavaSource("if(");
parentContext.setPluginAttribute("hasBeenHere", "true");
}
ctxt.generateAttribute("test");
ctxt.generateJavaSource("){");
ctxt.generateBody();
// We don't generate the closing "}" for the "if" here because there
// may be whitespaces in between <c:when>'s. Instead we delay
// generating it until the next <c:when> or <c:otherwise> or
// <c:choose>
}
示例8: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Get the parent context to determine if this is the first <c:when>
TagPluginContext parentContext = ctxt.getParentContext();
if (parentContext == null) {
ctxt.dontUseTagPlugin();
return;
}
if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
ctxt.generateJavaSource("} else if(");
// See comment below for the reason we generate the extra "}" here.
}
else {
ctxt.generateJavaSource("if(");
parentContext.setPluginAttribute("hasBeenHere", "true");
}
ctxt.generateAttribute("test");
ctxt.generateJavaSource("){");
ctxt.generateBody();
// We don't generate the closing "}" for the "if" here because there
// may be whitespaces in between <c:when>'s. Instead we delay
// generating it until the next <c:when> or <c:otherwise> or
// <c:choose>
}
示例9: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Not much to do here, much of the work will be done in the
// containing tags, <c:when> and <c:otherwise>.
ctxt.generateBody();
// See comments in When.java for the reason "}" is generated here.
ctxt.generateJavaSource("}");
}
示例10: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Not much to do here, much of the work will be done in the
// containing tags, <c:when> and <c:otherwise>.
ctxt.generateBody();
// See comments in When.java for the reason "}" is generated here.
ctxt.generateJavaSource("}");
}
示例11: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// See When.java for the reason whey "}" is need at the beginng and
// not at the end.
ctxt.generateJavaSource("} else {");
ctxt.generateBody();
}
示例12: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// See When.java for the reason whey "}" is need at the beginng and
// not at the end.
ctxt.generateJavaSource("} else {");
ctxt.generateBody();
}
示例13: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
// Not much to do here, much of the work will be done in the
// containing tags, <c:when> and <c:otherwise>.
ctxt.generateBody();
// See comments in When.java for the reason "}" is generated here.
ctxt.generateJavaSource("}");
}
示例14: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
String index = null;
boolean hasVarStatus = ctxt.isAttributeSpecified("varStatus");
if (hasVarStatus) {
ctxt.dontUseTagPlugin();
return;
}
hasVar = ctxt.isAttributeSpecified("var");
hasBegin = ctxt.isAttributeSpecified("begin");
hasEnd = ctxt.isAttributeSpecified("end");
hasStep = ctxt.isAttributeSpecified("step");
boolean hasItems = ctxt.isAttributeSpecified("items");
if (hasItems) {
doCollection(ctxt);
return;
}
// We must have a begin and end attributes
index = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("for (int " + index + " = ");
ctxt.generateAttribute("begin");
ctxt.generateJavaSource("; " + index + " <= ");
ctxt.generateAttribute("end");
if (hasStep) {
ctxt.generateJavaSource("; " + index + "+=");
ctxt.generateAttribute("step");
ctxt.generateJavaSource(") {");
} else {
ctxt.generateJavaSource("; " + index + "++) {");
}
// If var is specified and the body contains an EL, then sycn
// the var attribute
if (hasVar /* && ctxt.hasEL() */) {
ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
ctxt.generateAttribute("var");
ctxt.generateJavaSource(", String.valueOf(" + index + "));");
}
ctxt.generateBody();
ctxt.generateJavaSource("}");
}
示例15: doTag
import org.apache.jasper.compiler.tagplugin.TagPluginContext; //导入方法依赖的package包/类
@Override
public void doTag(TagPluginContext ctxt) {
//don't support the body content
//define names of all the temp variables
String nameName = ctxt.getTemporaryVariableName();
String valueName = ctxt.getTemporaryVariableName();
String urlName = ctxt.getTemporaryVariableName();
String encName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
//if the param tag has no parents, throw a exception
TagPluginContext parent = ctxt.getParentContext();
if(parent == null){
ctxt.generateJavaSource(" throw new JspTagExcption" +
"(\"<param> outside <import> or <urlEncode>\");");
return;
}
//get the url string before adding this param
ctxt.generateJavaSource("String " + urlName + " = " +
"(String)pageContext.getAttribute(\"url_without_param\");");
//get the value of "name"
ctxt.generateJavaSource("String " + nameName + " = ");
ctxt.generateAttribute("name");
ctxt.generateJavaSource(";");
//if the "name" is null then do nothing.
//else add such string "name=value" to the url.
//and the url should be encoded
ctxt.generateJavaSource("if(" + nameName + " != null && !" + nameName + ".equals(\"\")){");
ctxt.generateJavaSource(" String " + valueName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
ctxt.generateJavaSource(" if(" + valueName + " == null) " + valueName + " = \"\";");
ctxt.generateJavaSource(" String " + encName + " = pageContext.getResponse().getCharacterEncoding();");
ctxt.generateJavaSource(" " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");");
ctxt.generateJavaSource(" " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");");
ctxt.generateJavaSource(" int " + index + ";");
ctxt.generateJavaSource(" " + index + " = " + urlName + ".indexOf(\'?\');");
//if the current param is the first one, add a "?" ahead of it
//else add a "&" ahead of it
ctxt.generateJavaSource(" if(" + index + " == -1){");
ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
ctxt.generateJavaSource("}");
}