Sunday, August 2, 2009

Icon Finder

“Iconfinder provides high quality icons for webdesigners and developers in an easy and efficient way”

this is icon's search engine, that very useful for desaigner.
Website : http://www.iconfinder.net/


Tuesday, July 14, 2009

Simple Shoutbox Ajax with JQuery & JSP

In this article, I will write about Simple Shoutbox Application with JQuery. With Ajax (Asynchronous JavaScript and XML) , we can send a form submission and get response back without refreshing current page. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.


Javascript Code :


$(function() {
$(".submit").click(function() {
var name = $("#name").val();
var comment = $("#comment").val();
var dataString = 'name='+ name + '&comment=' + comment;

if(name=='' || comment=='')
{
alert('Please Give Valide Details');
} else {
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="img/ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>');
$.ajax({
type: "POST",
url: "ajaxshoutbox.jsp",
data: dataString,
cache: false,
success: function(html){
$("ol#update").append(html);
$("ol#update li:last").fadeIn("slow");
$("#name").val('');
$("#comment").val('');
$("#name").focus();
$("#flash").hide();
}
});
return false;
}
});
});


Explanation :

$.ajax({}) is JQuery event to call ajax request, it’s has an object of key/value pairs , that are used to initialize and handle the request.

  1. type : The type of request to make ("POST" or "GET"), default is "GET"
  2. url: The url to request
  3. data: Data to be sent to the server
  4. chace : if set to false it will force the pages that you request to not be cached by the browser
  5. success : A function to be called if the request succeeds
Soutbox.jsp
<form action="#" method="post">
<label><input type="text" name="name" id="name"/>
<span class="titles">Name</span><span class="star">*</span>
</label><br />
<label>
<textarea name="comment" id="comment"></textarea>
<span class="titles">Comment</span>
</label><br />
<input type="submit" class="submit" value=" Submit Comment " /> </form>

ajaxshoutbox.jsp
<li class="box">
<span style=" font-weight:bold">Name :</span>
<span style="font-size:16px; color:#663399;"><%= request.getParameter("name") %></span> <br />
<span style=" font-weight:bold">Comment :</span> <%= request.getParameter("comment") %>
</li>

Download Sourcecode : http://simpleshoutboxajax.googlecode.com/files/SimpleShoutboxAjax-JQuery.zip

Tuesday, June 23, 2009

Accessing SQL Server Stored Procedure With Hibernate

In my previous project, I will be required to call Stored Procedure in SQL Server with Spring & Hibernate. Using HibernateTemplate class extends from HibernateDaoSupport, you can call the stored procedure in SQL Server.

The Stored Procedure:


USE [sample];
GO
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
ALTER PROCEDURE [SP_Sample]
(@Param1 nvarchar(50), @Param2 nvarchar(50))
AS
declare @Concatenation nvarchar(150)

set @Concatenation = @Param1 + ' and ' + @Param2

select @Param1,@Param2,@Concatenation
GO
SampleDao Source:

public class SampleDao extends HibernateDaoSupport {

@SuppressWarnings("unchecked")
public String callSP(String param1, String Param2) {
// create session from active session
Session ses = getSession(true);

// create query for call the stored procedure
SQLQuery q = ses.createSQLQuery("exec SP_Sample :param1, :param2");
q.setString("param1", param1);
q.setString("param2", param2);

//execute stored procedure and get list result
List l = q.list();
StringBuilder result = new StringBuilder();

if (l.size()>0){
for(Iterator it=l.iterator();it.hasNext();){
Object[] row = (Object[]) it.next();
result.append("Param 1 : " + row[0] + ", Param 2 : " + row[1] + ", Concatenation : " + row[2]);
}
}

return result.toString();
}

Tuesday, November 4, 2008

Bisa tuker uang 50 ribuan euy ke pengemis...

waktu makan di warteg deket kantor, yang notabennya tempat makan karyawan-karyawan deket kantorku. gak sengaja ngeliat keluar ada orang yang nanya ke pengemis sembari bawa duit 50 ribuan. Secara gak sengaja letak pengemis dan orang yang mau nukarin uang tadi pas di belakangku. nah iniliah transaksi kedua orang tu


ternyata, pengemis jakarta penghasilannya juga lumayan ya...

Older Posts