• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

custom tags

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i got a custom tag, which serves the purpose of Button and Hyperlink.This custom tag makes use of LinkTag.

public class ToggleButtonLink extends LinkTag
{
private static Category cat = WebServerCategory.getInstance(" ToggleButtonLink ");

public ToggleButtonLink()
{
src = null;
onSrc = null;
first = true;
}

public String getSrc()
{
return src;
}

public void setSrc(String src)
{
this.src = src;
}

public String getOnSrc()
{
return onSrc;
}

public void setOnSrc(String onSrc)
{
this.onSrc = onSrc;
}

public String getImageName()
{
return imageName;
}

private void createImageName()
{
Integer counter = (Integer)super.pageContext.getAttribute("imageCounter");
if(counter == null)
counter = new Integer(0);
Integer next = new Integer(counter.intValue() + 1);
super.pageContext.setAttribute("imageCounter", next);
imageName = "button" + next.toString();
}

protected static String concat(String s1, String s2)
{
if(s1 == null)
return s2;
if(s2 == null)
return s1;
else
return s1 + ";" + s2;
}


public int doStartTag()
throws JspException
{
onSrc = null;
imageName = null;
if(getOnSrc() == null)
setOnSrc(getSrc().substring(0, getSrc().length() - 5) + "2.gif");
createImageName();
if(first)
{
setOnmouseover(concat("document.images['" + getImageName() + "'].src='" + getOnSrc()+ "'", getOnmouseover()));
setOnmouseout(concat("document.images['" + getImageName() + "'].src='" + getSrc() + "'", getOnmouseout()));
first = false;
}
reply = super.doStartTag();
results = new StringBuffer("<img name=\"" + getImageName() + "\" src=" + getSrc() + " border=\"0\">");
ResponseUtils.write(super.pageContext, results.toString());
return reply;
}

private String src;
private String onSrc;
private String imageName;
private boolean first;
private int reply ;
private StringBuffer results;
}



i extended this custom tag and created another tag ,where in i am using the functions of the earlier custom tag.The functions 'setOnmouseover(),getOnmouseover()'doesnt seem to be working in the extended class.can any one pls help out,whats wrong in this?

public class ToggleImageSubmit extends ToggleButtonLink
{
private static Category cat = WebServerCategory.getInstance(" ToggleImageSubmit ");

public ToggleImageSubmit()
{
first = true;
}


public int doStartTag()
throws JspException
{
if(first)
{
setHref("#");
setOnclick(ToggleButtonLink.concat(getOnclick(), "submit()"));
setOnmouseover(ToggleButtonLink.concat("href=document.location.href+'#'", super.getOnmouseover()));
setOnmouseover(ToggleButtonLink.concat("search=document.location.search", super.getOnmouseover()));
first = false;
}
return super.doStartTag();
}

private boolean first;
}

any help ,highly appreciated.
its a bit urgent pls!

Thanks
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic