HTML5 placeholder inside Struts html:text tag
Asked Answered
R

2

5

I'm using Struts 1.3.10 in a web application, and I want my textfields to have a placeholder. Unfortunately, the current Struts taglib doesn't recognize this attribute, and I would like to avoid using javascript for this if possible. Do you know any solution for this?

Ribald answered 18/2, 2012 at 1:17 Comment(0)
I
2

Struts 1 is dead. It hasn't had a release since 2008. I would really think about migrating to a more modern framework.

If you're stuck with Struts 1, you could

  • edit the sources yourself, and add a placeholder attribute to the tag.
  • avoid using the tag, and go back to basic HTML + JSTL + EL :

    <input type="text" name="foo" value="<c:out value='${myForm.foo}' />" 
           placeholder="Enter foo here" />
    
Icehouse answered 6/8, 2012 at 11:51 Comment(2)
Yes, I know it's an old, crappy framework, but for now we're kinda stuck :(Avera
I ended up using your second suggestion, although that screws up validations using the validation pluginAvera
K
0

In case this might be helpful to others:

If you have a JavaBean (with getters and setters) you could use basic html and the bean:write struts tag.

<input type="text" name="foo" placeholder="Enter foo here"value="<bean:write name="myFormBean" property="foo" />"> 
Keenan answered 10/10, 2014 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.