Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Integration with java. Show all posts
Showing posts with label Integration with java. Show all posts

Wednesday 15 March 2017

Fetch Tweets of a User using Twitter4J API and show in af:table in ADF & Java


In the previous blogs we learned about posting tweets on twitter timeline using Twitter4J API and sending direct meaages to followers using same API

This post is next in the series and about fetching a user tweets and showing in ADF Table , For this requirement we need to use same Consumer Key+ Secret and Access Token+Secret (Refer previous posts for this)

And In same way after authentication we can fetch a user tweets by using it's twitter handle. So for this requirement I have added a button to fetch tweets and a POJO based table to show fetched tweets in page

See the code to fetch tweets using user's twitter handle and it's retweets and favourites count, We can get tweets by passing page number as parameter and it returns a list of tweets


Thursday 9 March 2017

Send Direct Message to followers using Twiter4J API in Oracle ADF and Java


My previous post was about tweeting using Twitter4J API from Oracle ADF Application . Twitter4J is a Java API that simplifies accessting twitter features in our application easily

In this I am going to show how to send DM (Direct Message) to anyone using their twitter handle and for this we need to use same consumer key, secret and access token, secret (How to access all these is described in previous post)

Tuesday 7 March 2017

Post to twitter using Twitter4J API in Oracle ADF and Java


Hello All

In this post I am talking about how to post a tweet on your twitter timeline using Twitter4J Java API in your Oracle ADF Application
Using this API makes the process very simple , For accessing twitter we need Twitter API keys, It is called Consumer Key and Access Token

For this you need a twitter account and then follow these steps

Thursday 16 February 2017

Post to Facebook Page Wall using restfb Graph API in ADF & Java


This is next post working with Facebook Graph API series, Previously I have posted about gettting access token and use it to get Facebook Profile detail and Posting status on your Facebook Timeline using restfb Facebook Graph API

Go through previous posts for better understanding of this blog post

Saturday 11 February 2017

Post Status on Facebook Timeline using restfb Graph API in ADF & Java

Hello All

Previous post was about generating temporary access token and using it get Facebook profile detail usinf restfb Graph API , Go through previous post before this as graph api basics are described in that post

Now In this post I am talking about posting facebook status update so for this I am extending same sample application

Wednesday 8 February 2017

Get Facebook profile detail using restfb Graph API in Java & ADF


Facebook is most popular social networking sites now a days and influencing our life in all aspect. Facebook gives us option to use it's Graph API to access it's features programmatically, The Graph API is primary way to read and write to facebook social graph using Access Tokens

In this post I am talking about how to access Facebook profile detail using restfb graph API . So First we need to know about Acsess Tokens

Monday 12 January 2015

Send eMail and attachement from any SMTP server using JavaMail in Oracle ADF


The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications- JavaMail API

This post is about sending eMail and attachments from any SMTP (Simple Mail Transfer Protocol) as Gmail or any other server (mail.awasthiashish.com)
You can read my previous post about mail integration with ADF that was specifically about using Gmail Server
Gmail Integration with Oracle ADF using Java Mail API 

So all basic configuration is described in previous post , now in this post i am only writing a java method to send mail and attachments


Don't forget to download these 2 jar files
  1.mail.jar 2. Activation.jar- Download
Add both jar files to project library path and then use this method 
Necessary packages to import -


import java.util.ArrayList;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;

import javax.activation.FileDataSource;

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.NoSuchProviderException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;


Helper method (JavaCode) to send simple eMail and eMail with attachment-

    /**Method to send mail from any SMTP server using JavaMail API
     * Provide Correct Parameters
     * @return
     * @param msg- Email Message Body
     * @parsm subject- Subject of Email
     * @param FromUser- Email Id of Sender
     * @param ToUser- Email Id of Reciever
     * @param pwd- Password of sender's email address
     * @param hostName- Host Name of Mail server (smtp.gmail.com)
     * @param isAnyAtchmnt- "Y" for yes there is an attachement and "N" for no attachment
     * @param fileNamePath- abolute path of file on server if there is any attachement
     */
    public String sendMail(String msg, String subject, String FromUser, ArrayList<String> ToUser, String pwd,
                           String hostName, String isAnyAtchmnt, ArrayList<String> fileNameNPath) {
        // Setting Properties
        Properties emailProperties = new Properties();
        emailProperties.put("mail.smtp.host", hostName);
        emailProperties.put("mail.smtp.auth", "true");
        emailProperties.put("mail.smtp.starttls.enable", "true");
        //Login Credentials
        final String user = FromUser; //change accordingly
        final String password = pwd; //change accordingly
        //Authenticating...
        Session session = Session.getInstance(emailProperties, new javax.mail.Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(user, password);
            }
        });

        //1) create MimeBodyPart object and set your message content
        MimeMessage message = new MimeMessage(session);
        try {
            message.setFrom(new InternetAddress(user));
            for (String email : ToUser) {
                System.out.println("Mail Id is-" + email);
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
            }
            message.setSubject(subject);

            BodyPart messageBody = new MimeBodyPart();

            messageBody.setContent(msg, "text/html");

            // If there is any attachment to send
            //5) create Multipart object and add MimeBodyPart objects to this object
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBody);

            if ("Y".equalsIgnoreCase(isAnyAtchmnt)) {
                //2) create new MimeBodyPart object and set DataHandler object to this object


                for (String path : fileNameNPath) {
                    MimeBodyPart messageBodyPart2 = new MimeBodyPart();
                    System.out.println("Exact path--->" + path);
                    DataSource source = new FileDataSource(path);
                    messageBodyPart2.setDataHandler(new DataHandler(source));
                    // System.out.println("FileName is-"+path.substring(path.lastIndexOf("//")+1, path.length()));
                    messageBodyPart2.setFileName(path.substring(path.lastIndexOf("//") + 2, path.length()));
                    multipart.addBodyPart(messageBodyPart2);
                }

                //6) set the multiplart object to the message object
                message.setContent(multipart);
                message.saveChanges();
            }
            //If there is plain eMail- No Attachment
            else {
                message.setContent(msg, "text/html"); //for a html email
            }
        } catch (MessagingException e) {
        }

        Transport transport = null;


        try {
            transport = session.getTransport("smtp");
        } catch (NoSuchProviderException e) {
            System.out.println("No such Provider Exception");
        }

        try {
            transport.connect(hostName, FromUser, pwd);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();

            System.out.println("Email sent successfully.");
            return "Y";
        } catch (MessagingException e) {
            System.out.println("Messaging Exception" + e);
            return "N";
        }

    }


Call this method in your ADF Application to send simple mail or mail with attachment, this is just like plug n play , provide correct parameters and use

Thanks :) Happy Learning

Friday 2 January 2015

Using captcha with ADF Faces (Integrate Kaptcha project with Oracle ADF)



First of all wishing a very Happy New Year to all of you, learn more n more ADF this year :)


This post is about using captcha challenge in ADF Faces, captcha is used to determine whether user is a human or not
CAPTCHA stands for-Completely Automated Public Turing test to tell Computers and Humans Apart
Frank Nimphius posted about 'captcha with ADF Faces' using "Simple Captcha" project.
You can read complete article- http://www.oracle.com/technetwork/developer-tools/jdev/captcha-099103.html



For this post I am using modern version of simplecaptcha project called Kaptcha, project provides a servlet that is responsible for generating captcha image and there are various configuration parameters to change look n feel of captcha image
See project documentation - https://code.google.com/p/kaptcha/
Download jar file- https://code.google.com/p/kaptcha/downloads/list

Now see the steps to integrate Kaptcha project with Oracle ADF
  • Create a FusionWeb Application, attach kaptcha-2.3.2 jar to viewController project, also see How to use "Kaptcha"-https://code.google.com/p/kaptcha/wiki/HowToUse


  • Next step is to add kaptcha servlet reference in web.xml file

  •  <servlet>
            <servlet-name>Kaptcha</servlet-name>
            <servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Kaptcha</servlet-name>
            <url-pattern>/kaptchaimage</url-pattern>
        </servlet-mapping>
    

  • Add an af:image on page to show captcha, image source is referenced from servlet mapping

  • <af:image id="i1" partialtriggers="l1" shortdesc="Captcha" source="/kaptchaimage">
    

  • Default configuration for captcha image is completed , I have added an af:inputText and button on page to enter captcha result .

  • <af:panelBox text="Captcha Demo- www.awasthiashish.com" id="pb1" showDisclosure="false"
                                     inlineStyle="width:350px;">
                            <f:facet name="toolbar"/>
                            <af:spacer width="0" height="10" id="s3"/>
                            <af:panelFormLayout id="pfl1">
                                <af:panelGroupLayout id="pgl1" layout="horizontal">
                                    <af:image source="/kaptchaimage" id="i1" partialTriggers="l1" shortDesc="Captcha"/>
                                    <af:spacer width="10" height="0" id="s4"/>
                                    <af:link id="l1" icon="#{resource['images:reload.png']}" shortDesc="Refresh Captcha"/>
                                </af:panelGroupLayout>
                                <af:inputText label="Enter text" id="it1" binding="#{ReadCaptchaBean.entrdCaptchaBind}"
                                              contentStyle="font-weight:bold;"/>
                                <af:button text="Submit" id="b1" actionListener="#{ReadCaptchaBean.readCaptchAction}"/>
                            </af:panelFormLayout>
                        </af:panelBox>
    

  • Run application and see how captcha image is appearing on page


  • It looks good :-), now see the managed bean code written in submit button's action. This code checks actual captcha value with entered value

  •     //Binding of inputText to get entered value
        private RichInputText entrdCaptchaBind;
    
        public void setEntrdCaptchaBind(RichInputText entrdCaptchaBind) {
            this.entrdCaptchaBind = entrdCaptchaBind;
        }
    
        public RichInputText getEntrdCaptchaBind() {
            return entrdCaptchaBind;
        }
        
        /**Method to check whether entered value is correct or not
         * @param actionEvent
         */
        public void readCaptchaAction(ActionEvent actionEvent) {
            FacesContext fctx = FacesContext.getCurrentInstance();
            ExternalContext ectx = fctx.getExternalContext();
            HttpServletRequest request = (HttpServletRequest) ectx.getRequest();
            //KAPTCHA_SESSION_KEY- The value for the kaptcha is generated and is put into the HttpSession. This is the key value for that item in the session.
            String kaptchaExpected =
                (String) request.getSession().getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
            //Get entered value of captcha using inputText binding
            String kaptchaReceived = entrdCaptchaBind.getValue().toString();
            System.out.println("Entered Value-" + kaptchaReceived + " Expected Value-" + kaptchaExpected);
            if (kaptchaReceived == null || !kaptchaReceived.equalsIgnoreCase(kaptchaExpected)) {
                FacesMessage errMsg = new FacesMessage("Invalid Value");
                errMsg.setDetail("Incorrect captcha value- Not Human");
                errMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
                fctx.addMessage(entrdCaptchaBind.getClientId(), errMsg);
            } else {
                FacesMessage errMsg = new FacesMessage("Correct Value");
                errMsg.setDetail("Hello this is the right guess");
                errMsg.setSeverity(FacesMessage.SEVERITY_INFO);
                fctx.addMessage(entrdCaptchaBind.getClientId(), errMsg);
            }
        }
    

  • Again run this application and enter value for captcha



  • So it is working , now to change captcha image added a link with partialSubmit=false and set partial trigger property on af:image.


  • Kaptcha integration with Oracle ADF is complete and it is working properly  now if you want to modify captcha look n feel then add some init-param (configuration parameter) in web.xml file.
    See complete list of configuration parameters- https://code.google.com/p/kaptcha/wiki/ConfigParameters
    I have changed some parameters value in web.xml , see changed source of web.xml and captcha output

  • <servlet>
            <servlet-name>Kaptcha</servlet-name>
            <servlet-class>com.google.code.kaptcha.servlet.KaptchaServlet</servlet-class>
            <init-param>
                <param-name>kaptcha.border</param-name>
                <param-value>yes</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.border.color</param-name>
                <param-value>red</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.border.thickness</param-name>
                <param-value>1</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.image.width</param-name>
                <param-value>250</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.image.height</param-name>
                <param-value>60</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.textproducer.font.size</param-name>
                <param-value>35</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.textproducer.font.color</param-name>
                <param-value>red</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.background.clear.from</param-name>
                <param-value>orange</param-value>
            </init-param>
            <init-param>
                <param-name>kaptcha.textproducer.char.length</param-name>
                <param-value>7</param-value>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>Kaptcha</servlet-name>
            <url-pattern>/kaptchaimage</url-pattern>
        </servlet-mapping>
    

    again run this application and check output

    Thanks, Happy Learning :)
    Download-Sample ADF Application

Monday 20 October 2014

Send SMS from Oracle ADF Application using Horizon SMS API

This post is about using SMS API to send SMS text to mobile from an Oracle ADF application
there are various SMS Gateway to send SMS using java and all java API's can be used with Oracle ADF

here i am using sms horizon (a bulk sms provider in india) see this SMS API integration with Java and Oracle ADF, follow the steps
First create an account with SMS Horizon - http://www.smshorizon.in/ or User Login- SMS Horizon

you can purchase a trial package to test your code, they provide 200 sms for Rs 25 only. So After purchasing trial pack you will get and API Key and username



Login to your account and see your dashboard-



you will see your API key in this type of box-



Now first step is complete and second and last step is implement code in your managed bean
you can find Sample API files (code to use API in Java, C#, PHP etc) from there

So for this i have a created a Fusion Web Application and a page in it


created a managed bean and actionListener for this Send button
this url is used to send sms and it returns msgId of sent message

http://smshorizon.co.in/api/sendsms.php?user=******&apikey=*****8&mobile=xxyy&message=xxyy&senderid=xxyy&type=txt


See the ActionListener code -


    /**Method to send SMS using SMS Horizon API
     * @param actionEvent
     */
    public void sendSMSAction(ActionEvent actionEvent) {
        // get mobile number value using component binding
        if (mobNoBind.getValue() != null) {
            // Replace with your username
            String user = "userId";

            // Replace with your API KEY (We have sent API KEY on activation email, also available on panel)
            String apikey = "your_api_key";

            // Replace with the destination mobile Number to which you want to send sms
            String mobile = mobNoBind.getValue().toString();

            // Replace if you have your own Sender ID, else donot change
            String senderid = "WEBSMS";

            // Replace with your Message content
            String message = "SMS API -Oracle ADF";

            // For Plain Text, use "txt" ; for Unicode symbols or regional Languages like hindi/tamil/kannada use "uni"
            String type = "txt";

            //Prepare Url
            URLConnection myURLConnection = null;
            URL myURL = null;
            BufferedReader reader = null;

            //encoding message
            String encoded_message = URLEncoder.encode(message);

            //Send SMS API
            String mainUrl = "http://smshorizon.co.in/api/sendsms.php?";

            //Prepare parameter string
            StringBuilder sbPostData = new StringBuilder(mainUrl);
            sbPostData.append("user=" + user);
            sbPostData.append("&apikey=" + apikey);
            sbPostData.append("&message=" + encoded_message);
            sbPostData.append("&mobile=" + mobile);
            sbPostData.append("&senderid=" + senderid);
            sbPostData.append("&type=" + type);

            //final string
            mainUrl = sbPostData.toString();
            System.out.println("URL to Send SMS-" + mainUrl);
            try {
                //prepare connection
                myURL = new URL(mainUrl);
                myURLConnection = myURL.openConnection();
                myURLConnection.connect();
                reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
                //reading response
                String response;
                while ((response = reader.readLine()) != null) {
                    //print response
                    System.out.println(response);
                }
                System.out.println(response);
                //finally close connection
                reader.close();


            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public void setMobNoBind(RichInputText mobNoBind) {
        this.mobNoBind = mobNoBind;
    }

    public RichInputText getMobNoBind() {
        return mobNoBind;
    }

you can check status of each SMS in your account that it is delivered of not, other than this you can also check status of msg in your code also using this url

http://smshorizon.co.in/api/status.php?user=*****&apikey=*********&msgid=xxyy

pass msgId returned from previous url and it will return you status of message as- PENDING , DELIVERED etc
see imports used in code-


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.input.RichInputText;

Thanks :) Happy Learning

Friday 9 August 2013

Creating pdf file using Apache PDFBox API in ADF Faces and opening it in new window -Oracle ADF

Apache PDFBox library is an open source java tool for working with PDF documents, go to http://pdfbox.apache.org/ for API docs and download jar (pdfbox-app-1.8.2) from there.

  •  Now create a fusion web application and add jar to view controller project's library and class-path
  •  To convert text to pdf format, i have used an input text and bind it to bean (to get value)
  •  Now see the button code that converts text to pdf file format using Apache PDFBox

  •         PDDocument document = new PDDocument();
            PDPage page = new PDPage();
            document.addPage(page);
    
            // Create a new font object selecting one of the PDF base fonts
            PDFont font = getFontDef();
    
            // Start a new content stream which will "hold" the to be created content
            PDPageContentStream contentStream = new PDPageContentStream(document, page);
    
            // Define a text content stream using the selected font, moving the cursor and drawing the text "Hello World"
    
            contentStream.beginText();
            contentStream.setFont(font, 10);
            contentStream.moveTextPositionByAmount(50, 700);
            contentStream.drawString(textToConvert.getValue().toString());
            contentStream.endText();
    
            // Make sure that the content stream is closed:
            contentStream.close();
    
            // Save the results and ensure that the document is properly closed:
            try {
                document.save("D:/Test_pdf.pdf");
            } catch (COSVisitorException e) {
            }
            document.close();
    

  • now your pdf is generated in fixed path, and if user want to open it immediately , try to do this



  •         if ((new File("D:\\Hello World.pdf")).exists()) {
    
                Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler D:\\Hello World.pdf");
                p.waitFor();
    
            } else {
    
                System.out.println("File is not exists");
    
            }
    

  • this code invokes File Protocol using Runtime class
  • Run this application and see-
 Click on generate button-


For more details and functionality visit Apache PDFBox site
Sample ADF Application-Download

Thursday 20 June 2013

Bing language Translation API integration with Java- microsoft-translator-java-api

Google Translation is very popular and widely used for language translation as it is now paid service,
so i  came to know about Microsoft Translator (Bing Translator), it is providing free API up to 2000,000 character/Month to translate.

Key features and point-
  • Provides java wrapper around microsoft translator (Bing Translator)
  • Developed as alternative of Google Translator
  • Follow coding standard, naming, functionality and usage patterns of widely used google translation API
This is very very simple to use -Follow steps




  • First Download JAR for API- http://code.google.com/p/microsoft-translator-java-api/  with all dependencies
  • Now obtain client secret key and client id in order to access API , see this http://msdn.microsoft.com/en-us/library/hh454950.aspx
  • After this create a simple java class and just write this code-
  • Don't forget to add JAR in your project's class path

  • package translation;
    
    import com.memetix.mst.language.Language;
    import com.memetix.mst.translate.Translate;
    
    public class MicrosoftTranslator {
        public static void main(String[] args) throws Exception {
            
            Translate.setClientId("secret client id");
            Translate.setClientSecret("secret key");
    
    
            String translatedText = Translate.execute("hello", Language.ENGLISH, Language.FRENCH);
            System.out.println(translatedText);
        }
    }
    

  • Enter your key and id in code, you can change language with available list, and run this code
  • To use this in web application , you must handle SSL certificate

Sunday 16 June 2013

Using Java API for getting Weather information in Oracle ADF-wunderground-core

hello everyone, here is nice tutorial for all ADF techies-
i have developed an application in ADF that retrieves weather information of a country's weather stations.
as-temperature, humidity, dew, rain rate, wind speed etc using wunderground-core 
API . This API fetch weather data for a weater station by given month and year or data for all the stations of a country.

Feature of this wunderground-core-
  1. Very simple to use
  2. Date Listener support
  3. Fetch weather data for all stations of country
  4. can be used with desktop or web application
  5. Ajax supported
  6. Real Time weather values
Snap-
 Change Country-

and download jar distribution with all dependencies

  • Now start , create a fusion web application and add jar file to  classpath
  • Now create a bounded taskflow and a .jsff page inside this , now see the simple code to get all weather station of acountry and their weather data

  •         /*  create an instance of WeatherStationService */
            WeatherStationService weatherStationService = new WeatherStationService();
    
            /*  find all weather stations */
            List<WeatherStation> stations = weatherStationService.findAllWeatherStationsByCountry("INDIA");
    
            
            for (WeatherStation weatherStation : stations) {
                System.out.println(weatherStation.getStationId() + "\t" + "\t" + weatherStation.getCity() + "\t" +
                                   weatherStation.getCountry());
    
                HttpDataReaderService dataReader = new HttpDataReaderService();
                dataReader.setWeatherStation(weatherStation);
                DataSet current = dataReader.getCurrentData();
    
                System.out.println(current.getDateTime() + "Temperature- " + current.getTemperature() + "Humidity-" +
                                   current.getHumidity());
    

  • I have used this code on my af:commandButton for getting weather data, and a table on page to show this information on page using list (arrayList) , rest is same and simple like other ADF Application
  • Download Sample Application and see it, you will also learn that how to show a table using List(Java) Sample ADF Application




  • See source of .jsff page for tables'use and values-

  • <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core">
        <af:panelBox text="Weather Report App-www.javadrive.co.in" id="pb1" showDisclosure="false">
            <f:facet name="toolbar"/>
            <af:panelFormLayout id="pfl1">
                <af:inputText label="Country Name" id="it1"
                              contentStyle="text-transform:upperCase;color:green;font-weight:bold;"
                              binding="#{WeatherReportBean.cntryNameBind}"/>
                <af:commandButton text="Get Report" id="cb1" actionListener="#{WeatherReportBean.getWeatherReportButton}"
                                  inlineStyle="font-weight:bold;"/>
            </af:panelFormLayout>
            <af:popup childCreation="deferred" autoCancel="disabled" id="p1">
                <af:dialog id="d1" title="User-User4" type="none">
                    <f:facet name="buttonBar"/>
                    <af:message id="m1" message="You are not authorize to make an order of 25000, your limit is 20000 !!!"
                                messageType="error"/>
                </af:dialog>
            </af:popup>
            <af:panelGroupLayout id="pgl1" layout="horizontal">
                <af:table var="row" rowBandingInterval="1" id="t1" value="#{WeatherReportBean.stations}"
                          partialTriggers="::cb1" contentDelivery="immediate" width="500">
                    <af:column sortable="false" headerText="Country" id="c3">
                        <af:spacer width="10" height="10" id="s2"/>
                        <af:outputText value="#{row.country}" id="ot3" inlineStyle="font-weight:bold;color:red;"/>
                        <af:spacer width="10" height="10" id="s1"/>
                    </af:column>
                    <af:column sortable="false" headerText="Locality" id="c4" width="150">
                        <af:outputText value="#{row.neighborhood}" id="ot4"/>
                    </af:column>
                    <af:column sortable="false" headerText="City" id="c2">
                        <af:outputText value="#{row.city}" id="ot2" inlineStyle="font-weight:bold;color:darkgreen;"/>
                    </af:column>
                    <af:column sortable="false" headerText="Station Id" id="c1">
                        <af:outputText value="#{row.stationId}" id="ot1" inlineStyle="font-weight:bold;color:darkblue;"/>
                    </af:column>
                </af:table>
                <af:table value="#{WeatherReportBean.reportL}" var="row" rowBandingInterval="1" id="t2"
                          contentDelivery="immediate" partialTriggers="::t1 ::cb1" styleClass="AFStretchWidth" width="800">
                    <af:column sortable="false" headerText="Date" align="start" id="c5">
                        <af:spacer width="10" height="10" id="s4"/>
                        <af:outputText value="#{row.currDate}" id="ot5" inlineStyle="font-weight:bold;">
                            <af:convertDateTime pattern="dd/MMM/yyyy"/>
                        </af:outputText>
                        <af:spacer width="10" height="10" id="s3"/>
                    </af:column>
                    <af:column sortable="false" headerText="Temperature" align="end" id="c6" width="70">
                        <af:outputText value="#{row.temp} C" id="ot6" inlineStyle="font-weight:bold;color:teal;"/>
                    </af:column>
                    <af:column id="c7" headerText="Humidity" align="right" width="70">
                        <af:outputText value="#{row.humid}" id="ot7" inlineStyle="font-weight:bold;color:orange;"/>
                    </af:column>
                    <af:column id="c8" headerText="Dew Point" align="right" width="70">
                        <af:outputText value="#{row.dewR}" id="ot8" inlineStyle="font-weight:bold;color:green;"/>
                    </af:column>
                    <af:column id="c9" headerText="Wind Direction" align="right" width="70">
                        <af:outputText value="#{row.windDirec}" id="ot9" inlineStyle="font-weight:bold; color:Olive;"/>
                    </af:column>
                    <af:column id="c10" headerText="Wind Speed (Km/H)" align="right">
                        <af:outputText value="#{row.windSpd}" id="ot10"
                                       inlineStyle="color:ActiveCaption;font-weight:bold;"/>
                    </af:column>
                    <af:column id="c11" headerText="Rain Rate" align="right" width="70">
                        <af:outputText value="#{row.rainRt}" id="ot11" inlineStyle="font-weight:bold;color:maroon;"/>
                    </af:column>
                    <af:column id="c12">
                        <af:image shortDesc="Weather" id="i1"
                                  source="#{row.temp >35 ? resource['images:sun.png'] : resource['images:sun_slush.png']}"/>
                    </af:column>
                </af:table>
            </af:panelGroupLayout>
        </af:panelBox>
    </jsp:root>
    

  • And see managed bean code to populate data in tables on page, other than manged bean i have used a java bean to populate value in list and then in table
  • WeatherReportBean.java

  • package weather.view.bean;
    
    import de.mbenning.weather.wunderground.api.domain.DataSet;
    import de.mbenning.weather.wunderground.api.domain.WeatherStation;
    import de.mbenning.weather.wunderground.impl.services.HttpDataReaderService;
    import de.mbenning.weather.wunderground.impl.services.WeatherStationService;
    
    import java.io.Serializable;
    
    import java.sql.SQLException;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.faces.event.ActionEvent;
    
    import oracle.adf.view.rich.component.rich.input.RichInputText;
    
    import oracle.jbo.domain.Date;
    
    public class WeatherReportBean implements Serializable {
        private RichInputText cntryNameBind;
    
        public WeatherReportBean() {
        }
        WeatherStationService weatherStationService = new WeatherStationService();
    
        List<WeatherStation> stations;
        List<Report> reportL;
    
    
        public void getWeatherReportButton(ActionEvent actionEvent) throws SQLException {
            if (cntryNameBind.getValue() != null) {
                String cntryName = cntryNameBind.getValue().toString();
    
                stations = weatherStationService.findAllWeatherStationsByCountry(cntryName);
                reportL = new ArrayList<Report>(50);
                for (WeatherStation weatherStation : stations) {
    
                    HttpDataReaderService dataReader = new HttpDataReaderService();
                    dataReader.setWeatherStation(weatherStation);
                    DataSet current = dataReader.getCurrentData();
    
                    java.util.Date b = new java.util.Date();
                    Double c = new Double(0);
                    Integer humidity = 0;
                    Double dew = new Double(0);
                    String windDir = "";
                    Double windSp = new Double(0);
                    Double rainRate = new Double(0);
    
                    if (current != null) {
                        if (current.getDateTime() != null) {
                            b = current.getDateTime();
                            c = current.getTemperature();
                            humidity = current.getHumidity();
                            dew = current.getDewPoint();
                            windDir = current.getWindDirection();
                            windSp = current.getWindSpeedKmh();
                            rainRate = current.getRainRateHourlyMm();
                            System.out.println("Humidity is-->" + current.getHumidity() + "dew point-->" +
                                               current.getDewPoint() + "wind -->" + current.getWindDirection() +
                                               "speed--" + current.getWindSpeedKmh());
    
    
                        }
                    }
    
                    reportL.add(new Report(b, c, humidity, dew, windDir, windSp, rainRate));
    
                }
    
    
            }
    
        }
    
        public void setStations(List<WeatherStation> stations) {
            this.stations = stations;
        }
    
        public List<WeatherStation> getStations() {
            return stations;
        }
    
        public void setReportL(List<Report> reportL) {
            this.reportL = reportL;
        }
    
        public List<Report> getReportL() {
            return reportL;
        }
    
        public void setCntryNameBind(RichInputText cntryNameBind) {
            this.cntryNameBind = cntryNameBind;
        }
    
        public RichInputText getCntryNameBind() {
            return cntryNameBind;
        }
    }
    

  • Report.java- bean class to populate list

  • package weather.view.bean;
    
    import java.util.Date;
    
    public class Report {
    
        private Date CurrDate;
        private double temp;
        Integer humid;
        Double dewR;
        String windDirec;
        Double windSpd;
        Double rainRt;
    
        public Report(Date date, Double double1, Integer hum, Double de, String windD, Double windS, Double Rain) {
            System.out.println("date is-->" + date + "and temp is-->" + double1);
    
            this.CurrDate = date;
            setTemp(double1);
            this.humid = hum;
            this.dewR = de;
            this.windDirec = windD;
            this.windSpd = windS;
            this.rainRt = Rain;
    
    
        }
    
    
        public void setCurrDate(Date CurrDate) {
            this.CurrDate = CurrDate;
        }
    
        public Date getCurrDate() {
            return CurrDate;
        }
    
        public void setTemp(double temp) {
            this.temp = temp;
        }
    
        public double getTemp() {
            return temp;
        }
    
        public void setHumid(Integer humid) {
            this.humid = humid;
        }
    
        public Integer getHumid() {
            return humid;
        }
    
        public void setDewR(Double dewR) {
            this.dewR = dewR;
        }
    
        public Double getDewR() {
            return dewR;
        }
    
        public void setWindDirec(String windDirec) {
            this.windDirec = windDirec;
        }
    
        public String getWindDirec() {
            return windDirec;
        }
    
        public void setWindSpd(Double windSpd) {
            this.windSpd = windSpd;
        }
    
        public Double getWindSpd() {
            return windSpd;
        }
    
        public void setRainRt(Double rainRt) {
            this.rainRt = rainRt;
        }
    
        public Double getRainRt() {
            return rainRt;
        }
    }