Custom struts2 tag?

I want to write my own struts2 tag, which has a separate class of actions for itself and can be called from different jsp pages.

Sort of:

<s:writetext type="aaa" parentid="xxx" parentname ="yyy" height ="50" width ="125" /> 

Is it possible? Please help, I am very new to this, and googling about this did not help.

Thanks Aditya

+4
source share
3 answers

This old question has become relevant for me this week, when some existing code is being reviewed. Apart from tbruyelle's answer , this was the most useful link for me:

http://bodez.wordpress.com/2009/03/13/customising-struts2-jsp-tags/

In short (1) ,

  • Extend an existing tag (e.g. org.apache.struts2.views.jsp.ui.TextFieldTag )
  • Extend your behavior (e.g. org.apache.struts2.components.TextField )
  • Define a new theme and templates (for example, copy and edit an existing theme in /core/src/main/resources/template )
  • Create a new TLD for a customized version of taglib
  • Deploy it in a web application

struts 2 API can also be useful.

Unfortunately (and surprisingly), there is very little documentation on how to do this, and the javadoc for existing location components is a bit leaner and misleading. Perhaps it is not intended to be used in this way?


Notes

(1) I edited this answer a few years after the initial post to add this summary, matching the answer with SO recommendations. Unfortunately, this was a long time without working with similar code, and I cannot be sure that I have retained the essence of the linked blog, so please refer to the link if it still works.

+3
source

All Articles