02 September 2016

ADF DVT get Selected Pie values for pie chart

1. Create a pie graph
2. Make Data Selection property as Single
3. Add ClickListener in Bean

[code]<dvt:pieGraph id="graph1" value="#{bindings.ViewObject1.graphModel}" subType="PIE"
threeDEffect="true" animationOnDisplay="auto" hideAndShowBehavior="withRescale"
seriesRolloverBehavior="RB_HIGHLIGHT" dynamicResize="DYNAMIC_SIZE"
shortDesc="Delivery By Period" clickListener="#{bean.pieClickListener}">
[/code]

4. Add this code in bean [code]public void deliveryClickListener(ClickEvent clickEvent) {

String deliveryDate = null;
String customerCode = null;
String customerName = null;

MyUtil.invokeEL("#{bindings.ViewObject1.graphModel.processClick}", new Class[] { ClickEvent.class },
new Object[] { clickEvent });
// get selected row (Use pie chart iterator name)
Row selectedRow = (Row) myUtil.evaluateEL("#{bindings.ViewObject1Iterator.currentRow}");
//get attribute from selected row
customerCode = (String)selectedRow.getAttribute("CustomerCode");
deliveryDate = selectedRow.getAttribute("DeliveryDate").toString();
customerName = (String)selectedRow.getAttribute("CustomerName");

System.out.println("Delivery Date : "+deliveryDate);
System.out.println("Customer Code : "+customerCode);
System.out.println("Customer Name : "+customerName);
}
[/code]

5. Here are the helper methods

[code]
public static Object invokeEL(String el, Class[] paramTypes, Object[] params) {

FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
   MethodExpression exp = expressionFactory.createMethodExpression(
                                                elContext, el, Object.class,  paramTypes);
   return exp.invoke(elContext, params);
}


public static Object evaluateEL(String el) {
       FacesContext facesContext = FacesContext.getCurrentInstance();
       ELContext elContext = facesContext.getELContext();
      ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
     ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
    return exp.getValue(elContext);
}
[/code]


07 December 2015

How to resolve SVN E175002 VisualSVN connection error from JDeveloper11g


When you try to connect to visual SVN repository from JDeveloper 11.1.2.4, you may sometime get and error if you have updated/moved SVN server, error could be something similar to the following


svn: E175002: java.lang.RuntimeException: Could not generate DH keypair
Prime size must be multiple of 64, and can only range from 512 to 1024



This happens because of the SSL handshake error, this is how you can fix it:

1. Open Command prompt on your windows machine Go to the SVN server installation directory e.g. "C:\Program Files\VisualSVN Server" navigate to bin folder

2. Type this command : openssl dhparam 1024

3. You will see something like this




4. Copy the Text at the end including both lines --BEGIN DH PARAMETERS--- and ---END DH PARAMETERS----

5. The copied text will look like this

-----BEGIN DH PARAMETERS-----
MIGHAoGBANTDCmRPq+d8NDFX7j1XM2a+e17hY4IGyc+zboMOTylsMxtbE33YUViY
JvOCdQpw0LE0XDSAtetMHtcI18TdGQMIwBJNCceso07E4Vg04nICt9xrU8vHCvUk
GVBiuFKe9Du3At11t8AMl3sXWtvni1rfrVxUpQvqUqCP1Mpawe9TAgEC
-----END DH PARAMETERS----- 

6. Open "C:\Program Files\VisualSVN Server\certs" folder and look for file named "server.pem",  open the file with any  text editor, and paste the copied text at the end of the file.

7. Save the file, restart visual svn server 

8. You will be able to connect from JDeveloper now. 

13 October 2015

ADF Table column filters making it case insensitive



When you drag a view from data control and drop it on a page as ADF Table and mark it filterable, filters are added on each table column.


The problem here is when you enter any text on filter and hit enter, the table is filtered, but you will notice that its a case sensitive filtering and you cannot see the results if the data contains characters in different case (small or capital letters). 

You can overcome this issue by following this:

1. select table column from structure window


2. Go to properties for the table column

3. Select Behavior tab

4. In FilterFeatures property write "caseInsensitive".


5. Hit enter, save all changes and you are done !!






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

06 March 2015

ADF : Use Database Sequence in Entity Object

ADF Entity Object : How to use database sequence to populate EO attribute


If there is a requirement to use database sequence to populate an attribute of  ADF entity object, do the following:

1. Select the attribute where you want to use a sequence from attributes tab of an entity object
2. In details pane below, go to default value section
3. select "expression" radio button (one of three radio buttons - Literal, Expression and SQL)
4. add following groovy expression in the box provided below radio button

(new oracle.jbo.server.SequenceImpl("YOUR_SEQUENCE_NAME", adf.object.getDBTransaction())).getSequenceNumber()

5. Make sure that the sequence is available in the database you are connecting.
6. Save details and you are done, test your EO from Application Module tester or from the page.

Use Logger in ADF application

How to use ADF Logger in ADF Application


If you want to use Logger in your ADF application, add following to any Java class in your ADF application

First declare it

ADFLogger log = ADFLogger.createADFLogger(this.getClass());

or

private static final ADFLogger log =                ADFLogger.createADFLogger(MyClassName.class);

and the use it as

log.info("Logger output");