struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cimballi <cimba...@cimballi.net>
Subject Re: Factoring out URL and link generation
Date Tue, 15 Jun 2010 18:08:51 GMT
Hi Jan,

One solution could be to externalize the URL generation in a JSP
fragment and set a variable containing the resulting URL.
Then, in your JSP you call the variable to output the URL.

Cimballi


On Tue, Jun 15, 2010 at 1:05 PM, Jan T. Kim <j.kim@uea.ac.uk> wrote:
> Hi All,
>
> the basic way to produce a link using struts seems to be to use the s:url
> and s:a tags, e.g. to produce a link to a person you might use something
> like
>
>    <s:url var="personurl" action="showperson">
>      <s:param name="personId" value="%{id}"/>
>    </s:url>
>    <s:a href="%{personurl}"><s:property value="%{firstname}"/></s:a>
>
> This is ok but it does get repetitive if links to persons occur in many
> JSPs, and if you want to change the format of these links (e.g. include
> the lastname), you have to search and update all these repetitions.
>
> Therefore, is it possible to factor out URL and link generation?
>
> I suppose I could write a taglib with my own person element but that
> seems a bit over the top to me.
>
> Best regards, Jan
> --
>  +- Jan T. Kim -------------------------------------------------------+
>  |             email: j.kim@uea.ac.uk                            
    |
>  |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
>  *-----=<  hierarchical systems are for files, not for humans  >=-----*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Cimballi
JAVA J2EE Freelance
http://javajeeleader.elance.com/

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


Mime
View raw message