Mock tests, Interview questions, Tutorials and Tech news
 
 

Archive

Archive for July, 2009

Rating a page by selecting stars – Using Javascript and Ajax

July 31st, 2009 smitha No comments

      I am working on an application, where I had to catch the user response for rating a page. User selects some stars (out of 5) and then clicks on it to rate. The user’s response must be recorded when he clicks on the star.

As I am working on JSF, I searched for some components like this. There are many Richfaces components available for users with very much customized features. But I didn’t find any rating component. I didn’t have had much time to develop one component for this myself. My first choice was to use JavaScript and Ajax to record the response.

The design is to collect user input and use an Ajax call to send this response to a Servlet, which will record the rating. Also I had to avoid multiple rating by same client. JavaScript part is to capture user response and create effect of selecting a star. When user moves mouse over the starts, they look to be selected. For this I used 2 star images, one is plain and another is colored. Initially all plain 5 starts will be displayed.

<img src=”/images/starPlain.gif”  onmouseover=”selectStart(this.id)”  onclick=”captureStar(this.id)”   onmouseout=”deselectStar(this.id)”  id=”star1″ />

<img src=”/images/starPlain.gif”  onmouseover=”selectStart(this.id)”  onclick=”captureStar(this.id)”   onmouseout=”deselectStar(this.id)”  id=”star2″ />

…………… for all 5 starts (id is start1 , star 2 .. star 5)

Also the star images will be preloaded using JavaScript.

var plainstar = new Image();
plainstar.src = “../images/starPlain.jpg”;

var colorstar = new Image();
colorstar.src = “../images/starColored.jpg”;

Each plain start image will have a unique id, a JavaScript function to be called for mouseOver ,mouseOut and onClick events. The mouse over function will replace current and all left side star images to colored star images. Mouse Out event will replace all colored starts by plain stars.

For each <img/>, we have onmouseover=”selectStart(this.id)”. This function changes current star (which called the function) and all the starts left, to colored stars. This can be achieved using the id. For Example: 4th start id is star4. When mouse is placed on this star, we have to make all the left side stars and current star colored. Get the current star id, (star4) change current and all small number id stars (star1, star2,star3) to colored.

function selectStart (id) would be like:

if(id == “star1″)
{
document.getElementById(’star1’).src = colorstar.src;
}else if(id == ‘star2’){
document.getElementById(’star1’).src = colorstar.src;
document.getElementById(’star2’).src = colorstar.src;
}
.
.
.

Here we are replacing the current and left start by colored one.

Once user clicks on the star, we call captureStar() function. This star identifies the star on which the mouse was clicked using the id, and stored the number.

captureStar() function would be to save, selected star rating data. Below I am saving rating in a field called starCount.

if(id == “star1″)
{
starCount = 1;
}else if(id == ‘star2’){
starCount = 2;
}
.
.
.
.

Now its time to make ajax call to our servlet to record star rating. This servlet could be a simple servlet implementing service or doGet method, which reads the request parameter ’starParam’

For firefox and Netscape following code works:

var xmlhttp = new XMLHttpRequest();
var url = url to servlet

if (typeof xmlhttp == “undefined”)

alert(“XMLHttp cannot be created!”);
else
{
xmlhttp.open(“GET”, url+”starParam=”+a, true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.send(null);
}

Starring logic is done.

Hope this helps!

Jforum Integration with a Spring and JSF WebApplication

July 31st, 2009 smitha 10 comments

I am working on a web application, in which forum feature has to be integrated. Jforum  was chosen to integrate. Jforum is an open source forum implementation in Java (http://www.jforum.net ).

My Application is a spring / JSF application using mysql Db.Jforum has separate user tables and separate authentication mechanism. For integration it provides Single Sign on Facility and easy configuration. By turning ‘Single sign on’ facility on, the login and registration screens on Jforum will get disabled. The jforum searches for special attributes in session for logged user information and if the user is not present in its table it will automatically create one.All the authentication details will be handled by my application. Also I wanted to keep jforum tables in same db.

Read more…

Free SCJP Mock test for Standard Edition 6 available

July 29th, 2009 Vinay No comments

Skill-guru is pleased to announce the release of 56 questions for SCJP mock testSkill-guru is a test platform which allows users to create and publicize their tests on any subjects or topics.

SCJP 6 mock test is based on SCJP 1.6 syllabus of Sun Certified Programmer for the Java Platform, Standard Edition 6.0 (CX-310-065)

The questions on the test are original and are completely free. We had these test running under our old site etattva. Close to 6000 people had taken the test last one year. Now we heve moved the tests and the test taker database to this new site.  Here we plan to offer more tests to test takers on a variety of subjects.

The best part is that you can register your self as guru and create your own tests.

You would have to register to take the test. Please post in your comments and feedback which will help us make the test better.

So enjoy your free scjp mock test.

Update : There is one more SCJP Mock test with 125 questions and explanations added by Kalyan .

Invest $500,000, score a U.S. visa

July 28th, 2009 Vinay No comments

For all the immigrants who are coming to US on H1b,  and are waiting on long lines to get a green card, there is another option.  Forgot about getting a job in US these days. If you can get $500,000 to invest in US, you might get a green card in return. But there are some clauses. Read the news here

It is a different question that if an immigrant has $500,000 ,is he willing to take that risk or wants to spend a cushy life back in his home. Of course not an option for everyone .

Categories: Business Tags: , ,

Business Cards at Vista Print and their service

July 28th, 2009 Vinay No comments

I wanted to get business cards printed for my business. Did not find much variety at staples. Also when you walk in to their store , it is expensive to get the cards printed. Online option is good but they do not have much option.

I tried Vista print instead as they were offering pretty good deals and they had front and back side printing. They charged extra for back printing , this I came to know later but I was ok with it. I chose Custom business card on Matte finish.

They delivered in the time frame they had promised. The card quality was ok, not very good but I guess you get what you pay for. They also gave couple of offers although none were much useful.

What I did not like was they had been spamming my email ever since. Every second day I get emails form them announcing some new offer. Looks like I have no choice but to mark it as spam.

When I clicked on “If you do not want to send us offers , Click Here”, it opened a new mail message. I send the message not to send me mails.

Comes back the reply

Thank you for contacting VistaPrint, the online solution for “Best Printing, Best Price.”

We apologize for any inconvenience this may cause, but we are not able to reply to direct emails to this particular email address.

You and your business are important to us. Please contact our Customer Care department:

http://www.vistaprint.com/vp/ns/customer_care/contactus.aspx

Now that really pissed me off.  I am marking their mails as spam.

BusinessI

Categories: Business Tags: ,

SCJP Mock Test available

July 28th, 2009 Vinay 2 comments

Skill-guru is pleased to announce the release of 56 questions for SCJP mock testSkill-guru is a test platform which allows users to create and publicize their tests on any subjects.

SCJP mock test is based on SCJP 1.5 syllabus of Sun Certified Programmer for the Java Platform, Standard Edition 5.0 (CX-310-055)

The questions on the test are original and are completely free. We had these test running under our old site etattva. Close to 5000 people had taken the test last one year. Now we have moved the tests and the candidate’s database to this new site, skill-guru.  Here we plan to offer more tests to test takers on a variety of subjects.

The best part is that you can register your self as guru and create your own tests.

You would have to register to take the test. Please post in your comments and feedback which will help us make the test better.

So enjoy your free scjp mock test.

Update: This mock test is for SCJP 5. Click here for mock test of SCJP 6 mock test

Which is better : Spring’s Transaction management or EJB’s Container managed transaction

July 27th, 2009 Vinay 1 comment

I was a big fan of EJB’s CMT  (Container managed transaction) feature because it reduces the developer of complex task of managing transaction through code. One of the biggest drawback of this was that this feature could only be used with EJB’s and not ordinary Java classes.

Then came the Spring’s Transaction management feature which changed the way applications can manage transactions.  We will explore about Spring’s transactional capabilities and if they are better than EJB’s transaction

Read more…

Not enough work for 18000 freshers at Infosys

July 27th, 2009 Vinay No comments

Global downturn seems to be taking its toll on all industries. IT industries were also deeply affected by this downturn.

Companies were hoping that recession will end this year therefore most of them honored the offers given to college grads last year.

But looks like they do not have enough work for them. Infosys has doubled the training time for its 18000 freshers which were hired last year. It also assigning them to mock projects in order to give them some real time experience.

While this may not be good enough but at least it is better than sitting idle. This is not good for students  who graduated  this year and are facing a tough time in job market.

Read the complete story here

Categories: Technology Tags: ,
Get Adobe Flash playerPlugin by wpburn.com wordpress themes