You have to copy/paste extended taglib description in your custom tld.

You should write a simplest custom tag that includes it's body into response (the way 
logic: tags do) on some
application-specific conditions, and use it this way :

<myTag:isUserInRole path="/sample.html">
    <html:link href="/sample.html">test</html:link>
</myTag:isUserInRole>

Your tag will be reusable for various presentation items.

Nico.


> Thanks Nico.
>
> However, I'm facing a problem with using my custom linktag.
>
> I am trying to specify the "href" attribute from which I shall get the
> "path" by using:
> <dtag:dlink href="/sample.html" showAlways="true">test tag</dtag:dlink>
>
> However, my jsp is giving me the error: "Error(12): Attribute: href is not a
> valid attribute name"
>
> I suspect that since it is looking up the tld which I've written, which
> doesn't have the href attribute, that's causing the error.
>
> Now, my tag class extends the struts html LinkTag, but how do I get it (my
> TLD) to include the attributes of the LinkTag in the original
> struts-html.tld.
>
> Thanks.
> Sanjay
>
> -----Original Message-----
> From: Nicolas De Loof [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 02, 2004 3:32 PM
> To: Struts Users Mailing List
> Subject: Re: Custom Link Tag
>
>
> public int doStartTag() {
>
>     if (skip_condition) {
>         return SKIP_BODY;
>     }
>     return super.doStartTag()
> }
>
> Nico.
>
> > Nico,
> >
> > Thanks for your response.
> > However, what will happen to the existing code in the doStartTag of the
> > org.apache.struts.taglib.html.LinkTag?
> > Because I will still need the existing functionality of the
> > org.apache.struts.taglib.html.LinkTag as well !!
> > Should I make a call to the super.doStartTag()?
> >
> > Please advise.
> >
> > Thanks.
> > Sanjay
> >
> > -----Original Message-----
> > From: Nicolas De Loof [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, December 31, 2003 6:25 PM
> > To: Struts Users Mailing List
> > Subject: Re: Custom Link Tag
> >
> >
> > Place your code in doStartTag as it can return SKIP_BODY to exclude body
> > from resulting HTML.
> >
> > return EVAL_BODY_INCLUDE if you want the body to be included
> >
> > Nico.
> >
> > > Hi,
> > >
> > > I am writing a custom tag: MyLinkTag that extends the
> > > org.apache.struts.taglib.html.LinkTag.
> > >
> > > MyLinkTag has two fields. They are
> > > showAlways : Boolean & alternateLink : String.
> > >
> > > The functionality of the MyLinkTag is captured in the following code
> > > snippet:
> > >
> >
> ****************************************************************************
> > > *******
> > > HttpServletRequest request = pageContext.getRequest();
> > > ActionMappings actionMappings =
> > > (ActionMappings)request.getAttribute(Action.MAPPINGS_KEY);
> > > String path = getHref();
> > > ActionMapping actionMapping = actionMappings.findMapping(path);
> > > String[] roleNames = actionMapping.getRoleNames();
> > > boolean userInRole = false;
> > > for(int i=0; i<roleNames.length(); i++)
> > > {
> > > userInRole = request.isUserInRole(roleNames);
> > > if(!userInRole){
> > > if((alternateLink != null) && !("".equals(alternateLink))){
> > > setHref(alternateLink);
> > > }
> > > else{
> > > if(showAlways){
> > > setDisabled(true);
> > > }
> > > else{
> > > //don't show the link
> > > return SKIP_BODY;
> > > }
> > > }
> > > }//end if !userInRole
> > > }//end for loop
> > >
> >
> ****************************************************************************
> > > *******
> > >
> > > The problem is I don't know where to place this code i.e. in which
> method:
> > > doStartTag() or doEndTag() or doAfterBody() or any other??
> > > What method should I override??
> > > And what should be the return [integer] values??
> > >
> > > Thanks in advance.
> > > Sanjay
> > >
>
> ____________________________________________________
> This message contains information that may be privileged or confidential and
> is the property of the Cap Gemini Ernst & Young Group. It is intended only
> for the person to whom it is addressed. If you are not the intended
> recipient, you are not authorised to read, print, retain, copy, disseminate,
> distribute, or use this message or any part thereof. If you receive this
> message in error, please notify the sender immediately and delete all copies
> of this message.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to