Annotations

These days I'm reading about annotated XML as it is necessary for our final year project.When I started it, I didn't had any idea about what it means.So I first searched about the meaning of annotation.

When we read a text book or some article, we make our own notes about its content. In general annotation means something like that.

There are many technologies that use annotation concept. following is a summary of what I found on internet regarding annotation.

Java Annotations:
is a which feature shifted the responsibility for writing the boilerplate code from the programmer to the compiler.


PDF Annotation:
Adobe Acrobat is one example of proprietary software that allows the user to annotate, highlight, add notes to already created PDF files.

Web Annotation:
It can be considered as an annotation system, a user can add, modify or remove information from a Web resource without modifying the resource itself.

Scrollable HTML table with arrow key support

Last week I had to face following scenario.

I had to create an scrollable HTML table and when it loads, the first entry is already selected. I should be able to navigate it by arrow keys.

When I create it the arrow keys worked properly, but the scrollbar does not work at that time. So I can select only rows in the visible area of table.

If I click on a row, then both keys and scrollbar work properly.(When I press down arrowkey consecutively, scrollbar works and shows the selected row).

I wanted to find a way , which can activate both arrowkeys and scrollbar when the page loads.This is the solution I found.

you can add a scrollbar to the table by following command.


To make scrollbar and keys work, you need to set focus to the table when the page loads.As the table cannot be focused correctly, put a tag and set focus to it.








window.onload = function(){
document.getElementById('doctypelink').focus();
}

Few facts about Environment variables

Yesterday, I had to install MULE esb in my machine for our new project. There were about three options to install it. I had to tried two of them because, the first method was bit confusing.By doing that I learnt many new things that I wasn't aware of. So I'm going to share them.

To edit or add new environment/system variables (windows)
start-->control panel-->system-->advanced-->environment variables

* if need to access some command from command prompt,first we need to set "path" variable accordingly.

ex: to invoke maven from cmd prompt we have to add M2_HOME and M2 envronmental variables and append M2_HOME to the path variable.

* When you try to enter a command in cmd line, if you get any error message saying " is not recognized as an internal or external command, operable program or batch file" It is probably because you have'nt add "C:\WINDOWS\system32" to your path variable.
If you have already added it, then check it's position there. It should be the first entry under path variable.

Adding image to a report dynamically- iReport

This blog is about adding an image to a report in iReport dynamically. In this example I'm going to do it through a netbeans plugin (using iReport platform).

First create a netbeans module. Select iReport as the platform. Add an action class to the project. In gui registration , I selected it to get a menuitem under the Format menu.

then add following code to Action class.


public void actionPerformed(ActionEvent e) {
boolean isImageAdded=false;
JasperDesign report=IReportManager.getInstance().getActiveReport();
if( report != null ){
JRParameter param[]=report.getParameters();
for(int i=0; i if(param[i].getName().equals("photo")){
JOptionPane.showMessageDialog(null, "The logo is already added to the report");
isImageAdded= true;
}
}
if(!isImageAdded ){
getImage();
}
}
}

private void getImage(){
Image photo;
JFileChooser fc = new JFileChooser();

if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
fc.setCurrentDirectory(fc.getCurrentDirectory());
ImageIcon icon = new ImageIcon(fc.getSelectedFile().getAbsolutePath());
icon = new ImageIcon(icon.getImage());
photo = icon.getImage();

JasperDesign report=IReportManager.getInstance().getActiveReport();

if (report != null){
try {
JRDesignParameter parameter =new JRDesignParameter();
parameter.setName("photo");
parameter.setValueClass(java.lang.Object.class);
report.addParameter(parameter);

IReportManager.getInstance().saveiReportConfiguration();

JRDesignExpression expression=new JRDesignExpression();
expression.setText("$P{photo}");
expression.setValueClass(java.awt.Image.class);

JRDesignImage image = new JRDesignImage(null);
image.setY(0);
image.setWidth(photo.getWidth(fc));
image.setHeight(photo.getHeight(fc));
// image.setScaleImage(JRImage.SCALE_IMAGE_CLIP);
image.setExpression(expression);

JRDesignBand band=(JRDesignBand) report.getTitle();
band.setHeight(photo.getHeight(fc));
band.addElement(image);

IReportManager.getInstance().saveiReportConfiguration();

} catch (JRException ex) {
Exceptions.printStackTrace(ex);
}


Map param = new HashMap();
param.put("photo", photo);

try {
generateReports( report,param);
} catch (JRException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}


private void generateReports(JasperDesign report, Map param) throws JRException {

try {

if (IReportManager.getInstance().getActiveReport() != null){

JasperReport jasperReport = JasperCompileManager.compileReport(report);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, param, new JREmptyDataSource());

JasperViewer.viewReport(jasperPrint, false);
}
}
catch (JRException ex)
{Exceptions.printStackTrace(ex);
}

}



Now run the project.

The jarfile rt.jar has no source attachment

This is for people who have faced that problem when using myeclipse. Well, I'm going to give you a tip.

"the jarfile rt.jar has no source attachment" is not part of the actual error. An exception is being thrown in your programme. Eclipse is trying to show you the source code of error, But it cant find the code of relevant classes (it is possible)
Eclipse is telling you it can't provide this help. This is a seperate matter
from the actual exception itself.

So , pay your attention to more important area without worring about this. I'm telling you this from my experience :)

more info :
http://www.velocityreviews.com/forums/t151773-need-help-the-jarfile-jsr173_api-jar-has-no-source-attachment.html