Applying bootstrap styles to Struts 1.x html tags
Asked Answered
M

1

7

I am working on some legacy Struts 1.x applications that use Struts html tags instead of standard html tags. I am trying to modernize the UI without making functional changes.

For example: The input field is <html:text property="someProperty" styleClass="someCssStyle">

instead of <input type="text" class="someCssStyle">

If I change, <html:text> to <input type="text"> the property binding breaks i.e. the value in input field is not passed to the code.

If I try to apply bootstrap styles to <html:text>, it does not work.

How can I apply Bootstrap styles to legacy struts html tags?

Meitner answered 29/6, 2017 at 7:56 Comment(5)
is styleClass ="form-control" not workingCot
No. It does not apply the rounded edge style associated with <input> to <html:text>Meitner
#13893998Thapsus
That question and accepted answer both are Struts 2 specific and will not work for Struts 1.x.Meitner
1) Is it possible to suround the element with a wrapping div for example? 2) Can the solution include javascript / jQuery? 3) can you provide an example of how the field looks in html when it is rendered?Parhe
S
2

You have add the style(s) to the styleClass attribute.

For example:

<html:text property="propName" name="formName" styleClass="form-control"></html:text>

or

<html:submit styleClass="btn btn-link">submit</html:submit>

Here is a very basic sample app on GitHub that shows this working: https://github.com/lviviani/sample-struts-bootstrap

Styria answered 9/7, 2017 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.