Hi there, First off i would suggest using only one custom tag insted of these two:
<input type='text' name='<gan:getFullNameForItem name="Weight" />' value='<gan:getValueForItem name="Weight" />' /> so that the JSP would look like: <gan:inputfieldwriter property="Weight"/> The reason being is that I the way you presented the problem it seems that you're always retrieving a Key/Value pair from the HashMap and placing it in one resulting HTML element so it makes sense to do it like that. Eventually you will need two tags Gan:array Gan:inputfieldwriter The Gan array must allow to nest other tags in it therefore your class must extend TagSupport. The tag must implement the doStartTag and doEndTag methods. The doStart will probably define your basic table element etc. it must then return EVAL_BODY_INCLUDE to tell the Jspwriter that this tag has a body and something must be valuated between its start and end tags. The doEndTag method is executed when the </gan:array> element is encountered, this will probably close the table element. public class GanArray extends TagSupport { public int doStartTag() throws JspException { //Do something return EVAL_BODY_INCLUDE; } public int doEndTag() throws JspException { //Do something return EVAL_PAGE; } } The second tag only needs to implement the doStartMethod. It will generate the required HTML to print the input field. public class InputFieldWirter extends BodyTagSupport { public int doStartTag() throws JspException { //Do something return EVAL_BODY_TAG; } } The request is of course always accessible in your taghandler by calling the following statement: HttpServletRequest req = (HttpServletRequest) this.pageContext.getRequest(); Personally I would create a third (abstract) tag which would be used as base for all standard html elements. This class would define fields like: name, styleclass, onmouseover and all other common html parameters. Your InputFieldWirter would then only have to extend this tag and implement only the functionality which is specific to it. For a good implementation check out Apache's Base Tags included in their custom taglib. Hope this helps MIchael -----Oorspronkelijk bericht----- Van: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]] Namens Cidoni_b Verzonden: donderdag 29 augustus 2002 11:44 Aan: [EMAIL PROTECTED] Onderwerp: Help need: Custom tags in JSP I am trying to use custom tags in my JSP. I have illustrated the simplified version of my problem below. Can anyone tell me how to go about doing it? Problem definition: -------------------- I have a JSP in which I retrieve a hashtable from request object using request.getAttribute() method. I need to display the commodity details present in the Hashtable using custom tags. Input Hashtable contents(given in Key: Value format) --------------------------------------------------- "Commodity.length": "2" "Commodity[0].Weight": "34" "Commodity[1].Weight": "43" Please note that the above keys are not Java arrays, they are just strings Required JSP format ------------------- <gan:array name = "Commodity"> <table> <tr> <input type='text' name='<gan:getFullNameForItem name="Weight" />' value='<gan:getValueForItem name="Weight" />' /> </tr> </table> </gan:array> Desired HTML output: -------------------- <table> <tr> <input type='text' name='Commodity[0].Weight' value='34' /> <input type='text' name='Commodity[1].Weight' value='43' /> </tr> </table> My question: ------------ How can I go about implementing the tags starting with "gan:"? Please note that there can be nested gan:array tags. ========================= To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com