You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Rush <mi...@gmail.com> on 2006/08/02 00:54:34 UTC

html:form / styleId in xhtml mode

I was just looking into upgrading my app from 1.2.9 to 1.3.4 and have  
run into a snag:

2006-08-01 15:33:49,911 (ERROR) InsertTag.doEndTag - ServletException  
in '/pages/site/entry.jsp': Cannot specify "styleId" when in XHTML  
mode as the HTML "id" attribute is already used to store the bean name
javax.servlet.ServletException: Cannot specify "styleId" when in  
XHTML mode as the HTML "id" attribute is already used to store the  
bean name

FormTag dictates that the styleId attribute cannot be set in the  
html:form tag when using xhtml mode:

    protected void renderName(StringBuffer results)
             throws JspException {
         if (this.isXhtml()) {
             if (getStyleId() == null) {
                 renderAttribute(results, "id", beanName);
             } else {
                 throw new JspException(messages.getMessage 
("formTag.ignoredId"));
             }
         } else {
             renderAttribute(results, "name", beanName);
             renderAttribute(results, "id", getStyleId());
         }
     }

The question is, why?

Couldn't it just as easily be done as the following?

         if (this.isXhtml()) {
             if (getStyleId() == null) {
                 renderAttribute(results, "id", beanName);
             } else {
                 renderAttribute(results, "id", getStyleId());
             }
         }

We're using quite a bit of AJAX in our application and referring to  
document elements by id quite regularly, not to mention that  
stylesheets reference specific ids as well (i.e. all of our forms  
have a styleId attribute). Going through and renaming all of the ids  
of the forms doesn't seem very attractive. Can someone verify that  
it's necessary?

Thanks,
Michael



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:form / styleId in xhtml mode

Posted by Laurie Harper <la...@holoweb.net>.
I suspect this restriction is there to support the validator. XHTML 
mandates the use of 'id' in place of 'name' in various situations.

That said, you can still predict what the 'id' value will be; in this 
case, it will take the name of the FormBean associated with the form. So 
your AJAX calls could just use that name to reference the form.

L.

Michael Rush wrote:
> I was just looking into upgrading my app from 1.2.9 to 1.3.4 and have 
> run into a snag:
> 
> 2006-08-01 15:33:49,911 (ERROR) InsertTag.doEndTag - ServletException in 
> '/pages/site/entry.jsp': Cannot specify "styleId" when in XHTML mode as 
> the HTML "id" attribute is already used to store the bean name
> javax.servlet.ServletException: Cannot specify "styleId" when in XHTML 
> mode as the HTML "id" attribute is already used to store the bean name
> 
> FormTag dictates that the styleId attribute cannot be set in the 
> html:form tag when using xhtml mode:
> 
>    protected void renderName(StringBuffer results)
>             throws JspException {
>         if (this.isXhtml()) {
>             if (getStyleId() == null) {
>                 renderAttribute(results, "id", beanName);
>             } else {
>                 throw new 
> JspException(messages.getMessage("formTag.ignoredId"));
>             }
>         } else {
>             renderAttribute(results, "name", beanName);
>             renderAttribute(results, "id", getStyleId());
>         }
>     }
> 
> The question is, why?
> 
> Couldn't it just as easily be done as the following?
> 
>         if (this.isXhtml()) {
>             if (getStyleId() == null) {
>                 renderAttribute(results, "id", beanName);
>             } else {
>                 renderAttribute(results, "id", getStyleId());
>             }
>         }
> 
> We're using quite a bit of AJAX in our application and referring to 
> document elements by id quite regularly, not to mention that stylesheets 
> reference specific ids as well (i.e. all of our forms have a styleId 
> attribute). Going through and renaming all of the ids of the forms 
> doesn't seem very attractive. Can someone verify that it's necessary?
> 
> Thanks,
> Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org