Bible site application example

Displaying large data sets, filtering, real-time updates and persistence.

Filtering, content changes as database changes or is updated.


 Keyword(s)
 Phrase

[Reset Search]


Current size of list: 31

View ActionBookChapterVerse[Sortable]Bible Text[Sortable]
verse    chapter Genesis11 In the beginning God created the heaven and the earth.~
verse    chapter Genesis12 And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.~
verse    chapter Genesis13 And God said, Let there be light: and there was light.~
verse    chapter Genesis14 And God saw the light, that it was good: and God divided the light from the darkness.~
verse    chapter Genesis15 And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.~

Version:KJVBook:GenesisChapter:1, Verse:5
And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.~


This is an example of multiple grids, working independently

Bible Text[Sortable]Verse[Sortable]
In the beginning God created the heaven and the earth.~1
And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.~2
And God said, Let there be light: and there was light.~3
And God saw the light, that it was good: and God divided the light from the darkness.~4
And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.~5

Bible Text[Sortable]Verse[Sortable]
In the beginning God created the heaven and the earth.~1
And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.~2
And God said, Let there be light: and there was light.~3
And God saw the light, that it was good: and God divided the light from the darkness.~4
And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.~5

Bible Text[Sortable]Verse[Sortable]
In the beginning God created the heaven and the earth.~1
And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.~2
And God said, Let there be light: and there was light.~3
And God saw the light, that it was good: and God divided the light from the darkness.~4
And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.~5


Non-Ajax and Ajax zones

The last update occured at: Wed Aug 23 19:03:38 EDT 2017

You have clicked the link 0 times.

[increment]  

Form with validation

Username = username
Password = password
or just try null, empty string or gibberish...

:
:

How to build it...

Getting your environment up and running:

I'll try to be thorough but bear in mind the environment is up to you, i.e. your OS, DBMS and so on. I use PostgreSQL, and Tomcat because they are dependable and open source. Substitute your preferences as you see fit. I am using Oracle JDK 6 latest. I am assuming you have some sort of programming background with Java, JPA/Hibernate, and Tapestry5. And if not hope you find this usefull. I am not responsible for any accidents. ;) If you are running Windows, you could adapt the below but you are on your own. Otherwise proceed.

Tomcat 6

You could install Tomcat 7 but there have been some changes to the manager app that are not compatible with this current setup. Besides, as of now IMHO version 6 is the tried and true, battle ready version. Anything new and shiny might jam on you or cause serious injury. Up to you.

Simply download the latest version 6 from here: [Latest 6] Just stick with the tar.gz format and unzip to a local folder in your home directory. I usually put everything in one folder for simplicity.

Install the following user in the tomcat-users.xml file:

<user name="changeThis" password="changeThisToo" roles="standard,manager-script" / >

PostgreSQL

There is a guide here: [Guide] I am running Fedora at home so I just do as root...

yum install postgresql-server
service postgresql initdb
service postgresql start

Detailed instructions here: [Detailed PostgreSQL instructions for Fedora]

You will need to set the postgres user password if not done already (as root)

passwd postgres

Make sure this line is in /var/lib/pgsql/data/pg_hba.conf

local all all trust

As stated in this file, if you do not trust all your local users, then change this to something else per the wiki or the offical PostgreSQL web site here: website, especially if you are deploying to the public. The above will allow local connections (connections originating from your machine).

Create a postgresql user for connecting through Hibernate:

su postgres
psql
create role tester password 'changethis' login;

Create the database:

create database myTestDB;

Grant permissions to tester (we need all of them for now)

grant all on database myTestDB to tester;

Eclipse IDE

I usually download the J2EE version, just for completeness. You may want these plugins as well:

Installing the Eclipse Maven plugin
Installing Hibernate Tools for Eclipse

Ant

Installing Ant

Maven

Scroll down to the 'UNIX' installation instructions: Installing Maven

Ant Tasks for Maven

Just follow the simple version, installing in lib directory: Installing Ant Tasks for Maven

Environment Variables and libs

Edit your '.bash_profile' to match the below scripting (only the variables) Mine are as follows in my '.bash_profile' in the root of my home folder:

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
#EDIT FROM HERE
export JAVA_HOME=/path/to/your/java/installation
export CATALINA_HOME=/path/to/your/tomcat/installation
export MAVEN_HOME=/path/to/your/maven/installation
export ANT_HOME=/path/to/your/ant/installation
export USER_CLASSPATH=/path/to/your/lib/directory
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$MAVEN_HOME/bin:$CATALINA_HOME/bin:$PATH
export PATH
#TO HERE

Now copy catalina-ant.jar, tomcat-coyote.jar, and tomcat-util.jar, to a lib directory you will specify later in the build.xml script. Either way these files need to be in your classpath in order to run the undeploy and deploy utilities. These files are in the tomcat installation directory in the lib folder. *Remember to specify the location above in the USER_CLASSPATH variable, and in the the build script.

Down to business, build a skeleton project with Maven

This will setup a working Tapestry project wherever you run the following: Tapestry Project Setup
If you'll notice you specify a group id(package) and artifact id(project name). Mine are 'com.jupra.home' and 'home' respectively. Use these or substitute your own. You might want to stick with com.example.app and app. Optionally use the Ant build script below to undeploy and deploy instead of Jetty. As an alternative I use Ant for building and deploys since Tomcat will sometimes have issues with hot deploys. As a rule of thumb if deploying to the public, always do a cold deploy i.e. undeploy, shutdown, startup, then deploy, which is what this script does(undeploy and deploy).

For building and re-deploy use the following build script. The script runs a utility for connecting to tomcat manager and undeploying/deploying your project. It needs the files mentioned above under environment variables and libs. If these are in your classpath then you are ready to run the script. This script is placed in the root of your maven project directory.

[ Build.xml ]

Import the project into Eclipse

Open up eclipse, then import the project as a Maven project.
File : Import : Existing Maven Projects, use the defaults.

Loading dependencies in your pom.xml file

You will need the following dependencies present in your pom.xml

Creating the hibernate entity classes

For learning to use hibernate, I highly recommend the following book:
Harnessing Hibernate The following are the entity classes you will need:

These go into the com.example.app.entites package. Tapestry expects the entities package to contain your O/R classes. Create a com.example.app.entities package. Do not move the packages around. This might break your project. Always keep the base layout intact and only place components in components, entities in entities, etc.. This is called coding by convention verses configuration (i.e. Spring) wiring, verbose xml, etc..

Creating the database schema

Download the latest postgreSQL JDBC driver here. We want the JDBC4 version. Place the driver in the lib folder of your tomcat installation. When running the below command you will need the driver in your classpath. Specify this in the build.xml file under the user classpath spec. Place this file in your 'home/USER/lib' directory along with the tomcat files mentioned above under 'Environment variables and libs'.

We need a hibernate configuration file. The following comes pre-configured to use postgresql and C3P0 connection pooling: hibernate.cfg.xml. Change the username and password to the values used when creating the database login. To learn more about C3P0 go here. Download the following hibernate config file and place in the root of 'src/main/resources'. Ant expects to find this file when you run the following from the root of your project folder:

ant schema

This command creates the schema per the dialect and driver information supplied in the hibernate config file.

You should be able to open up this project in eclipse with no errors, red Xs. You should also be able to build with 'mvn clean package' and to do a deploy and undeploy with 'ant deploy' and 'ant undeploy'. The preceding command will build the database schema. Use this with caution as this is quite violent by nature. The build.xml file contains a target called 'schema'. This will connect to postgreSQL and drop any existing tables with the same name and create new ones as described in the Java mapping files. All this is explained by example and in very good detail in the 'Harnessing Hibernate' book.

Getting data into the database

The following Java code reads and parses a Bible text file containing the entire Bible in KJV format. Place this file where you can find it and edit the file location specified in the Java file. There is some hibernte stuff goin on here but it's not optimal as our relationships are 'Set' based, so adding a verse to a book more than once gets you one instance, not 2 or more. Create a sub package 'com.example.app.parse' and place it there. After the schema is created you can run this as a Java Application from eclipse by right clicking and selecting 'run as application'. Get the parser here. And the data file here. The process of importing the file into the DB takes about 2 seconds on my laptop. It should take about the same on your machine.

More tml and java files needed

The tml goes in 'src/main/resources/' under com.example.app.pages. The 'BibleAppPage.java' file goes in 'src/main/java' under com.example.app.pages. The 'DataSource' source files go in the 'com.example.app.data' package.

The idea of having a 'Bible' entity is adding more bible versions. The only problem is that they are under copyright and require special permission. If you have any questions or bug fixes, improvements, I look forward to hearing from you via the contact info link at the top.

Using Tapestry with Hibernate

More to come...