Embedding highcarts in HDI

                                                                               Embedding highcarts in HDI


 

We can embed highcharts(http://www.highcharts.com/) in HDI (Helical Dashboard Insight).

To use highcharts, download latest version of highcharts. You can download from below mentioned link:

http://www.highcharts.com/download

Here, I am embedding a simple highcharts. You can find highcharts example on http://www.highcharts.com/demo/

1)    EFW file:- Create one EFW extension file. EFW contain the Title, author, description, Template name, visibility of the Dashboard.

2)   HTML file:  Create one html extension file. HTML file contains html code and HDI components such as SELECT, CUSTOM SCRIPT, DATE PICKER etc. We are going to use custom component:

Html file will look like this:

// Highcharts SRC scripts url

<script src=”http://code.highcharts.com/highcharts.js”></script>

<script src=”http://code.highcharts.com/highcharts-more.js”></script>

<script src=”http://code.highcharts.com/modules/exporting.js”></script>

// Dummy htmlobject for scutom script (runScript)

<div id=”chartContainer”></div>

// htmlobject for rendering the highcharts

<div id=”realtimeGraph”  style=”height: 300px;”></div>

//Now we write script and define components

<script>

dashboard = Dashboard;

var runScript = {

name: “runScript”,

type: “custom”,

requestParameters :{

“m_name” : “m_name”,

“sDate” : “sDate”,

“eDate” : “eDate”,

“org_id” : “org_id”,

“timeZone”: “timeZone”,

“clmname”:”clmname”,

“param”:”param”

},

listeners: [“m_name”,”sDate”,”eDate”],

htmlElementId: “#chartContainer”,

customScript: function(a,b){

$.getJSON(‘http://www.highcharts.com/samples/data/jsonp.php?filename=range.json&callback=?’, function (chartdata) {

$(‘#realtimeGraph’).highcharts({

chart: {

type: ‘arearange’,

zoomType: ‘x’

},

title: {

text: ‘Temperature variation by day’

},

xAxis: {

type: ‘datetime’

},

yAxis: {

title: {

text: null

}

},

tooltip: {

crosshairs: true,

shared: true,

valueSuffix: ‘°C’

},

legend: {

enabled: false

},

series: [{

name: ‘Temperatures’,

data: chartdata

}]

});

});

},

executeAtStart: true

};

// Now create one array of initialized components:

var components = [runScript];

// Now initialize defined components.

dashboard.init(components);

#realtimeGraph: It is a div ID where highcarts will be renderd.

Here we go. You can see highcharts in your HDI reports.

Thanks

Sharad

I-Report Bands

                                                                                                        I-Report Bands

 

A jasper report is composed by a set of sections named as “bands”.  Every band contains few properties such as height. Band height should be greater than 0, otherwise it will never be visible to user.  The band height can grow if elements inside it are stretched.

Default Bands in Report:

Title Band

Printedonly one time and it’s the first band. It can be printed on a separate page. You can print report title in this band.

 

Page Header

Printed on each page.

 

Column Header

It prints on each page if page contains detail band. If page splits it prints on each page. You can use this to crate manual table and put column name in this band.

 

Detail

It prints for each record in the source.

 

Column Footer

It is same as column header band, but it prints in footer instead of header.

 

Page Footer

Same as Page header, but it is footer section.

 

Summary

It prints only once at the end of the report. It can be printed on separate page also.

 

Background

It can be used to define a page background. You can also use image in this band.

 

The position of bands cannot be modified. For each band, you can modify only band height.

This is the sequence of bands in any jasper report (Fig 1.0). You can hide/unhide bands according to your needs.

If you click on any band, you can see the properties of that band in your right hand side panels (Fig 2.0). (If properties panel is not visible, Click on menu Window > Properties.

 

FIg 1.0

FIg 1.0

Fig 2.0

Fig 2.0

 

 

 

 

Thanks

Sharad Sinha

Sending Mail Using JavaMail API

Here, we are going to see how to send mail using JAVA MAIL API.

First, you need mail.jar in your project. If you have, copied it otherwise you can download.

Here are few notes, when you are going to create program for mail sending:

1)     It is always better to create SESSION instance in your code.

2)     Make sure you are using correct information about your SMTP host.

3)     Sender and recipient’s mail-id must be valid and active.

Now, we will see examples:

1: The Properties class represents a persistent set of properties. So create an object of Properties and set all required parameters into this object:

Properties props = new Properties();

props.put(“mail.smtp.auth”,isAuthenticated);

props.put(“mail.smtp.starttls.enable”,isSSLEnabled);

props.put(“mail.smtp.host”, hostname);

props.put(“mail.smtp.port”, port);

2: Create Session instance to authenticate user:

Session session = Session.getInstance(props,new javax.mail.Authenticator()                                                                {

protected PasswordAuthentication getPasswordAuthentication() {

    return new PasswordAuthentication(username, password);

   }

 });

3: Now, Create an object of java.mail.Message with created object of Session:

Message message = new MimeMessage(session);

Now, set required parameters which are used in sending mail, to message object:

message.setFrom(new InternetAddress([email protected]));

message.setRecipients(Message.RecipientType.TO, InternetAddress.parse([email protected]));

message.setSentDate(new Date());

message.setContent(body, “text/html; charset=utf-8”);

message.setSubject(“Testing Java Mail”);

message.setText(“Dear Recipient,” +”\n\n Hurray!! Mail is here.”);

Now, Send Message:

Transport.send(message);

NOTE:

If you are trying to send mail using gmail SMTP, first you need to disable security. You can find this option in your gmail setting or when you send mail, you will get one mail from gmail which will help you to disable security.

You can find below the code which sends mail using gmail SMTP:

package com.helical.Mail;

import java.util.Properties;

import javax.mail.Message;

import javax.mail.MessagingException;

import javax.mail.PasswordAuthentication;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeMessage;

  public class SendMailGmail {

 

                public static void main(String[] args)

               {

                                final String username = “[email protected]”;

                                final String password = “password”;

 

                                Properties props = new Properties();

                                props.put(“mail.smtp.auth”, “true”);

                                props.put(“mail.smtp.starttls.enable”, “true”);

                                props.put(“mail.smtp.host”, “smtp.gmail.com”);

                                props.put(“mail.smtp.port”, “587”);

                                 Session session = Session.getInstance(props,  new javax.mail.Authenticator(){

                                                protected PasswordAuthentication getPasswordAuthentication() {

                                                                return new PasswordAuthentication(username, password);                                                

                                                                      } 

                                                                });

 

                            try

                            {

                                    Message message = new MimeMessage(session);

                                    message.setFrom(new InternetAddress(“[email protected]”));

                              message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(“[email protected]”));

                                  message.setSubject(“Java Mail Testing”);

                                 message.setText(“Dear Recipient,”+ “\n\n Mail has received”);                  

                                 Transport.send(message);

                                System.out.println(“Mail Sent Successfully”);

                            }

                           catch (MessagingException e)

                          {

                                                throw new RuntimeException(e);

                          }

            }

}

Troubleshooting:

There are few exception, which you get often:

  • UnknownHostException : SMTP HOST

 

Ping to your SMTP host from command line. Make sure you get response (Success) because sometimes your firewall may block your connection.

 

  • javax.mail.AuthenticationFailedException

 

Check your username and password. If this is correct, try to login using your browser and make sure given user information are correct.

 

  • Could not connect to SMTP host

Check your SMTP host name and SMTP port, this is correct or not. Execute telnet command from your command prompt and check you are able to connect or not. Telnet command is:

C:\> telnet <SMTP HOST> <SMTP PORT>

 

Thanks

Sharad Sinha