Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Wednesday, April 24, 2013

Creating a spring project using maven appfuse-basic-spring archetype

In my previous post about using spring security using a users database, I used a sample project which you get when downloading the spring security library. In this post, I will be setting up a spring project using maven appfuse-basic-spring archetype from scratch.

Saturday, December 3, 2011

Refresh image after upload in Primefaces - JSF 2.0

Yesterday I was trying to create a page where the user attach an image to an article and I wanted him to see what image he is attaching before saving the form. I was facing a huge problem which was that the image was only refreshing the first time the user uploads an image, but the second time nothing happens. I am using Primefaces 2.2.


To solve this I did the following:

  1. Stored the image in a session attribute within the fileUploadListener
  2. Retrieved the image inside a servlet and cleared the session attribute
  3. added a javascript within a primefaces outputpanel that changes the image source to the servlet path and added a date parameter to insure that the request will be done everytime this script is run
  4. added an update attribute to the fileupload component which updates the outputpanel created in step 3.

Check the following source for more details

Thursday, November 24, 2011

Creating a database login screen using Primefaces and Hibernate

In this tutorial I will be creating a simple JSF login screen based on a database table. The final result will be a login form in which the user enters his username/password and it will redirect him to the home page or will show him a message indicating an invalid username/password or if his status is inactive.
In order to complete this tutorial you will need to complete those two tutorials, note that you will need to create both projects in the same workspace.

Tuesday, November 22, 2011

Setting up Hibernate with an eclipse JPA project



In this tutorial I will be creating a sample JPA application from scratch in which we will create a single entity representing a user.

We will need to have the following available:

  1. Eclipse IDE for Java EE developers, which can be downloaded from eclipse download page , I am using Indigo.
  2. hibernate-distribution-3.6.7.Final-dist which can be downloaded from hibernate download page.
  3. Oracle or Oracle XE installation. Oracle XE can be downloaded from oracle xe download page.
  4. SLF4J can be downloaded from slf4j download page.
  5. Create a folder in d:\workspaces and name it hibernate_lib, place the following files inside of it:
  • The two jars hibernate3.jar,hibernate-jpa-2.0-api-1.0.1.Final.jar which can be found in the hibernate distribution.
  • antlr-2.7.6.jar, commons-collections-3.1.jar,dom4j-1.6.1.jar,javaassist-3.12.0.GA.jar, jta-1.1.jar, and slf4j-api-1.6.1.jar. Those files can be found inside the HIBERNATE_DISTRIBUTION/lib/required
  • ojdbc4.jar which can be found in ORACLE_XE_HOME\app\oracle\product\10.2.0\server\jdbc\lib
  • slf4j-simple-1.6.2.jar from the SLF4J distribution.


Friday, November 18, 2011

Setting up Primefaces with an eclipse dynamic web project

In this tutorial I will write about how to setup Primefaces with eclipse IDE. You will need to have the following available:


  1. Eclipse IDE for Java EE developers, which can be downloaded from eclipse website , I am using Indigo.
  2. JBoss Tools for creating and editing xhtml files. This is the JBoss tools update sites, you can just install JBoss tools richfaces.
  3. Primefaces 2.2.1 bundle, which can be downloaded from Primefaces website.
  4. Tomcat 7, which can be downloaded from Apache website.
  5. JSF 2.1.3 jar files can be downloaded from Java.net.
  6. el api 2.2 can be downloaded from here.
  7. el impl 2.2 can be downloaded from here.