Posts

Showing posts from February, 2013

Sample applications in play

Image
The Play binary package comes with a comprehensive set of sample applications written in both Java and Scala. This is a very good place to look for code snippets and examples. Hello world This is a very basic application that demonstrates Play fundamentals: Writing controllers and actions. Routing and reverse routing. Linking to public assets. Using the template engine. Handling forms with validation. Computer database   This is a classic CRUD application, backed by a JDBC database. It demonstrates: accessing a JDBC database, using Ebean in Java and Anorm in Scala table pagination and CRUD forms integrating with a CSS framework ( Twitter Bootstrap ). Twitter Bootstrap requires a different form layout to the default layout provided by the Play 2.0 form helper, so this application also provides an example of integrating a custom form input constructor. Forms This is a dummy application presenting several typical form usages. It demon

Setting up your preferred IDE for play

Image
Working with Play is easy. You don’t even need a sophisticated IDE, because Play compiles and refreshes the modifications you make to your source files automatically, so you can easily work using a simple text editor. However, using a modern Java or Scala IDE provides cool productivity features like auto-completion, on-the-fly compilation, assisted refactoring and debugging. Eclipse Generate configuration Play provides a command to simplify Eclipse configuration. To transform a Play application into a working Eclipse project, use the eclipse command: without the source jars: [ My first application ] $ eclipse if you want to grab the available source jars (this will take longer and it’s possible a few sources might be missing): [ My first application ] $ eclipse with - source = true Note if you are using sub-projects with aggregate, you would need to set skipParents appropriately: import com . typesafe . sbteclipse . core . EclipsePlugin . EclipseKeys o

Creating a new application with play

Image
Create a new application with the play command The easiest way to create a new application is to use the play new command. $ play new myFirstApp This will ask for some information. The application name (just for display, this name will be used later in several messages). The template to use for this application. You can choose either a default Scala application or a default Java application. Note that choosing a template at this point does not imply that you can’t change language later. For example, you can create a new application using the default Java application template and start adding Scala code whenever you like. Create a new application without having Play installed You can also create a new Play application without installing Play, by using sbt. First install sbt if needed. Just create a new directory for your new application and configure your sbt build script with two additions. In project/plugins.sbt , add: // The Typesafe repository resolv

introduction play framework

Image
Installing Play Prerequisites To run the Play framework, you need JDK 6 or later . If you are using MacOS, Java is built-in. If you are using Linux, make sure to use either the Sun JDK or OpenJDK (and not gcj, which is the default Java command on many Linux distros). If you are using Windows, just download and install the latest JDK package. Note, Java 7 pre update 9 on MacOS has a bug that causes problems with futures and iteratees, including making large file uploads hang. If using Java 7 on MacOS, make sure you are using the latest version. Be sure to have the java and javac commands in the current path (you can check this by typing java -version and javac -version at the shell prompt). Download the binary package Download the latest Play binary package (take the latest official version) and extract the archive to a location where you have both read and write access. (Running play writes some files to directories within the archive, so don’t install to /o

Struts 2 Ajax drop down Example

Struts 2 has emerged as boon for developers. But the documentation available is very small. So I had decided to give a brief demonstration of the ajax used in struts 2.1.8.1 Libraries used: commons-beanutils-1.7.0.jar commons-fileupload-1.2.jar commons-logging-1.1.jar commons-logging-api-1.1.jar freemarker-2.3.8.jar struts2-core-2.1.8.1.jar struts2-dojo-plugin-2.1.8.1.jar xwork-core-2.1.6.jar In this example when u select from one drop down the other will populate accordingly. You can use it as it is or play with it. Enjoy !! index.jsp <%@ taglib prefix="s" uri="/struts-tags" %> <s:action name="ListingAction" executeResult="true"></s:action> listing.jsp <%@ taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="sx" uri="/struts-dojo-tags"%> <html> <head> <sx:head/> <title>Listing</title> </head> <script&

Connect Multiple Database using hibernate

1.Create 2 hibernate config xml for each database connection here i have 2 database studentDetails and Collages the hibernate config xml files are given below collage.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property> <property name="hibernate.connection.driver_class">org.postgresql.Driver</property> <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/collageDetails</property> <property name="hibernate.connection.username">postgres</property> <property name="hi