You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Gagnon <mg...@genome.med.harvard.edu> on 2008/05/06 20:41:31 UTC

Struts Taglib

I've added a custom taglib in my project. One of these tags does some logic
to generate a series of links. Given one target URL, I want to create X
links to that URL with one changed parameter. If the given URL has
parameters, I want them to all be preserved except for one named
'pageNumber' which may be altered or added if missing

 

I would like to use struts URL tags in this. Ideally my tag handler would
generate s:url and s:a tags that could then be processed by struts. I don't
see a way to do this though. The only real way I immediately see is to use a
s:url tag before my tag to put a value on the stack then say something like 

prefix:myTag url="${sURL}"

to get a string in my handler. Then I'd have to parse for the pageNumber
variable to make sure I don't duplicate it, and generate html links
directly. I'd really strongly prefer some way of doing the above where I can
generate struts tags to be re-processed.

 

I know this is more of a general JSP oriented question, but it's worth
asking here. Is there a clear way to do this sort of thing?


Re: [struts] Struts Taglib

Posted by Dale Newfield <Da...@Newfield.org>.
Michael Gagnon wrote:
> I've added a custom taglib in my project

> I would like to use struts URL tags in this. Ideally my tag handler would
> generate s:url and s:a tags that could then be processed by struts. I don't
> see a way to do this though

A tag is a Java object.  You can always instantiate 
org.apache.struts2.views.jsp.URLTag in your custom tag, set the 
appropriate attributes (don't forget to setJspContext()), and call 
doTag() on it.

-Dale

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