00001
package com.quadcap.http.servlets.jsp;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
import java.io.PrintWriter;
00042
00043
import java.util.Hashtable;
00044
00045
import org.xml.sax.AttributeList;
00046
00047
import com.quadcap.util.Debug;
00048
00049
00050
00051
00052
00053
00054
00055 public class TagJspSetProperty extends TagJsp {
00056 public TagJspSetProperty() {}
00057
00058 public TagJspSetProperty(
TagContext context) {
00059 super(context);
00060 }
00061
00062 public TagInstance makeInstance(
TagContext context) {
00063
return new TagJspSetProperty(context);
00064 }
00065
00067
throws JspException
00068 {
00069 super.doStartTag(tagName, attributes);
00070 context.
addPageDirective(
"import",
00071
"com.quadcap.http.servlets.jsp.PropertyUtils");
00072
00073 PrintWriter w = context.
getPrintWriter();
00074 String name = attributes.getValue(
"name");
00075 String prop = attributes.getValue(
"property");
00076
if (prop.equals(
"*")) {
00077 w.print(
" PropertyUtils.");
00078 w.print(
"setPropertiesFromRequest(");
00079 w.print(name);
00080 w.println(
", request);");
00081
return;
00082 }
00083
00084 String param = attributes.getValue(
"param");
00085
if (param != null) {
00086 w.print(
" PropertyUtils.");
00087 w.print(
"setPropertyFromRequestParameter(");
00088 w.print(name);
00089 w.print(
", request, \"");
00090 w.print(param);
00091 w.println(
"\");");
00092
return;
00093 }
00094
00095 String value = attributes.getValue(
"value").trim();
00096
if (value != null) {
00097
if (value.startsWith(
"<%=") && value.endsWith(
"%>")) {
00098 value = value.substring(3);
00099 value = value.substring(value.length() - 2).trim();
00100 }
else {
00101 value =
"\"" + value +
"\"";
00102 }
00103 w.print(
" PropertyUtils.");
00104 w.print(
"setPropertyFromValue(");
00105 w.print(name);
00106 w.print(
", String.valueOf(");
00107 w.print(value);
00108 w.println(
"));");
00109
return;
00110 }
00111
00112
throw new JspException(
"Bad jsp:setProperty tag");
00113 }
00114 }
00115