throws IOException {
if ((context == null) || (component == null)) {
throw new NullPointerException();
}
AreaComponent area = (AreaComponent) component;
UIComponent form = findEnclosingForm(context, area);
UIComponent targetComponent = findComponent(context, form, area.getTargetImage());
String targetImageId = null;
if (targetComponent != null)
{
targetImageId = targetComponent.getClientId(context);
}
else
{
throw new NullPointerException("Unable to find the component: " + area.getTargetImage());
}
// fails in Myfaces because it thinks we are an "included/forwarded" request and hence adds a unique suffix
// area.findComponent(area.getTargetImage()).getClientId(context);
ImageArea iarea = (ImageArea) area.getValue();
ResponseWriter writer = context.getResponseWriter();
StringBuffer sb = null;
String formRef = "document.forms[0]['";
if (form != null)
formRef = "document.forms['" + form.getClientId(context) + "']";
writer.startElement("area", area);
writer.writeAttribute("alt", iarea.getAlt(), "alt");
writer.writeAttribute("coords", iarea.getCoords(), "coords");
writer.writeAttribute("shape", iarea.getShape(), "shape");
// PENDING(craigmcc) - onmouseout only works on first form of a page
sb =
new StringBuffer(formRef).append("['").append(targetImageId)
.append("'].src='");
sb.append(
getURI(context, (String) area.getAttributes().get("onmouseout")));
sb.append("'");
writer.writeAttribute("onmouseout", sb.toString(), "onmouseout");
// PENDING(craigmcc) - onmouseover only works on first form of a page
sb =
new StringBuffer(formRef).append("['").append(targetImageId)
.append("'].src='");
sb.append(
getURI(context, (String) area.getAttributes().get("onmouseover")));
sb.append("'");
writer.writeAttribute("onmouseover", sb.toString(), "onmouseover");
// PENDING(craigmcc) - onclick only works on first form of a page
sb = new StringBuffer(formRef).append("['");
sb.append(getName(context, area));