struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STR-2859) When using <html:html xhtml="true"> the form name is not used but the id, and the client validation using javascript fails
Date Tue, 09 May 2006 09:35:42 GMT
    [ http://issues.apache.org/struts/browse/STR-2859?page=comments#action_37333 ] 

Niall Pemberton commented on STR-2859:
--------------------------------------

This issue was fixed by a combination of the changes in Struts 1.2.8 and Validator 1.2.0 -
however both Struts 1.2.8 and Struts 1.2.9 were shipped with Validator 1.1.4 and so resolving
the issue does require upgrading to a later version of Commons Validator as you have done.
This was/is indicated on the Struts 1.2.8 upgrade notes on the wiki:
http://wiki.apache.org/struts/StrutsUpgradeNotes127to128

Also the Struts 1.2.9 upgrade notes on the wiki also highlight that it ships with 1.1.4 and
suggest upgrading to a later version of Validator for bug fixes:
http://wiki.apache.org/struts/StrutsUpgradeNotes128to129

There are a couple of reasons why Struts 1.2.8/1.2.9 shipped with Validator 1.1.4 rather than
the latest Validator version:

1) Both of these Struts releases were maintenance releases primarily to fix security issues
so sticking with the more stable/widely used Validator 1.1.4 seemed like a good idea - rather
than the (at the time) brand new Validator 1.2.0/1.3.0 versions. In the case of Struts 1.2.8,
which could have shipped with Validator 1.2.0, this IMO has proved to be a good decision since
there were a number of bugs introduced in 1.2.0 (now fixed in Validator 1.3.0).

2) Struts 1.2.x has not been modified to support all the features in Validator 1.2.0 (i.e.
Variables in Resource Bundles - see http://wiki.apache.org/jakarta-commons/ValidatorVersion120)
- this doesn't necessarily mean it shouldn't be changed to use the latest Validator version,
but it would IMO create confusion when people try to use this feature and find it doesn't
work in Struts (prior to Struts 1.3.x).

> When using <html:html xhtml="true"> the form name is not used but the id, and the
client validation using javascript fails
> --------------------------------------------------------------------------------------------------------------------------
>
>          Key: STR-2859
>          URL: http://issues.apache.org/struts/browse/STR-2859
>      Project: Struts Action 1
>         Type: Bug

>   Components: Taglibs
>     Versions: 1.2.8
>  Environment: Linux Fedora 5
> Tomcat 5.5 and JBoss 4.0.3
> Struts 1.2.8
>     Reporter: Manuel Valladares

>
> When we use client javascript validation we have a problem when we try to set the strict
xhtml format in the <html:html> tag.
> For example, in the following jsp code:
> <%@ page contentType="text/html; charset=utf-8" language="java" %>
> <%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
> <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
> <%@ taglib uri="/tags/struts-html" prefix="html" %>
> <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
> <%@ taglib uri="/tags/c" prefix="c" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html:html xhtml="true" locale="true">
> <html:errors/>
> <html:javascript formName="TmpForm"/>
> <head>
> </head>
> <html:form action="/Tmp.do" method="get" onsubmit="return validateTmpForm (this)">
> <html:text property="aparam"/>
> <html:submit/>
> <html:cancel/>
> </html:form>
> </html:html>
> The generated code for the form is:
> <form id="TmpForm" method="get" action="/MRE/Tmp.do;jsessionid=50AB02D65B89E98624364A26680EF831"
onsubmit="return validateTmpForm (this)">
> As you see, it doesn't have a "name" property but a "id".
> And the validation javascript function created is:
>    function validate....(form) {
>         var isValid = true;
>         var focusField = null;
>         var i = 0;
>         var fields = new Array();
>         var formName = form.getAttributeNode("name"); 
>         oRange = eval('new ' + formName.value + '_floatRange()');
>         [...........]
>         return isValid;
>     }
> But the form doesn't have a "name" property. And the javascript fails.
> If you change the generated javascript code looking for "id" instead of "name" everything
should work fine.
> For example, you could produce a code like:
>    function validate....(form) {
>         var isValid = true;
>         var focusField = null;
>         var i = 0;
>         var fields = new Array();
>         var formName = form.getAttributeNode("name") ? form.getAttributeNode("name")
: form.getAttributeNode("id");
>              
>         oRange = eval('new ' + formName.value + '_floatRange()');
>         [...........]
>         return isValid;
>     }
> Hope this helps.
>                        Manuel Valladares

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message