[cvs] expresso commit by mtraum: xhtml support for struts extended
tags (Mark
JCorporate Ltd
jcorp at jcorporate.com
Thu Apr 28 13:08:41 UTC 2005
Log Message:
-----------
xhtml support for struts extended tags (Mark Kikken, Mike Traum)
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html:
ExCheckboxTag.java
ExButtonTag.java
ExRadioTag.java
ExHtmlTag.java
ExSubmitTag.java
ExLinkTag.java
ExImageTag.java
ExBaseFieldTag.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib:
ButtonParams.java
expresso/expresso-web/expresso/doc:
ChangeLog.xml
Added Files:
-----------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html:
ExTagUtils.java
Revision Data
-------------
Index: ExSubmitTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExSubmitTag.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExSubmitTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExSubmitTag.java -u -r1.13 -r1.14
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExSubmitTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExSubmitTag.java
@@ -138,7 +138,7 @@
// Render this element to our writer
TagUtils.getInstance().write(pageContext,
- myTransition.getHTMLParamString() + "\n");
+ ExTagUtils.getHTMLParamString(myTransition, getElementClose()) + "\n");
}
this.text = null;
@@ -218,7 +218,7 @@
results.append(prepareEventHandlers());
results.append(prepareStyles());
- results.append(">");
+ results.append(getElementClose());
// Render this element to our writer
TagUtils.getInstance().write(pageContext, results.toString());
Index: ExLinkTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExLinkTag.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExLinkTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExLinkTag.java -u -r1.12 -r1.13
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExLinkTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExLinkTag.java
@@ -148,7 +148,7 @@
}
results.append(prepareStyles());
results.append(prepareEventHandlers());
- results.append(">");
+ results.append(getElementClose());
if (!StringUtil.notNull(label).equals("")) {
results.append(label);
}
Index: ExHtmlTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExHtmlTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExHtmlTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExHtmlTag.java -u -r1.9 -r1.10
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExHtmlTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExHtmlTag.java
@@ -67,9 +67,11 @@
import java.util.Locale;
import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
+import org.apache.struts.Globals;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.taglib.html.HtmlTag;
@@ -87,7 +89,12 @@
*/
public class ExHtmlTag
extends HtmlTag {
+
+ protected boolean xhtmlMime = false;
+
// --------------------------------------------------------- Public Methods
+
+
/**
* Process the start of this tag.
*
@@ -121,11 +128,23 @@
charset = "ISO-8859-1";
}
+ // Set the contentType
ServletResponse res = pageContext.getResponse();
- res.setContentType("text/html;charset=" + charset);
+
+ HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
+ if ((req instanceof HttpServletRequest) && (xhtmlMime) && (req.getHeader("accept").indexOf("application/xhtml+xml") != -1)) {
+ res.setContentType("application/xhtml+xml;charset=" + charset);
+ } else {
+ res.setContentType("text/html;charset=" + charset);
+ }
StringBuffer sb = new StringBuffer("<html");
+ if (this.xhtml) {
+ this.pageContext.setAttribute(Globals.XHTML_KEY, "true", PageContext.PAGE_SCOPE);
+ sb.append(" xmlns=\"http://www.w3.org/1999/xhtml\"");
+ }
+
// Use the current Locale to set our language preferences
Locale currentLocale = l;
@@ -146,8 +165,14 @@
}
sb.append(">");
- sb.append("\n<meta http-equiv=\"Content-Type\" content=\"text/" +
- "html;charset=" + charset + "\">");
+
+ if (xhtml) {
+ sb.append("\n<meta http-equiv=\"Content-Type\" content=\"text/" +
+ "html;charset=" + charset + "\" />");
+ } else {
+ sb.append("\n<meta http-equiv=\"Content-Type\" content=\"text/" +
+ "html;charset=" + charset + "\">");
+ }
// Write out the beginning tag for this page
TagUtils.getInstance().write(pageContext, sb.toString());
@@ -155,4 +180,16 @@
// Evaluate the included content of this tag
return (EVAL_BODY_INCLUDE);
}
+ /**
+ * @return Returns the xhtmlMime.
+ */
+ public boolean setXhtmlMime() {
+ return xhtmlMime;
+ }
+ /**
+ * @param xhtmlMime The xhtmlMime to set.
+ */
+ public void setXhtmlMime(boolean xhtmlMime) {
+ this.xhtmlMime = xhtmlMime;
+ }
}
Index: ExButtonTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExButtonTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExButtonTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExButtonTag.java -u -r1.10 -r1.11
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExButtonTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExButtonTag.java
@@ -133,7 +133,7 @@
// Render this element to our writer
TagUtils.getInstance().write(pageContext,
- myTransition.getHTMLParamString() + "\n");
+ ExTagUtils.getHTMLParamString(myTransition, getElementClose()) + "\n");
}
this.text = null;
Index: ExCheckboxTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExCheckboxTag.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExCheckboxTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExCheckboxTag.java -u -r1.15 -r1.16
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExCheckboxTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExCheckboxTag.java
@@ -155,7 +155,7 @@
results.append(prepareEventHandlers());
results.append(prepareStyles());
- results.append(">");
+ results.append(getElementClose());
// Print this field to our output writer
TagUtils.getInstance().write(pageContext, results.toString());
Index: ExBaseFieldTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExBaseFieldTag.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExBaseFieldTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExBaseFieldTag.java -u -r1.15 -r1.16
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExBaseFieldTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExBaseFieldTag.java
@@ -193,7 +193,7 @@
results.append("\"");
results.append(prepareEventHandlers());
results.append(prepareStyles());
- results.append(">");
+ results.append(getElementClose());
// Print this field to our output writer
TagUtils.getInstance().write(pageContext, results.toString());
Index: ExImageTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExImageTag.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExImageTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExImageTag.java -u -r1.13 -r1.14
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExImageTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExImageTag.java
@@ -136,7 +136,7 @@
// Render this element to our writer
TagUtils.getInstance().write(pageContext,
- myTransition.getHTMLParamString() + "\n");
+ ExTagUtils.getHTMLParamString(myTransition, getElementClose()) + "\n");
}
this.text = null;
@@ -209,7 +209,7 @@
results.append(prepareEventHandlers());
results.append(prepareStyles());
- results.append(">");
+ results.append(getElementClose());
// Render this element to our writer
TagUtils.getInstance().write(pageContext, results.toString());
Index: ExRadioTag.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExRadioTag.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExRadioTag.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExRadioTag.java -u -r1.10 -r1.11
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExRadioTag.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExRadioTag.java
@@ -144,7 +144,7 @@
}
results.append(prepareEventHandlers());
results.append(prepareStyles());
- results.append(">");
+ results.append(getElementClose());
// Print this field to our output writer
TagUtils.getInstance().write(pageContext, results.toString());
--- /dev/null
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/struts/taglib/html/ExTagUtils.java
@@ -0,0 +1,118 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.struts.taglib.html;
+
+import com.jcorporate.expresso.core.controller.Transition;
+import com.jcorporate.expresso.core.misc.URLUTF8Encoder;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+
+/**
+ * Utilities related to the html extended struts tags
+ *
+ */
+public final class ExTagUtils {
+
+ /**
+ * Returns a hidden form field string that is safe in either the GET or POST
+ * case.
+ *
+ * @param transition the Transition to retrieve the parameters from
+ * @param closingElement the string to use to close the html statement
+ *
+ * @return java.lang.String
+ */
+ public static String getHTMLParamString(Transition transition, String closingElement) {
+ String paramString = transition.getParamString();
+ paramString = URLUTF8Encoder.encode(paramString);
+
+ //
+ //Guess at a memory allocation to reduce re-allocation/copy
+ //Alloc Adjust was guessed at based upon watching string lengths and
+ //guessing a reasonable maximum size that would fit most applciations.
+ //
+
+ FastStringBuffer sb = FastStringBuffer.getInstance();
+ String returnValue = null;
+ try {
+ sb.append("<input type=\"HIDDEN\" name=\"");
+ sb.append(transition.getName());
+ sb.append("_params");
+ sb.append("\" value=\"");
+ sb.append(paramString);
+ sb.append("\"");
+ sb.append(closingElement);
+ sb.append("<input type=\"HIDDEN\" name=\"");
+ sb.append(transition.getName());
+ sb.append("_encoding");
+ sb.append("\" value=\"u\"");
+ sb.append(closingElement);
+ returnValue = sb.toString();
+ } finally {
+ sb.release();
+ sb = null;
+ }
+ return returnValue;
+ } /* getHTMLParamStriong() */
+}
Index: ButtonParams.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib/ButtonParams.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib/ButtonParams.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib/ButtonParams.java -u -r1.6 -r1.7
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib/ButtonParams.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/services/taglib/ButtonParams.java
@@ -147,10 +147,10 @@
fsb.append(result.getName());
fsb.append("_params\" value=\"");
fsb.append(URLUTF8Encoder.encode(result.getParamString(true)));
- fsb.append("\">\n");
+ fsb.append("\" />\n");
fsb.append("<input type=hidden name=\"");
fsb.append(result.getName());
- fsb.append("_encoding\" value=\"u\">");
+ fsb.append("_encoding\" value=\"u\" />");
} finally {
writeValue = fsb.toString();
fsb.release();
Index: ChangeLog.xml
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/ChangeLog.xml,v
retrieving revision 1.304
retrieving revision 1.305
diff -Lexpresso-web/expresso/doc/ChangeLog.xml -Lexpresso-web/expresso/doc/ChangeLog.xml -u -r1.304 -r1.305
--- expresso-web/expresso/doc/ChangeLog.xml
+++ expresso-web/expresso/doc/ChangeLog.xml
@@ -6,6 +6,12 @@
<project name="Expresso">
<version name="5.6.1" releaseDate="Not released yet">
<comment>Continued Updates</comment>
+ <new-feature title="Struts extended tags now support xhtml">
+ <explanation>The struts extended tags now support xhtml in the same way is is supported under struts, through the use
+ of <html:html xhtml="true">.
+ </explanation>
+ <contributor>Mark Kikken, Mike Traum</contributor>
+ </new-feature>
<new-feature title="DBTool now has the ability to add a schema">
<explanation>DBTool is a command line tool to create database tables and populate values based on a schema. Prior to this addition, it
would only do this for ExpressoSchema unless a schema record was manually entered into the database. Now, DBTool is a one stop solution
More information about the cvs
mailing list