Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 30018 invoked by uid 500); 28 Aug 2001 00:15:17 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: struts-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 30011 invoked from network); 28 Aug 2001 00:15:17 -0000 Received: from icarus.apache.org (64.125.133.21) by daedalus.apache.org with SMTP; 28 Aug 2001 00:15:17 -0000 Received: (qmail 89492 invoked by uid 1059); 28 Aug 2001 00:14:56 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 28 Aug 2001 00:14:56 -0000 Date: Mon, 27 Aug 2001 17:14:56 -0700 (PDT) From: "Craig R. McClanahan" Sender: To: Subject: Re: tags build upon tags In-Reply-To: <3B86A86A.6010507@moonlight.com> Message-ID: <20010827170838.P82011-100000@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Fri, 24 Aug 2001, John Raley wrote: > Date: Fri, 24 Aug 2001 12:18:02 -0700 > From: John Raley > Reply-To: struts-user@jakarta.apache.org > To: struts-user@jakarta.apache.org > Subject: Re: tags build upon tags > > Funny, I was just griping about this to a friend last night: that tags > aren't composable like functions and classes. IMO it's a major weakness > in JSP. There was some discussion earlier on this list, see "Using tags > from Java code". The short answer is you do it all yourself. > Hmm, the main reason that and are two separate tags (instead of one) is so you *can* compose them together. > David Corbin wrote: > > >I would like to write a tag that is essentially + > > + domain data from a database. > > >Is there a standard way to construct such a tag? Should I just write > the >whole thing by hand? Should I write it be calling the other tag > classes? > >David Corbin > > > Have you considered not writing a new tag at all? Unless there are some really interesting requirements, you should be able to do something like this: * In a Action that preceeds the creation of your form, create two ArrayLists (one for the labels and one for the values). Store these as request attributes under keys "labels" and values". * When the JSP page is executed, you just say: * If this list of labels and values gets used repeatedly, you might create them at application startup time and store them in application scope instead. It would certainly be feasible to write a custom tag to do the database lookup inside the tag, but this violates the principle of separating how the data is stored (in the database) from how it is presented (on the page). The strategy above establishes a very simple mechanism for communication from the model layer to the view layer, without creating any undo dependencies on either side. Craig