11 March 2015

ADF DVT : Use of Click Listener for Pie Chart



When you want to perform some action on click and get the clicked value from the pie chart, you can use ClickListener added to the page bean. Here is the code you can use for the click listener:

1. Add it to your pie chart on the page


< dvt:pieGraph id ="graph5" value="#{bindings.yourView1.graphModel}" subType="PIE" dynamicResize="DYNAMIC_SIZE"
      clickListener="#{bean.myPieClickListener}" />



2. Add this to your bean

  public void myPieClickListener(ClickEvent evt)
  {
    ComponentHandle handle = evt.getComponentHandle();
    String myCode = null;
    if (handle instanceof DataComponentHandle)
    {
      DataComponentHandle dhandle = (DataComponentHandle) handle;
      Attributes[] seriesInfo = dhandle.getSeriesAttributes();
      if (seriesInfo != null)
      {
        for (Attributes attrs: seriesInfo)
        {
          myCode = (String) attrs.getValue(Attributes.ID_VALUE);
        }
      }
      //do whatever you want with your code
    }
  }

No comments:

Post a Comment