Showing posts with label Backing Bean. Show all posts
Showing posts with label Backing Bean. Show all posts

12 March 2015

ADF DVT : How to get multi-selection values from a pie chart

When you want to perform some action on click and get the clicked value (one or more than one pie slice) from the pie chart, you can use ClickAction added to the page bean. Here is how you can do it:

1. Add pie chart on the page

2. Bind the pie chart with a bean UIGraph component 
[code] private UIGraph myPie;  [/code]
3. Pay close attention to dataSelection attribute in the pie properties, if you want to get value of one pie slice then select "single" or select "multiple" for more than one values from a pie (default is "none"). you page should look like the code below:
[code] [/code]
4. Add this method to your bean (myBean)
[code]public String myPieSelectionAction(){ Object value1 = null; Object value2 = null; Set selectionSet = (Set) myPie.getSelection(); if (selectionSet == null) { //Show message to select pie slice return null; } for (GraphSelection selection: selectionSet) { if (selection instanceof DataSelection) { DataSelection ds = (DataSelection) selection; value1= ds.getSeriesKey().get("myAttribute1"); value2 = ds.getSeriesKey().get("myArrribute2"); } } // Do whatever you want with collected values return null; }[/code]


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
    }
  }