cssClass attribute with @s.textfield ignored when inputError happens
When a validation error occurs with the css_xhtml theme, the CSS class for a form input does not have the correct class attributes, if a cssClass has been supplied. Instead of class inputError joining the existing class which is specified by the cssClass form tag attribute, two separate class attributes are added to the element. Google Chrome only sees the first CSS class. AKA: Given the following struts2 freemarker snippet: @s.textfield name=port value=port key=service.port maxsize=5 cssClass=prop-port / When a validation error occurs, I end up with a form input element like: input type=text name=port class=inputError value= class=prop-port/ I would expect one single class attribute containing both class values separated by a space, like class=prop-port inputError I'm using Struts 2.2.1. I do see code meant to handle this in simple/css.ftl, but I'm not sure why that isn't being used. Instead, I seem to be getting the code from simple/text.ftl, which blindly adds a class attribute without checking about errors. Does anyone have any suggestions? -Roland
Re: cssClass attribute with @s.textfield ignored when inputError happens
I read the source code of [simple/css.ftl], it looks like trying to combine [cssClass] and [cssErrorClass]. So you can try: @s.textfield name=port value=port key=service.port maxsize=5 cssClass=prop-port cssErrorClass=inputError / see if the result is what you want? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: cssClass attribute with @s.textfield ignored when inputError happens
I did try that -- but unless simple/text.ftl changes, there will *still* be an unwanted class='inputError' before my cssClass and cssErrorClass attributes are handled by css.ftl. Your example produces the following broken tag: input name=port value= maxsize=5 class=inputError class=prop-port inputError / It's closer -- but I believe that a change needs to be made in the simple/text.ftl template to check for existence of the cssClass attribute, or determine if it's being called from the css_xhtml theme's text.ftl, in which case it could decide not to handle adding the inputError error class (because it would know that css.ftl handled the situation). I plan on extending css_xhtml myself to deal with this problem, but was hoping to verify this issue with someone else, and get it on the dev team's radar if it's a real problem. On Dec 13, 2010, at 6:32 PM, Li Ying - liying.cn.2...@gmail.com wrote: I read the source code of [simple/css.ftl], it looks like trying to combine [cssClass] and [cssErrorClass]. So you can try: @s.textfield name=port value=port key=service.port maxsize=5 cssClass=prop-port cssErrorClass=inputError / see if the result is what you want? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: cssClass attribute with @s.textfield ignored when inputError happens
I read the source of [simple/text.ftl], and found nothing looks like rendering the extra [class=inputError] attribute. Can you tell me where it is? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org