Please disable your adblock and script blockers to view this page

Search this blog

Friday 26 October 2018

Use Google Fonts in ADF Application using custom CSS

We can use google fonts in the ADF application very easily. In this post, I'll describe the steps to implement this using custom CSS.

Go to Google Fonts

Select any font that you want to use and click on the plus (+) icon, I have clicked that that's why the image is showing the minus(-) icon

The next step is to see the font's properties and copy the highlighted link, It'll be used in our CSS

Now create a page in the ADF application and add this CSS using the ADF Resource tag, Here I have added 4 different fonts

  1. <af:resource type="css" source=""/>
  2. <af:resource type="css" source=""/>
  3. <af:resource type="css" source=""/>
  4. <af:resource type="css" source=""/>

Added four output text to show different fonts

  1. <af:outputText value="Oracle Application Development Framework" id="ot1"
  2. inlineStyle="font-family:Charmonman;font-size:35px;color:red;font-weight:bold;"/>
  3. <af:spacer width="10" height="10" id="s1"/>
  4. <af:outputText value="Oracle Application Development Framework" id="ot2"
  5. inlineStyle="font-family:Kirang Haerang;font-size:35px;color:green;font-weight:bold;"/>
  6. <af:spacer width="10" height="10" id="s2"/>
  7. <af:outputText value="Oracle Application Development Framework" id="ot3"
  8. inlineStyle="font-family:VT323; font-size:35px; color:#4289aa; font-weight:bold;"/>
  9. <af:spacer width="10" height="10" id="s3"/>
  10. <af:outputText value="Oracle Application Development Framework" id="ot4"
  11. inlineStyle="font-family:Philosopher; font-size:35px; color:#dc006d; font-weight:bold;"/>

Now run the application and check :)

Sample ADF Application - Download

Cheers 🙂 Happy Learning

Wednesday 10 October 2018

Write data to google spreadsheet using service account and oauth authentication

Hello Everyone, Previously I have posted about reading data from Google spreadsheets and got lots of comments regarding writing data to google sheet. So in this post, I am describing how to write data to a google spreadsheet.

Here I am using a Google service account and auth key for authentication purposes. Here I'll show you how to obtain a key from google console.

  • Enable google sheets API for this project

  • Click on the project -- APIs & Services -- Credentials and click on Create credentials button

  • Select key type p12 and put account name

  • After this step, p12 key is downloaded to your system

Now see the java code that inserts a new record in the existing google sheet, Here I am using the same Google sheet that I have used in the previous post. is the URL of the spreadsheet and it looks like this

  1. package spreadsheetdemo;
  2. import;
  3. import;
  4. import;
  5. import;
  6. import;
  7. import;
  8. import;
  9. import;
  10. import;
  11. import;
  12. import;
  13. import;
  14. import;
  15. import;
  16. import;
  17. import;
  18. import;
  19. import java.util.Arrays;
  20. import java.util.List;
  21. public class MySpreadsheetIntegration {
  22. public static void main(String[] args) throws AuthenticationException, MalformedURLException, IOException,
  23. ServiceException, GeneralSecurityException {
  24. SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1");
  25. // Put the path of p12 file that is downloaded from Google Console
  26. File p12 = new File("D:/API Project-f35e9ad5ad07.p12");
  27. HttpTransport httpTransport = new NetHttpTransport();
  28. JacksonFactory jsonFactory = new JacksonFactory();
  29. String[] SCOPESArray = {
  30. "", "",
  31. ""
  32. };
  33. final List SCOPES = Arrays.asList(SCOPESArray);
  34. //Put your google service account id
  35. GoogleCredential credential =
  36. new GoogleCredential.Builder().setTransport(httpTransport).setJsonFactory(jsonFactory).setServiceAccountId("").setServiceAccountScopes(SCOPES).setServiceAccountPrivateKeyFromP12File(p12).build();
  37. service.setOAuth2Credentials(credential);
  38. // Define the URL to request. This should never change.
  40. new URL("");
  41. // Make a request to the API and get all spreadsheets.
  42. SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
  43. List<SpreadsheetEntry> spreadsheets = feed.getEntries();
  44. System.out.println("Total Sheets- " + spreadsheets.size());
  45. if (spreadsheets.size() == 0) {
  46. }
  47. SpreadsheetEntry spreadsheet = spreadsheets.get(0);
  48. System.out.println(spreadsheet.getTitle().getPlainText());
  49. // Get the first worksheet of the first spreadsheet.
  50. WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
  51. List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
  52. WorksheetEntry worksheet = worksheets.get(0);
  53. System.out.println(worksheet.getTitle().getPlainText());
  54. // Create a local representation of the new row.
  55. ListEntry row = new ListEntry();
  56. row.getCustomElements().setValueLocal("Cell1", "Testing");
  57. row.getCustomElements().setValueLocal("Cell2", "New Data");
  58. // Send the new row to the API for insertion.
  59. row = service.insert(spreadsheet.getWorksheetFeedUrl(), row);
  60. }
  61. }

After running this code see the new row is inserted in Google Sheet

You can download the required jars from this link

Cheers 🙂 Happy Learning