Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#7 c:chart tag tries to render a </img> tag producing a warning

open
None
5
2007-03-25
2006-10-25
Raul Davidovich
No

When using chart creator RC1 I get systematicaly a
warning saying that no text or HTML shoud be nested
inside an <img> tag.

When looking at UIChart class, I see the following code:

public void encodeBegin(FacesContext context) throws
IOException {
setChartDataAtSession(context);

ResponseWriter writer = context.getResponseWriter();
writer.startElement("img", this);
writer.writeAttribute("id", getClientId(context), null);
writer.writeAttribute("width",
String.valueOf(getWidth()), null);
writer.writeAttribute("height",
String.valueOf(getHeight()), null);
writer.writeAttribute("src",
ChartListener.CHART_REQUEST + ".jsf?ts=" +
System.currentTimeMillis() + "&id=" +
getClientId(context), null);
ChartUtils.renderPassThruImgAttributes(writer, this);
}

public void encodeEnd(FacesContext context) throws
IOException {
context.getResponseWriter().endElement("img");
}

If I take the "endElement" line in encodeEnd(), and put
it at the end of encodeBegin(), then remove
encodeEnd(), the warning dissapears:

public void encodeBegin(FacesContext context) throws
IOException {
setChartDataAtSession(context);

ResponseWriter writer = context.getResponseWriter();
writer.startElement("img", this);
writer.writeAttribute("id", getClientId(context), null);
writer.writeAttribute("width",
String.valueOf(getWidth()), null);
writer.writeAttribute("height",
String.valueOf(getHeight()), null);
writer.writeAttribute("src",
ChartListener.CHART_REQUEST + ".jsf?ts=" +
System.currentTimeMillis() + "&id=" +
getClientId(context), null);
ChartUtils.renderPassThruImgAttributes(writer, this);

context.getResponseWriter().endElement("img");
}

Discussion

    • assigned_to: nobody --> cagatay_civici