struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dallas_Brown...@ovid.com
Subject Passing Parameters to a custom tag...
Date Tue, 01 May 2001 21:45:00 GMT

Hi all, let me see if I can explain this.  I have a custom tag that
displays a list of information from a database.  The database will allow me
to apply an XSLT on the XML that it returns, and thus I can get the data
formatted how I want it.  Essentially my tag calls a method get
XMLDataList(int numOfRows, String XSLStyleSheetURI, String SortBy,
JSPWriter out).  This method belongs to a class that takes the information
passed to it, queries the DB and gives out (the JSPWriter) the html.  Then,
of course, html appears magically on the page.
However, I want the user to be able to determine how the list should sort
and how many rows should be shown.
There are many ways to accomplish this, using the struts framework, but I
am guessing that there are few ways that would be honest to the framework.
I would like your opinions on the matter.  How best would I solve this?
One idea, I could cheat and write the tag out like this
<customTagLib:customTag rows="<%=request.getParameter("rows")%>"... But I
would like to avoid any scriptlets on the page.
Or I could still allow the tag to accept a "hard coded" number (for
instance, a "rows="someNumber"" could be an option, and if so, user input
would be ignored).  And if those elements did not exist, ie the tag was
empty (<customTagLib:customTag/>) then the tag itself could do a
request.getParameter("rows")...  I kind of like that idea.  That way the
page designer has power, but they don't need to worry about knowing jsp in
order to give the user's the option to decide what the list should look
like.
But maybe I'm missing something.

One other (somewhat related) question.  I know that posts are generally an
elegant manner to pass data in struts.  But is it frowned upon to use gets
often, for instance I have many text buttons that are links to various *.do
pages.  Is there something preferred to passing data in a link like this
(We'll use the dataList idea again) <a href="sort.do?sort=name>Sort by
Name</a>  ?

Thank you,

Dallas Browning


Mime
View raw message