You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lbastil <ba...@gmx.de> on 2008/02/12 14:50:45 UTC

Re: Custom Tags for Struts2

Is there any complete Howto or Tutorial right now on this issue?
Should be really of interest ...

Thank you,
Basti



Jeromy Evans - Blue Sky Minds wrote:
> 
> Varun Narang wrote:
>> Hello all,
>> I want to get started with the customzied tag writing for Struts2.
>> I was able to find out ftl files for corresponding HTML elements.
>> Actually, I want to start writing tags which are integrated with ExtJS
>> library.
>>   
> One of the developers recently mentioned they is writing a document 
> about how to do this and I think there was talk about creating a maven 
> archetype.
> 
> In the mean-time, try following some of existing code.  The current 
> version of the struts2 yui plugin provides a nice simple example as it 
> only contains two tags and is packaged as a a plugin 
> (http://code.google.com/p/struts2yuiplugin/source).
> 
> I find it's easiest to follow that example completely - use the maven 
> plugin to generate the TLD and package your tags as a struts2 plugin. 
> This isn't mandatory though as you can write the TLD by hand and include 
> the classes in your webapp directly.
> 
> In general:
>  1. create a bean that extends UIBean or ClosingUIBean (for open & close 
> tags), identifies the templates and populates the template context
>  2. create a tag class that extends AbstractUITag that creates the bean 
> instance and sets the properties of the bean
>  3. create the templates referenced by the bean
> 
> After completing these 3 steps you can start using your tag if you write 
> a TLD and include it in your classpath.  If you copy the pom.xml from 
> the example able you can use maven to generate the TLD (if you've used 
> the appropriate annotations).
> 
> The remaining steps allowing your tags to be uses within freemarker and 
> velocity templates (rather than only JSP)
> 
>  4. Create a TagLibrary and TagModels for Freemarker and Directive's for 
> velocity
>  5. Create struts-plugin.xml that declares your TagLibrary bean
> 
> Hope that helps,
> regards,
> Jeromy Evans
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-Tags-for-Struts2-tp14289600p15433553.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Custom Tags for Struts2

Posted by Laurie Harper <la...@holoweb.net>.
Jeremy's post is the best HOWTO I've seen... There's also the source 
code for all the existing tags which you can use as reference material.

L.

lbastil wrote:
> Is there any complete Howto or Tutorial right now on this issue?
> Should be really of interest ...
> 
> Thank you,
> Basti
> 
> 
> 
> Jeromy Evans - Blue Sky Minds wrote:
>> Varun Narang wrote:
>>> Hello all,
>>> I want to get started with the customzied tag writing for Struts2.
>>> I was able to find out ftl files for corresponding HTML elements.
>>> Actually, I want to start writing tags which are integrated with ExtJS
>>> library.
>>>   
>> One of the developers recently mentioned they is writing a document 
>> about how to do this and I think there was talk about creating a maven 
>> archetype.
>>
>> In the mean-time, try following some of existing code.  The current 
>> version of the struts2 yui plugin provides a nice simple example as it 
>> only contains two tags and is packaged as a a plugin 
>> (http://code.google.com/p/struts2yuiplugin/source).
>>
>> I find it's easiest to follow that example completely - use the maven 
>> plugin to generate the TLD and package your tags as a struts2 plugin. 
>> This isn't mandatory though as you can write the TLD by hand and include 
>> the classes in your webapp directly.
>>
>> In general:
>>  1. create a bean that extends UIBean or ClosingUIBean (for open & close 
>> tags), identifies the templates and populates the template context
>>  2. create a tag class that extends AbstractUITag that creates the bean 
>> instance and sets the properties of the bean
>>  3. create the templates referenced by the bean
>>
>> After completing these 3 steps you can start using your tag if you write 
>> a TLD and include it in your classpath.  If you copy the pom.xml from 
>> the example able you can use maven to generate the TLD (if you've used 
>> the appropriate annotations).
>>
>> The remaining steps allowing your tags to be uses within freemarker and 
>> velocity templates (rather than only JSP)
>>
>>  4. Create a TagLibrary and TagModels for Freemarker and Directive's for 
>> velocity
>>  5. Create struts-plugin.xml that declares your TagLibrary bean
>>
>> Hope that helps,
>> regards,
>> Jeromy Evans
>>  
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org