user1888955
user1888955

Reputation: 626

Struts tags substitution

I was wondering if I could replace Struts tags with HTML, especially when I output data. The projects in my company are still using struts tags but it seems it's not so easy to use compared with HTML.

Upvotes: 2

Views: 229

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

Of course you can, as long as you duplicate:

  • Whatever HTML is emitted by the tag, and...
  • ...whatever Java logic the tag implements.

For example, all custom form tags do is:

  • Emit form elements
  • (possibly embedded in other markup depending on your S2 theme)
  • Set the form element value from an action property
  • Display any error messages relating to the form element (depending on your S2 theme)

Some tags don't emit any HTML of their own, for example, <s:iterator> loops over a collection, pushes each object onto the value stack, and processes the tag body like any other JSP custom tag.

Should you reproduce existing framework logic and write either:

  • A lot more HTML, or...
  • ...your own complete suite of custom tags?

I doubt it, but there are likely valid usecases for doing so–I just can't think of them.

Upvotes: 1

Related Questions