views:

287

answers:

2

Here is JSF code:

<o:chart id="categoryLineChart" model="#{categoryReports.categoriesLineChart}"
         view="line"
         rendered="#{categoryReports.reportRendered}"
         height="#{categoryReports.scaleHeight}" width="#{categoryReports.chartWidth}"
         binding="#{categoryReports.lineChartComponent}">
    <o:chartNoDataMessage  text="#{msg['report.nodata']}"/>
</o:chart>

And here is a part of backing bean for binding support (I post it hoping that something is missing here):

public void setLineChartComponent (Chart c) {
    this.lineChart = c;
}

public Chart getLineChartComponent () {
    return this.lineChart;
}

When I open page at first time everything works fine but when I open it at second time (refresh or open the same url in another tab or any other way) I get duplicate id error. Error message says that o:chartNoDataMessage has not unique id. Here is a part of long error message:

Component ID mainForm:j_id30 has already been found in the view. ... 
+id: j_id30 type: org.openfaces.component.chart.ChartNoDataMessage@26db62 +id: j_id30 type: <br/> +id: categoryPieChart type: org.openfaces.component.chart.Chart

The problem occured after I added binding attribute. If I remove it everything will work fine again (I tried).

I have 2 suggestions:

  1. I don't know how to use binding properly (I hope this is the case)
  2. There is a bug in component library
+3  A: 

You should bind it to a property which is used exclusively by the component in question. This exception indicates that this binding is been shared by multiple components. Fix it accordingly.

Duplicate component ID errors may occur when:

  • The same ID is used on different UIComponents inside the same UINamingContainer component.
  • Physically different components are bound to the same UIComponent property of the same bean.
  • The f:subview is been declared in the parent page instead of the include page.
  • The same include page is included multiple times inside the same UINamingContainer component.
  • A component is been dynamically built (e.g. new UIComponent()) without having an ID assigned.

Here, UINamingContainer is under each the <h:form>, <h:dataTable> and <f:subview>.

BalusC
Backing bean has session scope. This bean is being used only by this component. What do you mean saying 'exclusively'?
Roman
Thus different requests/views inside the same session is sharing the same binding? This isn't always going to work as well. Put it in a request scoped bean.
BalusC
I'm going to avoid binding at all and find suitable workaround. But I just wonder is it normal binding behavior (i.e. from spec)? Will I get the same result with standard jsf components? Or it depends?
Roman
Huh? Just put in request scope and use it further. You can even make it a child of the session scoped bean. Another cause can also be that the component is been used in an include/composition file and that it is included/reused multiple times inside the same page.
BalusC
Thanks for you list of possible problems. Its second item gave me an insight that getLineChartComponent() method should return null (in my case it doesn't break any functionality, I'm interested in setter method).
Roman
Glad you fixed it. You're welcome.
BalusC
A: 

You may please refer to the following link, and do let me know if it really helped. http://freejavaclass.com/detailpost.jsp?postid=63

athi
Did you miss the other answer?
BalusC