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 Shawn Bayern <ba...@essentially.net> on 2001/05/16 15:29:05 UTC
Re: [PATCH] I18N for Input tag
Thanks for bringing up this point. I didn't see the actual patch
attached; if you could forward it to the list, I'll take a look.
Best,
Shawn
On Wed, 16 May 2001, Takashi Okamoto wrote:
> Hi, there!
>
> At present, Input tag supports only iso-8859-1 encoding.
> Unfortunately, we ( Japanese,Chinese,Korean..., a lot of people who
> use other than iso-8859-1 encoding) can't use input tag.
> I attached a patch that resolve this international problem.
>
> You may write following code with text and textarea tags by this patch:
>
>
> <%@ page contentType="text/html;charset=Shift_JIS" %>
>
> <input:text name="username" default="<Your Name>" encoding="Shift_JIS" />
> <input:textare name="message" default="<Your Message>" encoding="Shift_JIS" />
>
>
> I just added encoding attribute for text and textarea tags. You can
> specify your encoding by it. And the encoding attribute is
> optional. When you remove it, input tag treate request parameter as
> iso-8859-1 encoding, and it will compatible with current version.
Re: [PATCH] I18N for Input tag
Posted by Takashi Okamoto <to...@kun.ne.jp>.
At Wed, 16 May 2001 23:51:58 +0000,
Takashi Okamoto wrote:
diff -uNr input.orig/src/org/apache/taglibs/input/Text.java input/src/org/apache/taglibs/input/Text.java
....
> if (req.getParameter(name) != null)
> - out.println(" value=\""
> - + Util.quote(req.getParameter(name)) + "\"");
> + /* decode parameter by response encoding */
> + out.println(" value=\"" + Util.quote(new String(req.getParameter(name).getBytes("iso-8859-1"), encoding)) + "\"");
...
diff -uNr input.orig/src/org/apache/taglibs/input/TextArea.java
input/src/org/apache/taglibs/input/TextArea.java
...
> if (req.getParameter(name) != null)
> - out.print(Util.quote(req.getParameter(name)));
> + /* decode parameter by response encoding */
> + out.print(Util.quote(new String(req.getParameter(name).getBytes("iso-8859-1"), encoding)));
Above two comments "/* decode parameter ...*/" are obsolete.(In the
first, I tried response encoding but quited it.)
Please remove them.
regards.
----------------------------
Takashi Okamoto
Re: [PATCH] I18N for Input tag
Posted by Takashi Okamoto <to...@kun.ne.jp>.
At Wed, 16 May 2001 09:29:05 -0400 (EDT),
Shawn Bayern wrote:
>
> Thanks for bringing up this point. I didn't see the actual patch
> attached; if you could forward it to the list, I'll take a look.
Oops, sure.
Please take following patch.
regards.
----------------------------
^^ Takashi Okamoto <to...@debian.org>
= ..= Debian Developer
-o- Key fingerprint:
8B37 1FE6 76B2 7BA6 D59A 9BF7 E7F4 46C8 5293 6E17
diff -uNr input.orig/conf/taglib.tld input/conf/taglib.tld
--- input.orig/conf/taglib.tld Wed May 16 19:27:47 2001
+++ input/conf/taglib.tld Wed May 16 19:18:04 2001
@@ -37,6 +37,11 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+ <attribute>
+ <name>encoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
</tag>
<tag>
@@ -87,6 +92,11 @@
</attribute>
<attribute>
<name>attributes</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>encoding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
diff -uNr input.orig/src/org/apache/taglibs/input/Text.java input/src/org/apache/taglibs/input/Text.java
--- input.orig/src/org/apache/taglibs/input/Text.java Wed May 16 19:27:47 2001
+++ input/src/org/apache/taglibs/input/Text.java Wed May 16 19:18:27 2001
@@ -75,6 +75,7 @@
private String name; // name of the text field
private String dVal; // default value if none is found
private Map attributes; // attributes of the <input> element
+ private String encoding = null; // character encoding
public void setName(String x) {
name = x;
@@ -88,6 +89,10 @@
dVal = x;
}
+ public void setEncoding(String enc) {
+ encoding = enc;
+ }
+
public int doStartTag() throws JspException {
try {
// sanity check
@@ -98,6 +103,10 @@
ServletRequest req = pageContext.getRequest();
JspWriter out = pageContext.getOut();
+ if (encoding==null) {
+ encoding = "iso-8859-1";
+ }
+
// start building up the tag
out.println();
out.println("<input ");
@@ -112,8 +121,8 @@
* use the default value if it's not
*/
if (req.getParameter(name) != null)
- out.println(" value=\""
- + Util.quote(req.getParameter(name)) + "\"");
+ /* decode parameter by response encoding */
+ out.println(" value=\"" + Util.quote(new String(req.getParameter(name).getBytes("iso-8859-1"), encoding)) + "\"");
else if (dVal != null)
out.println(" value=\"" + Util.quote(dVal) + "\"");
diff -uNr input.orig/src/org/apache/taglibs/input/TextArea.java input/src/org/apache/taglibs/input/TextArea.java
--- input.orig/src/org/apache/taglibs/input/TextArea.java Wed May 16 19:27:47 2001
+++ input/src/org/apache/taglibs/input/TextArea.java Wed May 16 19:18:47 2001
@@ -75,6 +75,7 @@
private String name; // name of the textarea
private String dVal; // default value if none is found
private Map attributes; // attributes of the <textarea> element
+ private String encoding = null; // character encoding
public void setName(String x) {
name = x;
@@ -88,6 +89,10 @@
dVal = x;
}
+ public void setEncoding(String enc) {
+ encoding = enc;
+ }
+
public int doStartTag() throws JspException {
try {
// sanity check
@@ -98,6 +103,10 @@
ServletRequest req = pageContext.getRequest();
JspWriter out = pageContext.getOut();
+ if (encoding==null) {
+ encoding = "iso-8859-1";
+ }
+
// start building up the tag
out.println();
out.println("<textarea ");
@@ -114,7 +123,8 @@
* use the default value if it's not
*/
if (req.getParameter(name) != null)
- out.print(Util.quote(req.getParameter(name)));
+ /* decode parameter by response encoding */
+ out.print(Util.quote(new String(req.getParameter(name).getBytes("iso-8859-1"), encoding)));
else if (dVal != null)
out.print(Util.quote(dVal));