Posts

Showing posts from 2010

Vaadin SuggestionTextField

This is my first vaadin widget and very first exposure to Vaadin widgets. Earlier I was thinking that Vaading widgetset are very difficult to implement since it uses the GWT as a bottom layer. All of a sudden i got a new requirement to build  suggestion text field that would populate the suggestion list depend on the user key in. Even though Vaadin "Select" has the filtering mode but it doesn't support to get the user key in events and implement the list according to that. I have done some RnD work and decide to build a new Suggestion Text field component since its not available in Vaadin add-ons as well. Vaadin Widget has two main parts one part for server side and other one for client side, client side component it has to implement using GWT basic layer component which will ultimately generate the javascript and transfer that to client side. With this new Vaadin add-on developers can easily integrate this widget set as following Import the jar file to classpath...

PostgreSQL bytea and oid

I came across with following issue when i'm trying to save the uploaded file in to the database as a byte array using hibernate, JPA 2.0  annotation with Postgre SQL. even though in this stage i'm pretty much new to Postgre SQL, It has two type of data types to represent the binary data or BLOB, since i'm using hibernate jpa annotations use the annotation @Lob to indicate the byte[] of data to persist as a binary data. @Lob   @Basic(fetch = FetchType.LAZY)  public byte[] getPicture() { return picture;  }    exception : java.sql.SQLException: ERROR: column "picture" is of type bytea but expression is of type oid   Then i understood the issue with the data types.but when the hibernate generating the table it creates the  column with data type "oid" , after removing this annotation it creates a table column with "bytea" data type. and i'm in doubt which would be the most suitable data type to use.   Then i found the difference...

Add Captcha to Application

When i'm searching for a Captcha API written in java to embedded with my vaadin application, i have found out SimpleCaptcha SimpleCaptcha is a framework used in generating CAPTCHA image/answer pairs for Java (J2EE, Grails, JavaFX, etc.). It is intended to be simple to implement and provide sensible defaults, while having the ability to be customized in a wide variety of ways. Example implementations are provided in Java/J2EE and Grails. Apply the simple captcha is a two step process. Captcha captcha = new Captcha . Builder ( 200 , 50 ) .addText() .addBackground() .addNoise() .gimp() .addBorder() .build();  above line would create captch image and this captcha object has  the image and the answer. now you can apply this in anywhere you need in your application. Link : http://simplecaptcha.sourceforge.net/       JCAPTCHA Stands for J ava C ompletely A utomated P ublic T ...

Open Source NoSQL Databases

NoSQL has started as an alternative to the relational databases. Scalability has become the biggest motivation factor behind the NoSQL. Usually releational databases do not support well to the kind of horizontal scalbility that's required for large-scale social networks or cloud applications. NoSQL is a movement that aims to re-examine the way we structure data and draw attention to innovation in hopes to finding the solution to the next generation's data persistance problems. Reference and more detail please visit : NoSQL

Hibernate Exception - Simultaneously Fetch Multiple Bags

Hibernate Exception - Simultaneously Fetch Multiple Bags One of my customers has just upgraded to JBoss 4.0.4-GA, the process also required us to upgrade Hibernate products to the following versions: Hibernate core – 3.2.0CR2 Hibernate Entity Manager – 3.2.0CR1 Hibernate annotations- 3.2.0CR1 We fixed some minor changes and improvements and then we bumped into the following exception  javax.persistence.PersistenceException: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) So what is the problem? When an entity has more than one non-lazy association that might be interpreted as a bag (e.g., java.util.List or java.util.Collection properties annotated with @org.hibernate.annotations.CollectionOfElements or @OneToMany or @ManyToMany and not ...

Vaadin And Spring Integration

This is my documentation for the steps that i have followed to integrate the Spring with the Vaadin. web.xml changes So first we need to add the Spring Context listener to load the bean configuration file. <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> Add the Spring Servlet to intercept Vaadin requests   <servlet> <servlet-name>VaadinSpringServlet</servlet-name> <servlet-class>com.dhaval.web.vaadin.spring.servlet.SpringApplicationServlet</servlet-class> <init-param> <param-name>applicationBean</param-name> <param-value>testApplication</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name...

Installing Spring Tool Suite (STS) under Eclipse 3.5 Galileo

Firstly you need to install Eclipse 3.5 Galileo, then once that’s up and running you can use the Spring update site to install the Spring Tool Suite (STS). Follow these simple step-by-step instructions. I’m assuming that you are the only Java developer using this machine. 1. Go to http://www.eclipse.org/downloads/ 2. Follow the link for Eclipse IDE for Java EE Developers (189 MB) for Windows. 3. Select a mirror and download the file. 4. Create a folder called c:\java. 5. Move the Eclipse archive (eclipse-jee-galileo-win32.zip) into c:\java and extract here. 6. Folder c:\java\eclipse will be created. 7. Drag the executable eclipse.exe on to the desktop (or quick launch) and make a shortcut. 8. The workspace dialogue will pop up and ask you where you would like to keep your workspace. Spaces in file names (or directories) are always a bad idea especially when developing under a Windows environment which is why I don’t accept the default workspace location...

OpenLDAP installation and configuration.

In the openLDAP installation and configuration README I followed they were asked to install the latest version of Berkely DB. At the moment I was installing it was 4.8.26 but after installing it I was unable to up the server. [ ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1) ] error was appeared. Finally I found the reason and it worked for me. In the LDAP release notes it is stated that the most stable version of Berkely DB for openldap_2.4.21 is db-4.7.25. Then I install this version and reconfigure the LDAP server. It worked fine. Here are the full steps that I have followed. I installed it on top of the SSL. Installing Berkely db-4.7.25. Download the compatible version (for your particular LDAP version) of Berkeley DB f rom http://www.sleepycat.com/download/index.shtml gzip -d db-4.7.25.tar.gz tar xvf db-4.7.25.tar cd db-4.7.25 ../dist/configure –prefix=/usr/local/ make make install Installing TSL(I install openSSL) Dow...

Spring 3.0 Article

I have found the following slide show a spring 3.0 is very much interesting and explain most of the features it has in new release. http://www.slideshare.net/sbrannen/whats-new-in-spring-30-2560016 What's New in Spring 3.0 View more presentations from Sam Brannen .

Send SMS via email

Following will lead to send sms for international careers via email. Most of mobile carriers offer free Email To SMS gateways which can be used to forward simple text emails to a mobile phones. And the good news, majority of those gateways are free and available to the general public. You just need to know the number and the carrier of the recipient to start emailing them to mobile phone. Below we put together a table listing free email to SMS gateways for different carriers. You can use as quick reference both for US and international mobile numbers. Free Email To SMS Gateways (Major US Carriers) Carrier Email to SMS Gateway Alltel [10-digit phone number]@message.alltel.com Example: 1234567890@message.alltel.com AT&T (formerly Cingular) [10-digit phone number]@txt.att.net [10-digit phone number]@mms.att.net (MMS) [10-digit phone number]@cingularme.com Example: 1234567890@txt.att.net Boost Mobile [10-digit phone number]@myboostmobile.com Example: 123456...

Photo Compression Tool For Linux

Following is A good quality photo compression tool can able to compress photos as batch. It supports many difference image formats. Phatch is a simple to use cross-platform GUI Photo Batch Processor which handles all popular image formats and can duplicate (sub)folder hierarchies. Phatch can batch resize, rotate, apply perspective, shadows, rounded corners, ... and more in minutes instead of hours or days if you do it manually. Phatch allows you to use EXIF and IPTC tags for renaming and data stamping. Phatch also supports a console version to batch photos on webservers. PHATCH = photo + Batch http://photobatch.stani.be/download/index.html ubuntu installation : apt-get install phatch Getting start http://photobatch.wikidot.com/getting-started

Ajax with Jquery

Following is simple example code can be use to send the ajax requests using JQuery. Sending Ajax request with JQuery is much more easier than can apply more user friendly messages to user $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); http://docs.jquery.com/Ajax/jQuery.ajax Note : In IE browsers it convert and process the XML response string as Text prevent that can use as following $.ajax({ url: "data.xml", dataType: ($.browser.msie) ? "text" : "xml", success: function(data){ var xml; if (typeof data == "string") { xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = false; xml.loadXML(data); } else { xml = data; } // Returned data available in object "xml" } There are much more options can be specified in aja...