views:

19

answers:

1

For example:

<c:a href="/myurl" style="margin: 5px;" addJsessionId="true" logEvent="true">
  click here</c:a>

such that:

1) all standard attributes of (style) are propagated as is.

2) my tag handler implementation handles the custom attributes (addJsessionId and logEvent in this case).

+1  A: 

Should be easy enough. JSP allows you define a tag with dynamic attributes, which essentially means the attributes are passed to the custom tag object as generic name/value pair rather than via setters as with normal tag attributes. This means you can transparently support arbitrary HTML attributes without declaring them individually in your tag class.

So, write a subclass of SimpleTagSupport, with your custom attributes fully defined and implemented, and then enable dynamic attributes for that tag.

It's still up to you to generate the actual HTML from the tag code, but that should be straightforward.

skaffman