• Post Reply Bookmark Topic Watch Topic
  • New Topic

custom tags  RSS feed

 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!