You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sourav Das <is...@hotmail.com> on 2003/05/06 08:35:13 UTC

how to get TagData object???

Hi ,
    I am trying to fetch tag's attribute in doStartTag function of the tag handler.
Now I would like to know all its attribute defined in tld file associated with this
tag. I searched the documentation but could not figure out which could do this.

I have an other alternative of reading the tld with DOM but I think that is not a 
good solution.

Can any body help me on this?

thanks,
- iSourav

Re: how to get TagData object???

Posted by Thomas Cornet <th...@cornet.name>.
Tags should provide getters ans setters for all their parameters, so thay 
can be considered as java beans in a way. So what you could do is using the 
BeanUtils.describe() method of the commons beanutils API like this :

    Map m = BeanUtils.describe(new YourTagClass());

After, you just have to get the map's iterator on the keys to know all 
attributes of this particular tag.

Another way would be to parse the tld file with the Digester API.

                         Thomas

At 11:08 06/05/2003, you wrote:
>I think i was not clear. I want all the attributes
>defined in the tld for that particular tag. What you have specified
>below are call backs. take for example that you want in your code to
>  list all the attributes that are defined in the tld files then what you/we
>do?
>
>regrads'
>-iSourav
>
>----- Original Message -----
>From: "Shweta Kumari" <sh...@globalcase.net>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Tuesday, May 06, 2003 12:41 PM
>Subject: RE: how to get TagData object???
>
>
> > hi,
> >
> > For all the attributes defined in the tld file, you should have
> > getter/setter method in your Taglib. TLD is just a definition telling
>about
> > the specs of the Taglib.
> >
> > Check out the foll code. I hope it solves your problem.
> >
> > package com.irrs.taglib;
> >
> > import javax.servlet.jsp.tagext.*;
> > import javax.servlet.jsp.*;
> >
> > public class IRBrowserContentTag extends  BodyTagSupport {
> >
> >     private String name;
> >
> > /**
> > * setName
> > * Set the name of the object
> > *
> > * @param aName Object name
> >     */
> >
> >     public void setName(String aName){
> >         name=aName;
> >     }
> >
> > /**
> > * getName
> > * Get the name of the object
> > *
> > * @return name Object name
> >     */
> >     public String getName(){
> >         return name;
> >     }
> >
> >
> >
> >
> > /**
> > * doAfterBody
> > * Super class method overidden
> > *
> > * @return int SKIP_BODY as super class definition
> > * @exception JspTagException
> >     */
> >     public int doAfterBody()throws JspTagException
> >     {
> >         try {
> >
> >               getPreviousOut().println(name);
> >
> >         }catch (JspException je) {
> >             je.printStackTrace();
> >         }catch (Exception e) {
> >             e.printStackTrace();
> >         }
> >
> >         return SKIP_BODY;
> >
> >     }
> > }
> >
> > regards,
> > shweta
> >
> > -----Original Message-----
> > From: Sourav Das [mailto:isourav@hotmail.com]
> > Sent: Tuesday, May 06, 2003 12:05 PM
> > To: Struts Users Mailing List
> > Subject: how to get TagData object???
> >
> >
> > Hi ,
> >     I am trying to fetch tag's attribute in doStartTag function of the tag
> > handler.
> > Now I would like to know all its attribute defined in tld file associated
> > with this
> > tag. I searched the documentation but could not figure out which could do
> > this.
> >
> > I have an other alternative of reading the tld with DOM but I think that
>is
> > not a
> > good solution.
> >
> > Can any body help me on this?
> >
> > thanks,
> > - iSourav
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: how to get TagData object???

Posted by Sourav Das <is...@hotmail.com>.
I think i was not clear. I want all the attributes
defined in the tld for that particular tag. What you have specified
below are call backs. take for example that you want in your code to
 list all the attributes that are defined in the tld files then what you/we
do?

regrads'
-iSourav

----- Original Message -----
From: "Shweta Kumari" <sh...@globalcase.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, May 06, 2003 12:41 PM
Subject: RE: how to get TagData object???


> hi,
>
> For all the attributes defined in the tld file, you should have
> getter/setter method in your Taglib. TLD is just a definition telling
about
> the specs of the Taglib.
>
> Check out the foll code. I hope it solves your problem.
>
> package com.irrs.taglib;
>
> import javax.servlet.jsp.tagext.*;
> import javax.servlet.jsp.*;
>
> public class IRBrowserContentTag extends  BodyTagSupport {
>
>     private String name;
>
> /**
> * setName
> * Set the name of the object
> *
> * @param aName Object name
>     */
>
>     public void setName(String aName){
>         name=aName;
>     }
>
> /**
> * getName
> * Get the name of the object
> *
> * @return name Object name
>     */
>     public String getName(){
>         return name;
>     }
>
>
>
>
> /**
> * doAfterBody
> * Super class method overidden
> *
> * @return int SKIP_BODY as super class definition
> * @exception JspTagException
>     */
>     public int doAfterBody()throws JspTagException
>     {
>         try {
>
>               getPreviousOut().println(name);
>
>         }catch (JspException je) {
>             je.printStackTrace();
>         }catch (Exception e) {
>             e.printStackTrace();
>         }
>
>         return SKIP_BODY;
>
>     }
> }
>
> regards,
> shweta
>
> -----Original Message-----
> From: Sourav Das [mailto:isourav@hotmail.com]
> Sent: Tuesday, May 06, 2003 12:05 PM
> To: Struts Users Mailing List
> Subject: how to get TagData object???
>
>
> Hi ,
>     I am trying to fetch tag's attribute in doStartTag function of the tag
> handler.
> Now I would like to know all its attribute defined in tld file associated
> with this
> tag. I searched the documentation but could not figure out which could do
> this.
>
> I have an other alternative of reading the tld with DOM but I think that
is
> not a
> good solution.
>
> Can any body help me on this?
>
> thanks,
> - iSourav
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


RE: how to get TagData object???

Posted by Shweta Kumari <sh...@globalcase.net>.
hi,

For all the attributes defined in the tld file, you should have
getter/setter method in your Taglib. TLD is just a definition telling about
the specs of the Taglib.

Check out the foll code. I hope it solves your problem.

package com.irrs.taglib;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;

public class IRBrowserContentTag extends  BodyTagSupport {

    private String name;

	/**
	* setName
	* Set the name of the object
	*
	* @param aName Object name
    */

    public void setName(String aName){
        name=aName;
    }

	/**
	* getName
	* Get the name of the object
	*
	* @return name Object name
    */
    public String getName(){
        return name;
    }




	/**
	* doAfterBody
	* Super class method overidden
	*
	* @return int SKIP_BODY as super class definition
	* @exception JspTagException
    */
    public int doAfterBody()throws JspTagException
    {
        try {

              getPreviousOut().println(name);

        }catch (JspException je) {
            je.printStackTrace();
        }catch (Exception e) {
            e.printStackTrace();
        }

        return SKIP_BODY;

    }
}

regards,
shweta

-----Original Message-----
From: Sourav Das [mailto:isourav@hotmail.com]
Sent: Tuesday, May 06, 2003 12:05 PM
To: Struts Users Mailing List
Subject: how to get TagData object???


Hi ,
    I am trying to fetch tag's attribute in doStartTag function of the tag
handler.
Now I would like to know all its attribute defined in tld file associated
with this
tag. I searched the documentation but could not figure out which could do
this.

I have an other alternative of reading the tld with DOM but I think that is
not a
good solution.

Can any body help me on this?

thanks,
- iSourav



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