Last modified by Andreas Hahn on 2011/05/30 17:06

Here we define all the necessary resources for the project.
This is a typical spring project setup and its listed here for completeness.

Most of these settings already come with the default project however we need to fill in some templates:

Database settings

In config/ you need to fill in your local database settings
Complete database name, username, password and the schema you'll use
(The postgres default schema is 'public' but for larger projects you should maintain a schema lifecycle)



Application context

In WEB-INF/applicationContext.xml the most basic application setup is defined.
This is an excerpt from the predefined applicationContext.xml you need to adopt if you are integrating shept into your existing spring application:

<bean id="messageSource"
   <property name="basenames">

<!-- edit this to match your projects dao -->
<bean id="dao" class="com.exampledomain.orm.dao.YourProjectDao">
   <property name="sessionFactory" ref="sessionFactory"/>

<!-- keep this default -->
<bean id="pageHolderFactory" parent="sheptPageHolderFactoryTemplate" />

In the messageSource section the predefined messages from the shept.jar are made available to the application.
You need to define a simple data access object. See complete applicationContext.xml here.


The WEB-INF/sheptDemo-servlet.xml is the spring configuration for the application web pages. Here we define the urls for the application and general setup for all our pages. Let's start with the general setup:

<bean id="bindingInitializer" parent="sheptBindingInitializerTemplate">
<property name="customEditorsForType">
<entry key="byte[]" value-ref="multipartFileEditor" />
<property name="dateTimeFormat" value="DATE_FORMAT_SHORT" />
<property name="formatResolver" ref="localeFormatResolver" />

<!-- This is the parent controller of all components -->
<bean id="sheptController" abstract="true" parent="sheptControllerTemplate">
<property name="webBindingInitializer" ref="bindingInitializer" />

We define our project specific sheptController - the controller instances that handles a single url. We will use this definition as a template for concrete instantiation for each of the urls we define hence the abstract="true" attribute. The interesting part is the webBindingInitializer which provide general application-wide default settings. We install DATE_FORMAT_SHORT (see i18n.xml) as a default dateTimeFormat which means that the internationalized date part is the default timeDate for calendar data entry fields.  The i18n.xml settings are useful if you want to specify symbolic names for locale specific data formats and your forms shall reflect locale changes for form data entry, most frequently used for time and date format specification but not limited to that. All bindings can be overridden by individual segment configuration.

This is the bean definition for the address-page:

<bean name="/address.shept" parent="sheptController">
<property name="configuration">
<bean parent="sheptTarget">
<property name="to" ref="addresses" />
<property name="filterClass" value="org.shept.apps.demo.web.controller.filters.AddressFilter" />

The address-segment is configured inside a sheptController with a reference to the address segment definition in segments.xml. The AddressFilter defines a filter that suppresses new rows. A new address can only be defined for an existing person instance. We will do that later in our example when we configure the chain from Person to Address.

See the complete file sheptDemo-servlet.xml attached.


WEB-INF/web.xml contains the setup for the web application container.


In the contextConfigLocation section all the config files of our app are listed. Note the classpath:org/shept/resources/xml/shept.xml statement that includes the setup for the shept.jar. The content of chains.xml will be explained in the next section. If you want to have your urls available under a different suffix than *.shept you need to find and replace all occurrences and replace them by your choice. You also need to change the page bean names in sheptDemo-servlet.xml to the new value (e.g. change /address.shept to /address.html).
See the full web.xml

<< Create Address Subform   Create Person Subform >>

Created by Andreas Hahn on 2010/12/16 11:23

© 2011 - Andreas Hahn