You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by mo...@apache.org on 2001/02/09 02:09:24 UTC
cvs commit: jakarta-taglibs/jdbc/src/org/apache/taglibs/jdbc/resultset GetColumnTag.java
morgand 01/02/08 17:09:24
Modified: jdbc/src/org/apache/taglibs/jdbc/resultset GetColumnTag.java
Log:
added support for the colName attribute
Revision Changes Path
1.2 +16 -11 jakarta-taglibs/jdbc/src/org/apache/taglibs/jdbc/resultset/GetColumnTag.java
Index: GetColumnTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/jdbc/src/org/apache/taglibs/jdbc/resultset/GetColumnTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GetColumnTag.java 2001/01/31 00:58:08 1.1
+++ GetColumnTag.java 2001/02/09 01:09:23 1.2
@@ -70,11 +70,7 @@
import javax.servlet.jsp.JspTagException;
/**
- * <p>Gets the value, as a String, of a coulmn in the enclosing
- * resultset. The column number is set via the "position" attribute.
- * You can optionally set the value, as a String, to a serlvet attribute
- * instead of the tag body with the "to" attribute. The scope of the servlet
- * attribute is specified by the "scope" XML attribute (default = page).</p>
+ * <p>Get the value of a database column as a String.</p>
*
* <p>JSP Tag Lib Descriptor
* <pre>
@@ -82,13 +78,20 @@
* <tagclass>org.apache.taglibs.jdbc.resultset.GetStringTag</tagclass>
* <bodycontent>empty</bodycontent>
* <info>Gets the value, as a String, of a coulmn in the enclosing
- * resultset. The column number is set via the "position" attribute.
+ * resultset. Either set the column number via the "position" attribute,
+ * or set the column name with the "colName" attribute.
* You can optionally set the value, as a String, to a serlvet attribute
* instead of the tag body with the "to" attribute. The scope of the servlet
- * attribute is specified by the "scope" XML attribute (default = page).</info>
+ * attribute is specified by the "scope" XML attribute (default = page). Dates,
+ * times, timestamps and numbers are output according to the JVM's defaults.</info>
* <attribute>
* <name>position</name>
- * <required>true</required>
+ * <required>false</required>
+ * <rtexprvalue>false</rtexprvalue>
+ * </attribute>
+ * <attribute>
+ * <name>colName</name>
+ * <required>false</required>
* <rtexprvalue>false</rtexprvalue>
* </attribute>
* <attribute>
@@ -110,16 +113,18 @@
public int doStartTag() throws JspTagException {
try {
+ int position = getPosition();
+
ResultSet rset = getResultSet();
// some complex datatypes, such as clobs,
// require special handling
ResultSetMetaData meta = getMetaData();
String string = null;
- switch (meta.getColumnType(_position)) {
+ switch (meta.getColumnType(position)) {
case (Types.CLOB):
try {
- string = readClob(rset.getClob(_position));
+ string = readClob(rset.getClob(position));
} catch (IOException e) {
throw new JspTagException(e.toString());
} catch (SQLException e) {
@@ -127,7 +132,7 @@
}
break;
default:
- string = rset.getString(_position);
+ string = rset.getString(position);
}
// null results are often OK, in outer joins for example