You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2006/06/07 21:47:16 UTC

[jira] Commented: (STR-2884) Javascript focus script fails when is present and the 'id' property is set on the form

    [ http://issues.apache.org/struts/browse/STR-2884?page=comments#action_37451 ] 

Niall Pemberton commented on STR-2884:
--------------------------------------

I've had a look into this and there is a difference in behaviour between Struts 1.2.9 and the current Struts 1.3.x. Struts 1.3.x has been changed to throw an exception if the styleId is specified in XHTML mode.

The reason for this is that in XHTML mode the form's "id" is used to determine the generated javascript method name by Commons Validator's validation methods - for example if you have a form named "fooForm" - Struts generates a fooForm_required() method - which commons validator's validateRequired(form) method looks for based on the form's "id". If we set an arbitary id, using the styleId property - then these valdiators won't work.

Unless the above is resolved, the only change (IMO) we should make is to port the change back to 1.2.x to throw an exception if styleId is specified in XHTML mode. However the answer to you remains the same - don't use the styleId attribute with XHTML.

I think we should close this as WONTFIX

> Javascript focus script fails when <html:xhtml/> is present and the 'id' property is set on the form
> ----------------------------------------------------------------------------------------------------
>
>          Key: STR-2884
>          URL: http://issues.apache.org/struts/browse/STR-2884
>      Project: Struts Action 1
>         Type: Bug

>   Components: Taglibs
>     Versions: 1.2 Family
>     Reporter: Frank Premereur
>     Priority: Minor

>
> The javascript for putting focus on a field still does not work in combination with xhtml, when providing the 'styleId' attribute. A previous bugfix, in response to bug id 35127, changed the behaviour such that the form is now rendered with the formname as value for id attribute, if no id attribute is set on the struts:form tag. The focus javascript still refers to the beanName, where it should refer to the value of 'styleId' attribute if this has been set. 
> This patch works for me:
> --- FormTag.java.orig   2006-03-09 14:32:28.000000000 +0100
> +++ FormTag.java        2006-06-07 11:30:56.104082800 +0200
> @@ -663,7 +663,12 @@
>          // Construct the control name that will receive focus.
>          // This does not include any index.
>          StringBuffer focusControl = new StringBuffer("document.forms[\"");
> -        focusControl.append(beanName);
> +        if (this.isXhtml() && getStyleId() != null) {
> +            focusControl.append(getStyleId());
> +        } else {
> +            focusControl.append(beanName);
> +        }
> +
>          focusControl.append("\"].elements[\"");
>          focusControl.append(this.focus);
>          focusControl.append("\"]");

-- 
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