struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (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 Mon, 08 May 2006 15:55:33 GMT
    [ http://issues.apache.org/struts/browse/STR-2859?page=comments#action_37326 ] 

Henri Yandell commented on STR-2859:
------------------------------------

Only worry with marking this as a duplicate Don, is that the issue this duplicates says that
the issue was fixed in 1.2.8, however the reporter is using 1.2.8.

> 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