Hi,
I'm writing component for chart plotting using CDK. The component has an attribute dataclickListner which is methodexpression pointing to method. It should be invoked in broadcast method when DataClickEvent occurs. However this attribute is evaluated to null.
i followed this tutorial - part of events.
Snippet from AbstractChart.java
{code}
@JsfComponent( type = "sk.lukasmacko.richfaces.chart.component.Chart", family = "sk.lukasmacko.Chart", renderer = @JsfRenderer(type = "sk.lukasmacko.chartRenderer"),
tag = @Tag(name = "chart"), fires = {@Event(value = DataClickEvent.class, listener = DataClickListener.class)}
)
abstract public class AbstractChart extends javax.faces.component.UIComponentBase {
/*
.....
*/
@Attribute(signature =
@Signature(parameters = DataClickEvent.class))
public abstract MethodExpression getDataClickListener();
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof DataClickEvent) {
FacesContext facesContext = getFacesContext();
MethodExpression expression = getDataClickListener();
if (expression != null) {
expression.invoke(facesContext.getELContext(), new Object[]{event});
}
super.broadcast(event);
}
else{
super.broadcast(event);
}
}
}
{code}
Usage of component
{code:xml}<lm:chart dataClickListener="#{myBean.dataclick}" ...>...{code:xml}
dataclick is method in managedbean
{code}
public void dataclick(DataClickEvent event){
setMsg("An event occured! ");
}
{code}
component sources and example of usage
any help appreciated thanks!
I found a solution. There was a missing annotation.
@Tag(name = "chart",handler = "sk.lukasmacko.richfaces.facelets.html.ChartTagHandler", generate = true, type = TagType.Facelets)