Friday, July 3, 2015

TypeError: $(…).datepicker is not a function

Usually this type of error will come whenever you are using jquery in your application.

The root cause of this error is ” Adding multiple versions of jquery library to your application“.

So, the solution to the above problem is “Remove multiple versions of jquery library”.

Note:  Sometimes you will be surprised like, you added some version  library like 1.8 in your jsp, html…etc.

but still you are getting this error, because if you are using any existing template the basic jsp/html is already loaded with other version of jquery.

So, try to look at the template related jsp/html pages carefully.

If you are using Mozilla firefox add Firebug extension to your browser. After adding activate firebug and try to refresh the page where you are getting this error, then firebug will show you which version of jquery library your jps/html page is accessing.

Locate that version , and either remove that version of jquery library, or your page jquery  library.




Display some part of text in bold and some part in italic in SWT

Let’s say if you want to display a message to the user, in that message some part will be in bold, some part will be italic, etc.

Now I will show you how to achieve this, have a look at the class

public class BoldTextMessageDialog extends Dialog {

private Composite container;
private String firstSring;
private String secondString;
private String boldString;
private Button restoreButton;
private Button cancelButton;

public BoldTextMessageDialog(Shell shell, String firstString, String secondString, String boldString) {
super(shell);
this.firstSring = firstString;
this.secondString = secondString;
this.boldString = boldString;
}

@Override
protected Control createDialogArea(Composite parent) {

container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);

gd.heightHint = 300;
gd.widthHint = 500;
container.setLayoutData(gd);

FormData fd = null;

final Label warningLabel = new Label(container, SWT.NONE);
warningLabel.setImage(Display.getCurrent().getSystemImage(SWT.ICON_WARNING));

fd = new FormData();
fd.left = new FormAttachment(0, 5);
fd.top = new FormAttachment(0, 5);
warningLabel.setLayoutData(fd);

fd = new FormData();
fd.left = new FormAttachment(warningLabel, 10);
fd.right = new FormAttachment(100, 0);
fd.top = new FormAttachment(0, 10);

final StringBuffer buffer = new StringBuffer();
buffer.append(firstSring).append(” “);
buffer.append(boldString).append(” “);
buffer.append(secondString);

final StyledText text = new StyledText(container, SWT.WRAP | SWT.READ_ONLY);

text.setText(buffer.toString());
text.setLayoutData(fd);
text.setBackground(GUIResourceManager
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

final StyleRange styleRange = new StyleRange(firstSring.length(), boldString.length() + 1, null, null, SWT.BOLD);
text.setStyleRanges(new StyleRange[] { styleRange });
return parent;
}

}

Here Dialog is the Parent class in SWT. which has some predefined methods , now I no need to explain it.

Our main part is create dialog area method, in that method

first interesting class is StyledText, second  StyleRange class,

StyledText is framework class, which is used to style the SWT widgets

StyleRange is also framework class, by using this object we can customize the style of our SWT widget.

If you observe above code, for the style range object I am passing that starting index for the bold text as last lenght of the first string, and end index as end of bold string +1.

So, in the middle Bold text will be displayed.

Clarification about “int” number that begins with Zero in java

public class Test {

    public static void main(String[] args) {

        int i = 012;
        System.out.println(i);
    }
}


It will print 10. but why?


the trick is "If a number starts with 0 it's an octal number with base 8. 012 is in decimal a 10"

Convert normal passport application to tatkal application


Hi, We can convert our normal passport application to tatkal application.
But this is not a standard process it depends on passport officer.This information is based on my past experience.

To convert normal application to tatkal application we have to visit R.P.O, and we have to request them. Before going to RPO (Regional passport Office) make sure that,

1. Your police verification should be completed successfully.

2.  Urgency proof. It depends on type of urgency like for S/W employees  urgency letter from employer, flight tickets,  GRE exam hall ticket, etc. The proof should clearly indicate that you need passport urgently.

3. Invitation letter from your client if you are employed.

4. Letter from you.

Actually there is no standard for these letters, write your own way so that by reading your letter they should know that you need passport urgently.I applied for passport on 6th June 2014, till October 2014 I did not get my passport.

On 3rd November 2014 I have to travel Germany on behalf of my company.So, I went to Regional Passport office Hyderabad on 24th October 2014. I stood in Q, took a token and went to "A" counter.

Where a lady was there, I asked her that, "is there any provision to convert normal application to tatkal application?". She told me that it depends on urgency , if there is an urgency Assistant passport officer(A.P.O),  Deputy Passport officer (D.P.O), or Regional Passport officer(R.P.O) can convert to tatkal application. Their decision is final. She asked me to submit a proof of urgency.

Then I submitted three letters
1. Urgency letter from my  employer.
2. Original Invitation letter from my client.(German).In your case submit your urgency proof.
3. A letter from me, requesting  R.P.O to expedite process of issuing passport.

She checked three letters thoroughly and write some thing on my letter and asked me to meet D.P.O. I went to D.P.O cabin.

When I reached his cabin, he was not there. Waited for 1 hour. Then he came. 

While he was coming its like a hero entrance in movies :), two police men before and after him. In the middle he(Deputy passport officer) was there.

After that  a lady was there I think she is the attender. She  asked me to go inside to cabin. DPO asked me all my details, and last but not least

why do you need passport urgently?..

I explained him clearly, I have to travel Germany on 3rd November 2014 prior to  that I have to complete VISA process also.

He also checked all my letters. He wrote some thing on my letter ans asked me give these letters to his P.A and told me that " With in one day you will get passport".

I was shocked, and  asked him did you convert my application to tatkal application, he replied me that, as you applied for passport long back no need to convert.

In case if it is not applied long back then you have to pay around 2K to 3k , then they will process your application in tatkal mode.

I was wondered , from last 4-5 months I was trying to get passport, he told me that I will get passport with in one day, so  again I asked him, did you convert my application to tatkal application, he was irritated and told me with smile on his face how many times I have to tell you , what did you study?.... First leave cabin.
I left office, on the next day received my passport :) :)