You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ML...@abusinessware.com on 2007/05/10 15:20:45 UTC

[S2] Creating my own tag

Hi all,

I don't find any documentation on that, so I post here.

I would like to create my own tag (in Struts 1 I extend 
org.apache.struts.taglib.html.BaseFieldTag for example) to display a 
table. In fact I would like to put some HTML around displayTag.

How could I do ? Where are the new "baseFieldTag" ?

My HTML code to put in my Tag :

<table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
                <td colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0" 
width="100%">
                                <tr>
                                        <td><img src="<s:url value=
"img/tableauArrondiTitreGauche.gif"/>"></td>
                                        <td width="100%" class=
"tableauArrondiTitre"><s:text name="title"/></td>
                                        <td><img src="<s:url value=
"img/tableauArrondiTitreDroite.gif"/>"></td>
                                </tr>
                        </table>
                </td>
        </tr>
        <tr>
                <td class="tableauLateral"><img src="<s:url value=
"img/vide.gif"/>" width="1"></td>
                <td width="100%">
 
                        <div id="display">
                                <display:table name="interventions">
                                        <display:column title=
"Heure&nbsp;&nbsp;" property="heure" sortable="true"/>
                                        ...
                                </display:table>
                        </div>
 
                </td>
 
                <td class="tableauLateral"><img src="<s:url value=
"img/vide.gif"/>" width="1"></td>
        </tr>
 
        <tr>
                <td colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0" 
width="100%">
                                <tr>
                                        <td><img src="<s:url value=
"img/tableauArrondiBasGauche.gif"/>"></td>
                                        <td width="100%" class=
"tableauArrondiBas"></td>
                                        <td><img src="<s:url value=
"img/tableauArrondiBasDroite.gif"/>"></td>
                                </tr>
                        </table>
                </td>
        </tr>
</table>

Thanks a lot,

Regards,

Michaël.

Re: [S2] Creating my own tag/theme/template

Posted by Don Brown <do...@gmail.com>.
Thanks for sharing that tip.  You can also simply make a JSP 2.0 tag
and bypass the whole Struts 2 tag system if you'd like.  That is a
simple way to create your own tags that encapsulate common HTML.  The
main thing the Struts 2 tags add is the ability to call them from JSP,
Velocity, and Freemarker, but if you are just working with JSP, you
can use it and its tag system directly.

Don

On 5/11/07, MLENEVEUT@abusinessware.com <ML...@abusinessware.com> wrote:
> Kikoolol.
>
> Thanks for your help, but if you had read my question, you will have
> understood that we don't care what will be in my tag. In do know that
> displayTag is not Struts...
>
> By the way, I found my mistake. Tags does'nt more exist, it is themes and
> templates.
>
> So here is my JSP :
> <s:component template="crmTable" theme="xhtml">
>         <s:param name="title" value="%{'accueil.mesInterventions'}"/>
>         <s:param name="table">
>                                 <display:table name="interventions">
>                                         <display:column title=
> "Heure&nbsp;&nbsp;" property="heure" sortable="true"/>
>                                         ...
>                                 </display:table>
>         </s:param>
> </s:component>
>
> and my template :
> <table border="0" cellpadding="0" cellspacing="0" width="100%">
>         <tr>
>                 <td colspan="3">
>                         <table border="0" cellpadding="0" cellspacing="0"
> width="100%">
>                                 <tr>
>                                         <td><img src="<@s.url
> value="img/tableauArrondiTitreGauche.gif"/>"></td>
>                                         <td width="100%" class=
> "tableauArrondiTitre">
> ${stack.findValue("getText('"+parameters.title+"')")}</td>
>                                         <td><img src="<@s.url
> value="img/tableauArrondiTitreDroite.gif"/>"></td>
>                                 </tr>
>                         </table>
>                 </td>
>         </tr>
>         <tr>
>                 <td class="tableauLateral"><img src="<@s.url
> value="img/vide.gif"/>" width="1"></td>
>                 <td width="100%">
>
>                         <div id="display">
>                                 ${parameters.table}
>                         </div>
>
>                 </td>
>
>                 <td class="tableauLateral"><img src="<@s.url
> value="img/vide.gif"/>" width="1"></td>
>         </tr>
>
>         <tr>
>                 <td colspan="3">
>                         <table border="0" cellpadding="0" cellspacing="0"
> width="100%">
>                                 <tr>
>                                         <td><img src="<@s.url
> value="img/tableauArrondiBasGauche.gif"/>"></td>
>                                         <td width="100%" class=
> "tableauArrondiBas"></td>
>                                         <td><img src="<@s.url
> value="img/tableauArrondiBasDroite.gif"/>"></td>
>                                 </tr>
>                         </table>
>                 </td>
>         </tr>
> </table>
>
> If it could be helpfull for someone...
>
> Michaël.
>
>
>
>
> "Antonio Petrelli" <an...@gmail.com>
> 10/05/2007 15:35
> Veuillez répondre à
> "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> A
> "Struts Users Mailing List" <us...@struts.apache.org>
> cc
>
> Objet
> Re: [S2] Creating my own tag
>
>
>
>
>
>
> 2007/5/10, MLENEVEUT@abusinessware.com <ML...@abusinessware.com>:
> > In fact I would like to put some HTML around displayTag.
>
> DisplayTag IS NOT part of Struts:
> http://displaytag.sourceforge.net/
>
> Antonio
>
> ---------------------------------------------------------------------
> 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


Re: [S2] Creating my own tag/theme/template

Posted by ML...@abusinessware.com.
Kikoolol.

Thanks for your help, but if you had read my question, you will have 
understood that we don't care what will be in my tag. In do know that 
displayTag is not Struts...

By the way, I found my mistake. Tags does'nt more exist, it is themes and 
templates.

So here is my JSP :
<s:component template="crmTable" theme="xhtml">
        <s:param name="title" value="%{'accueil.mesInterventions'}"/>
        <s:param name="table">
                                <display:table name="interventions">
                                        <display:column title=
"Heure&nbsp;&nbsp;" property="heure" sortable="true"/>
                                        ...
                                </display:table>
        </s:param>
</s:component>

and my template :
<table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
                <td colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0" 
width="100%">
                                <tr>
                                        <td><img src="<@s.url 
value="img/tableauArrondiTitreGauche.gif"/>"></td>
                                        <td width="100%" class=
"tableauArrondiTitre">
${stack.findValue("getText('"+parameters.title+"')")}</td>
                                        <td><img src="<@s.url 
value="img/tableauArrondiTitreDroite.gif"/>"></td>
                                </tr>
                        </table>
                </td>
        </tr>
        <tr>
                <td class="tableauLateral"><img src="<@s.url 
value="img/vide.gif"/>" width="1"></td>
                <td width="100%">
 
                        <div id="display">
                                ${parameters.table}
                        </div>
 
                </td>
 
                <td class="tableauLateral"><img src="<@s.url 
value="img/vide.gif"/>" width="1"></td>
        </tr>
 
        <tr>
                <td colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0" 
width="100%">
                                <tr>
                                        <td><img src="<@s.url 
value="img/tableauArrondiBasGauche.gif"/>"></td>
                                        <td width="100%" class=
"tableauArrondiBas"></td>
                                        <td><img src="<@s.url 
value="img/tableauArrondiBasDroite.gif"/>"></td>
                                </tr>
                        </table>
                </td>
        </tr>
</table>

If it could be helpfull for someone...

Michaël.




"Antonio Petrelli" <an...@gmail.com> 
10/05/2007 15:35
Veuillez répondre à
"Struts Users Mailing List" <us...@struts.apache.org>


A
"Struts Users Mailing List" <us...@struts.apache.org>
cc

Objet
Re: [S2] Creating my own tag






2007/5/10, MLENEVEUT@abusinessware.com <ML...@abusinessware.com>:
> In fact I would like to put some HTML around displayTag.

DisplayTag IS NOT part of Struts:
http://displaytag.sourceforge.net/

Antonio

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



Re: [S2] Creating my own tag

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/10, MLENEVEUT@abusinessware.com <ML...@abusinessware.com>:
> In fact I would like to put some HTML around displayTag.

DisplayTag IS NOT part of Struts:
http://displaytag.sourceforge.net/

Antonio

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