Forum Moderators: open
For Link
public class ToggleButtonLink extends LinkTag
{
private static Category cat = WebServerCategory.getInstance(" ToggleButtonLink ");
public ToggleButtonLink()
{
src = null;
onSrc = null;
first = true;
results = new StringBuffer();
}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
{
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;
boolean first;
private int reply ;
private StringBuffer results;
For Image Input
public class ToggleImageInput extends ImageTag
{
private static Category cat = WebServerCategory.getInstance(" ToggleImageInput ");
public ToggleImageInput()
{
onSrc = null;
}
public String getOnSrc()
{
return onSrc;
}
public void setOnSrc(String onSrc)
{
this.onSrc = onSrc;
}
public String getImageName()
{
return getProperty();
}
private void createImageName()
{
if(getProperty() == null ¦¦ getProperty().length() == 0)
{
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);
setProperty("button" + next.toString());
}
}
public int doStartTag()
throws JspException
{
FormTag formTag = (FormTag)TagSupport.findAncestorWithClass(this, org.apache.struts.taglib.html.FormTag.class);
if(formTag == null)
throw new JspTagException("ToggleImageInput must be enclosed in a FormTag");
if(getOnSrc() == null)
setOnSrc(getSrc().substring(0, getSrc().length() - 5) + "2.gif");
if(getBorder() == null ¦¦ getBorder().length() == 0)
setBorder("0");
createImageName();
setOnmouseover("MM_swapImage('" + getImageName() + "','','" + getOnSrc() + "',1)");
setOnmouseout("MM_swapImgRestore()");
return super.doStartTag();
}
private String onSrc;
}
For Image Submit
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+'#'", getOnmouseover()));
setOnmouseover(ToggleButtonLink.concat("search=document.location.search", getOnmouseover()));
first = false;
}
return super.doStartTag();
}
boolean first;
}
And the above code is used in jsp as follows :
<%
FW_S fws = new FW_S(3,((Integer) ugtm.getValueAt(i,7)).intValue());
java.util.Vector actions = (java.util.Vector) PMC.getAllowedActions(Profile, fws);
for (int u=0; u< actions.size();u++){
String ki =(String)actions.get(u); //actions.get(u).toString();
if (!ki.equalsIgnoreCase("z")){
String fn = "../images/action_"+actions.get(u)+"1.gif";
String onc = "document.forms[0].action.value='"+ki+"';document.forms[0].desk.value='"+pk+"'";
%>
<td class="<%=myclass%>" height="21" valign="top" align="center">
<webform:toggleSubmit onclick="<%=onc%>" src="<%=fn%>" /></td>
<% } %>
<% } %>
Can anyone pls recommend,why the hyperlink( onClick function) doesnt seem to be working?
Thanks
java9g
<logic:iterate id="reg" collection="<%= c %>" type="com.User">
<% userColor =(userColor.equals(ETLayout.userRowDark))? ETLayout.userRowBright2: ETLayout.userRowDark;
boolean isRowOdd = (userColor.equals(ETLayout.userRowDark));
%>
<tr bgcolor="<%= userColor %>">
<% String myclass = isRowOdd?"bgGray0":"bgGray1"; %>
<td class="<%=myclass%>"><%=reg.getName() %> </td>
<td class="<%=myclass%>" valign="top" align="center" height="21">
<webform:toggleButtonLink href="ETAdmin.jsp" paramId="id" paramName="reg" paramProperty="name" src= "../images/details1.gif" />
</td>
<% } %>
</tr>
</logic:iterate>
The button generated makes use of Toggling also using the javascript which is being embedded in the doStartTag() of the jsp.
The output looks fine ,but the toggling is not working and for some buttons the onclick/hyperlink doesnt seem to be working.
<webform:toggleButtonLink href="ETAdmin.jsp" paramId="id" paramName="reg" paramProperty="name" src= "../images/details1.gif" />
that doesn't mean anything to me, other than it probably printing out another form control with value and name set from the form bean. but i don't know what it's gonna do unless I see the HTML it actually prints, not the JSTL thanks.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>SOME SYSTEM</title>
<link rel="stylesheet" type="text/css" href="/someapp/css/standard.css"/>
<script type="text/javascript" language="JavaScript" src="/someapp/js/QXPscripts.js"></script>
<script type="text/javascript" language="JavaScript" src="/someapp/js/bas.js"></script>
<html>
<head>
<title>
</title>
<base href="http://localhost:8080/webPackage/jsp/ETApp.jsp">
<style>
body {margin-left:15px;margin-top:0px}
</style>
</head>
<body>
<form name="SingleUserForm" method="post" action="/someapp/singleUser.do">
<input type="hidden" name="action" value="">
<input type="hidden" name="desk" value="">
<table>
<tr>
<td class="tblHead">At</td>
<td class="tblHead">Valid from</td>
<td class="tblHead">Valid to</td>
</tr>
<tr>
<td class="bgGray1">2004-12-17</td>
<td class="bgGray1">2004-12-17</td>
<td class="bgGray1">2029-12-31</td>
<td class="bgGray1" valign="top" align="center">
<a href="ETUAN.jsp?i=997518&modifier=/viewUser" onmouseover="document.images['button1'].src='../images/view2.gif'" onmouseout="document.images['button1'].src='../images/view1.gif'"><img name="button13" src=../images/view1.gif border="0"></a>
</td>
<td class="bgGray1" height="21" valign="top" align="center">
<a href="#" onclick="document.forms[0].action.value='a3';document.forms[0].desk.value='997518'" onmouseover="document.images['button2'].src='../images/action_a32.gif';search=document.location.search;href=document.location.href+'#'" onmouseout="document.images['button2'].src='../images/action_a31.gif'"><img name="button14" src=../images/action_a31.gif border="0"></a>
</td>
<td class="bgGray1" height="21" valign="top" align="center">
<a href="#" onclick="document.forms[0].action.value='r3';document.forms[0].desk.value='997518'" onmouseover="document.images['button2'].src='../images/action_a32.gif';search=document.location.search;href=document.location.href+'#'" onmouseout="document.images['button2'].src='../images/action_a31.gif'"><img name="button15" src=../images/action_r31.gif border="0"></a>
</td>
</tr>
</table>
</form>
</body>
</html>
<a href="#" onclick="document.forms[0].action.value='a3';document.forms[0].desk.value='997502'" onmouseover="document.images['button2'].src='../images/action_a32.gif';search=document.location.search;href=document.location.href+'#'" onmouseout="document.images['button2'].src='../images/action_a31.gif'"><img name="button5" src=../images/action_a31.gif border="0"></a><a href="#" onclick="document.forms[0].action.value='r3';document.forms[0].desk.value='997502'" onmouseover="document.images['button2'].src='../images/action_a32.gif';search=document.location.search;href=document.location.href+'#'" onmouseout="document.images['button2'].src='../images/action_a31.gif'"><img name="button6" src=../images/action_r31.gif border="0"></a>
The button name in the image Tag is not getting updated.thats why the onmouseover functionality is not working.
This is working fine in tomcat3.22 but fails in tomcat4.1.so any idea about the cleaning up of instance variables in tomcat4.1?
thanks
java9g