Reputation: 17461
My index.xhtml
looks like
<p:selectOneMenu value="#{tBean.selectedChartType}"
converter="entityConverter">
<f:selectItems value="#{tBean.chartTypes}" var="chart"
itemLabel="#{chart}" />
</p:selectOneMenu>
This presents ENUM list from my managed bean
private List<ChartType> chartTypes = Arrays.asList(ChartType.values());
My Enum
public enum ChartType {
Line("line"), Spiral_Line("spline"), Area("area"), Spiral_Area("areaspline");
private String code;
private ChartType(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
Now when I run this .jsf on browser sometimes it throw error :
XML Parsing Error: undefined entity
Location: http://xxxx/index.sf
Line Number 54, Column 733:
When I look at the source code I have found
which is causing this error I guess.
I am using JSF 2.2.0
and Primefaces 3.5
could someone please help me out with this issue?
Upvotes: 0
Views: 1641
Reputation: 627
A little late to help the asker, but perhaps can help someone: I got this same error and the only way I could get around it was adding the attribute contentType="text/html"
to my <f:view>
, as in
<f:view contentType="text/html">
...
<p:selectOneMenu>
<f:selectItem itemLabel="test" itemValue="test"/>
</p:selectOneMenu>
...
</f:view>
This occurs, afaik, because p:selectOneMenu
renders a
and this character is not a xml entity. As my page uses DOCTYPE XHTML 1.0 Transitional
, this causes the error to occur.
HTH.
Upvotes: 1
Reputation: 9935
Try as the following configuration in faces-config.xml
<converter>
<converter-for-class>java.lang.Enum</converter-for-class>
<converter-class>javax.faces.convert.EnumConverter</converter-class>
</converter>
page
<p:selectOneMenu value="#{tBean.selectedChartType}">
<f:selectItems value="#{tBean.chartTypes}" var="chart" itemLabel="#{chart}" />
</p:selectOneMenu>
Upvotes: 1