Return-Path: Delivered-To: apmail-jakarta-struts-dev-archive@jakarta.apache.org Received: (qmail 25357 invoked by uid 500); 6 Jul 2001 18:11:00 -0000 Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: struts-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 25342 invoked from network); 6 Jul 2001 18:10:58 -0000 Received: from interlock2.lexmark.com (192.146.101.10) by h31.sny.collab.net with SMTP; 6 Jul 2001 18:10:58 -0000 Received: by interlock2.lexmark.com id OAA22640 (InterLock SMTP Gateway 4.2 for struts-dev@jakarta.apache.org); Fri, 6 Jul 2001 14:10:59 -0400 Message-Id: <200107061810.OAA22640@interlock2.lexmark.com> Received: by interlock2.lexmark.com (Protected-side Proxy Mail Agent-1); Fri, 6 Jul 2001 14:10:59 -0400 X-Lotus-Fromdomain: LEXMARK@LEXMTA From: dhay@lexmark.com To: struts-dev@jakarta.apache.org, Oleg V Alexeev Date: Fri, 6 Jul 2001 14:10:33 -0400 Subject: Re: Indexed tags - proposal to add changes Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Oleg, Hi. Agree that the link tag is different, but think that it is due to its nature! Unlike the other tags, adding index as a query param seems to me the only reasonable way to provide access to the index in the link. Not sure how else to do it (if you try and use name, obviously you change the link into an anchor!). If you (or anyone else) has any suggestions to handle it in a better way would like to hear them - maybe I missed something! Cheers, Dave Oleg V Alexeev on 07/06/2001 01:47:47 PM Please respond to struts-dev%jakarta.apache.org@interlock.lexmark.com; Please respond to Oleg V Alexeev To: struts-dev%jakarta.apache.org@interlock.lexmark.com cc: (bcc: David Hay/Lex/Lexmark) Subject: Re: Indexed tags - proposal to add changes Hello dhay, I think it useful addition with minimal changes of existing code - good solution. But there is one problem for my mind - html:link with index=x. All another tag proposals are simple and transparent. Friday, July 06, 2001, 9:31:21 PM, you wrote: dlc> Hi everyone. dlc> I have been posting to the user list for some time now regarding creating dlc> indexed names within an iterate tag. From feedback from that list, this seems dlc> to be an important addition to the current tags. dlc> While looking to write my own additional tags which would do this (eg dlc> html:indexedText etc), I discovered that this functionality could easily be dlc> added to the current tags, now that the getIndex() method is available, by dlc> creating an extra parameter 'indexed' which when set to true would create the dlc> indexed names. The necessary additions to current code were small and quite dlc> clean, as follows: dlc> - added 'indexed' as a parameter in BaseHandlerTag, with appropriate dlc> setter/getter dlc> - added if statement which checks for 'indexed=true', and if so, appends "[x]" dlc> to the name, before appending property eg myProperty[x].value. dlc> This was added to BaseFieldTag (to cover tags which extend this) and dlc> CheckBoxTag, & SelectTag dlc> as follows: dlc> //if "indexed=true" parameter, create indexed name for this tag eg dlc> name="myCollection[x].myproperty" dlc> if ("true".equals(indexed)) dlc> { dlc> // look for outer iterate tag dlc> IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, dlc> IterateTag.class); dlc> if (iterateTag == null) dlc> { dlc> // this tag should only be nested in iteratetag, if it's not, don't do dlc> anything dlc> return EVAL_PAGE; dlc> } dlc> results.append(getName()); dlc> results.append("["); dlc> results.append(iterateTag.getIndex()); dlc> results.append("]."); dlc> } dlc> - Slight variations were added to SubmitTag and ButtonTag to simply add index to dlc> it's name ie mySubmit[x]. dlc> - linkTag was somewhat different due to its nature. I added if statement to add dlc> "index=x" as a parameter to the link's querystring ie myAction.do?index=1 or dlc> myAction.do?param1=37&index=1, as follows: dlc> //if "indexed=true", add "index=x" parameter to query string dlc> if ("true".equals(indexed)) dlc> { dlc> // look for outer iterate tag dlc> IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, dlc> IterateTag.class); dlc> if (iterateTag == null) dlc> { dlc> // this tag should only be nested in iteratetag, if it's not, dlc> don't do anything dlc> System.out.println("couldn't find enclosing iterate tag"); dlc> return EVAL_PAGE; dlc> } dlc> //calculate index, and add as a parameter dlc> if (params == null) dlc> { dlc> params = new HashMap(); //create new HashMap if no dlc> other params dlc> } dlc> params.put("index", "" + iterateTag.getIndex()); dlc> } dlc> - minimal changes to struts-html.tld to add 'indexed' as param. dlc> All of this code has been available at Ted's site for a while, and I would like dlc> to suggest it is added to the Struts source. Numerous people are already using dlc> it, and I believe many more would if it was part of the build. dlc> Would appreciate your feedback, and not sure what happens next (just joined this dlc> list)! dlc> Cheers, dlc> Dave dlc> PS code attached(See attached file: struts indexed files.ZIP) -- Best regards, Oleg mailto:gonza@penza.net