<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CQ Community</title>
	<atom:link href="http://blogs.adobe.com/cqpost/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.adobe.com/cqpost</link>
	<description>Meet, ask, and follow the best in the CQ community</description>
	<lastBuildDate>Fri, 31 May 2013 07:31:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Submitting Mobile Data to Adobe CQ using a Sling Post Servlet</title>
		<link>http://scottsdigitalcommunity.blogspot.com/2013/05/submitting-mobile-data-to-adobe-cq.html</link>
		<comments>http://scottsdigitalcommunity.blogspot.com/2013/05/submitting-mobile-data-to-adobe-cq.html#comments</comments>
		<pubDate>Thu, 30 May 2013 16:42:00 +0000</pubDate>
		<dc:creator>Scott Macdonald</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Adobe AEM]]></category>
		<category><![CDATA[Adobe CQ]]></category>
		<category><![CDATA[Scott Macdonald]]></category>
		<category><![CDATA[SLING]]></category>
		<category><![CDATA[sling post servlet]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/cqpost/?guid=ed4b8189dbe1e05215b44b174a34216c</guid>
		<description><![CDATA[You can create an Adobe CQ mobile form using JQuery Mobile API and submit the data to Adobe CQ using a Sling Post Servlet. When a mobile user fills in the form and clicks the submit button, form data is submitted to Adobe CQ. &#160;However, instead of ...]]></description>
				<content:encoded><![CDATA[<em><strong> -Scott MacDonald</strong></em>

<p>You can create an Adobe CQ mobile form using JQuery Mobile API and submit the data to Adobe CQ using a Sling Post Servlet. When a mobile user fills in the form and clicks the submit button, form data is submitted to Adobe CQ.</p>

<p>...</p>

<p><strong>......</strong></p>


<p><strong><em>Read the full blog post at <a href="http://scottsdigitalcommunity.blogspot.in/2013/05/submitting-mobile-data-to-adobe-cq.html" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>]]></content:encoded>
			<wfw:commentRss>http://scottsdigitalcommunity.blogspot.com/feeds/1896011132023450611/comments/default</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing a Spring MVC project using Maven, JSTL tags, and data persistence</title>
		<link>http://scottsdigitalcommunity.blogspot.com/2013/05/developing-spring-mvc-project-using.html</link>
		<comments>http://scottsdigitalcommunity.blogspot.com/2013/05/developing-spring-mvc-project-using.html#comments</comments>
		<pubDate>Mon, 20 May 2013 00:30:00 +0000</pubDate>
		<dc:creator>Scott Macdonald</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[JSTL]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Scott Macdonald]]></category>
		<category><![CDATA[Spring MVC]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/cqpost/?guid=0222523bc0ad55f09842f0e1d9a89685</guid>
		<description><![CDATA[This&#160;<i>Scotts Digital Community&#160;</i>article falls into a general programming discussion (as opposed to an Adobe Enterprise development article) and provides details on developing a Spring MVC application that persists data. You can create this Spring MVC project by using Maven and JSTL tags. For information about Spring MVC, see <a href="http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html">http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html</a>.<br /><br /><br /><div><p>Assume, for example, that you want to create a Spring MVC project that saves, displays, and deletes customer data.</p></div>
<div><a href="http://3.bp.blogspot.com/-cONTSIn3aeo/UYgPATeyS6I/AAAAAAAAAl4/bnGiPhTNKAU/s1600/SpringCustomer2.png"><img border="0" height="358" src="http://3.bp.blogspot.com/-cONTSIn3aeo/UYgPATeyS6I/AAAAAAAAAl4/bnGiPhTNKAU/s640/SpringCustomer2.png" width="640"></a></div>
<div><p><br /></p></div>
<div><br /></div>
<div></div>
<div><span><b>A Spring MVC application that supports saving, viewing, and deleting customer data</b></span></div>
<div><br /></div>
<div>This development article guides you through how to create this Spring MVC project, including how to configure the Spring DispatcherServlet. Included in this article is the use of Spring annotations such as&#160;<span>@Autowired</span>. This annotation informs the Spring framework to use dependency injection on a constructor, class field, setter method or config method.&#160;</div>
<div><br /></div>
<div>The JavaServer Pages Standard Tag Library (JSTL) is a collection of &#160;JSP tags which uses functionality common to JSP applications. For example, using a JSTL tag, you can iterate through a data collection and display the results within a web page.&#160;</div>
<div><br /></div>
<div>To create a Spring MVC project using Maven, perform these tasks:</div>
<div>1. Setup Maven in your development environment.</div>
<div>2. Create a Maven project structure.</div>
<div>3. Convert the Maven project to a Spring MVC project.</div>
<div>4. Build the Maven project.</div>
<div>5. Deploy the Maven project to an application server (in this development environment, the project is ran on Tomcat).&#160;</div>
<div><br /></div>
<h2>SETUP MAVEN IN YOUR DEVELOPMENT ENVIRONMENT</h2>
<div>
<br />You can use Maven to build and manage Java projects. One benefit of Maven is dependency management. What does this mean? Well -- it means that Maven manages required JAR files that a Java project needs in its class path. Therefore instead of hunting through the Internet trying to find and download third-party JAR files to include in your class path, Maven will manage these dependencies for you.<br /><div><br /></div>
<div>
<div>You can download Maven 3 from the following URL:</div>
<div><br /></div>
<div><a href="http://maven.apache.org/download.html">http://maven.apache.org/download.html</a></div>
<div><br /></div>
<div>After you download and extract Maven, create an environment variable named <span>M3_HOME</span>. Assign the Maven install location to this environment variable. For example:</div>
<div><br /></div>
<div><span>C:\Programs\Apache\apache-maven-3.0.4</span></div>
<div><br /></div>
<div>You can test to determine if Maven is properly setup by entering the following command into a command prompt:</div>
<div><br /></div>
<div><span>%M3_HOME%\bin\mvn -version</span></div>
<div><br /></div>
<div>This command provides Maven and Java install details and resembles the following message:</div>
<div><br /></div>
<div><span>Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)</span></div>
<div><span>Maven home: C:\Programs\Apache\Maven\apache-maven-3.0.4</span></div>
<div><span>Java version: 1.6.0_31, vendor: Sun Microsystems Inc.</span></div>
<div><span>Java home: C:\Programs\Java64-6\jre</span></div>
<div><span>Default locale: en_US, platform encoding: Cp1252</span></div>
<div><span>OS name: &#8220;windows 7&#8221;, version: &#8220;6.1&#8221;, arch: &#8220;amd64&#8221;, family: &#8220;windows&#8221;</span></div>
</div>
<div><br /></div>
<h2>CREATE A MAVEN PROJECT STRUCTURE</h2>
<div>
<div>You can use a Maven archetype plugin to create a project. To create a Java application, you can &#160;use the maven-archetype-quickstart plugin. The following example creates a Maven Java application project in the C:\apache-maven-3.0.4\ folder.</div>
<div><br /></div>
<div>To create a Maven project structure:</div>
<div>1. Open the command prompt and go to the C:\apache-maven-3.0.4 directory.</div>
<div>2. Run the following Maven command:</div>
<div><span>mvn archetype:generate -DgroupId=com.sdc.controller -DartifactId=FirstController -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false</span></div>
</div>
<div><span><br /></span></div>
<br />You will see a Maven message similar to the following:<br /><br /><span>&#160;[INFO] Using following parameters for creating project from Old (1.x) Archetype:</span><br /><span>&#160;maven-archetype-quickstart:1.0</span><br /><span>[INFO]&#160;</span><br /><span>[INFO] Parameter: groupId, Value: com.sdc.controller</span><br /><span>[INFO] Parameter: packageName, Value: com.sdc.controller</span><br /><span>[INFO] Parameter: package, Value: com.sdc.controller</span><br /><span>[INFO] Parameter: artifactId, Value: FirstController</span><br /><span>[INFO] Parameter: basedir, Value: C:\apache-maven-3.0.4</span><br /><span>[INFO] Parameter: version, Value: 1.0-SNAPSHOT</span><br /><span>[INFO] project created from Old (1.x) Archetype in dir: C:\apache-maven-3.0.4\FirstController</span><br /><span>[INFO] BUILD SUCCESS</span><br /><span>[INFO] Total time: 3.347s</span><br /><span>[INFO] Finished at: Sun Jan 20 16:49:18 EST 2013</span><br /><span>[INFO] Final Memory: 8M/122M</span><br /><br />This Maven command produces a basic project structure that contains a POM file and basic Java class.<br /><div><a href="http://2.bp.blogspot.com/-8gROtH80nxA/UYgereypvvI/AAAAAAAAAmI/9LYhJTVGpew/s1600/Maven.png"><img border="0" height="380" src="http://2.bp.blogspot.com/-8gROtH80nxA/UYgereypvvI/AAAAAAAAAmI/9LYhJTVGpew/s400/Maven.png" width="400"></a></div>
<br /><br />The generated Maven POM file is located in the FirstController folder. Change this folder name to Customer and modify the folder structure under Customer to reflect the folder structure shown in the following illustration. Next, delete the folders under the java folder. New Java files are added in the following sections.<br /><div><a href="http://4.bp.blogspot.com/-LOVq2tqgNUk/UYgft6nrpHI/AAAAAAAAAmQ/S2InlLfJpjI/s1600/Maven2.png"><img border="0" height="223" src="http://4.bp.blogspot.com/-LOVq2tqgNUk/UYgft6nrpHI/AAAAAAAAAmQ/S2InlLfJpjI/s400/Maven2.png" width="400"></a></div>Under the java folder, create the following folder structure:&#160;java\com\springapp\mvc. These child folders correspond to the Java package named <span>com.springapp.mvc</span> that is used in this development article.<br /><h2>CONVERT THE MAVEN GENERATED PROJECT TO A SPRING MVC PROJECT</h2>
<div>
<div>The next step is to convert the generated Maven project into a Spring MVC project. This involves performing the following tasks:</div>
<div><br /></div>
<div>1. Add the Java classes to the <span>com.springapp.mvc</span> package.</div>
<div>2. Modify the POM file to include Spring MVC dependencies.</div>
<div>3. Add a data persistence XML configuration file to the resources folder. &#160;</div>
<div>3. Add a new folder named webapp to the src/main folder. This folder contains the WEB-INF folder.</div>
</div>
<h3>Add the User class&#160;</h3>
<div>Add a <span>Customer </span>class to the java\com\springapp\mvc folder that represents a Spring bean. This class uses the following annotations:</div>
<div><ul>
<li>
<b>@Entity</b> - indicates that this Spring bean is a persistent entity.&#160;</li>
<li>
<b>@GeneratedValue </b>- indicates a primary key property or field of an entity or mapped superclass in conjunction with the Id annotation.</li>
<li>
<b>@Basic</b> -&#160;<span>can be applied to a persistent property. In this example, first name, last name, and email fields are persisted.&#160;</span>
</li>
</ul></div>
<div>The following Java code represents the <span>User&#160;</span>class.&#160;</div>
<div>
<div><span>package com.springapp.mvc;</span></div>
<div><span><br /></span></div>
<div><span>import javax.persistence.*;</span></div>
<div><span><br /></span></div>
<div><span>@Entity(name = "account")</span></div>
<div><span>public class User{</span></div>
<div><span>&#160; &#160; @Id</span></div>
<div><span>&#160; &#160; @GeneratedValue(strategy = GenerationType.AUTO)</span></div>
<div><span>&#160; &#160; private Long id;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @Basic</span></div>
<div><span>&#160; &#160; private String firstName;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @Basic</span></div>
<div><span>&#160; &#160; private String lastName;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @Basic</span></div>
<div><span>&#160; &#160; private String email;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public Long getId() {</span></div>
<div><span>&#160; &#160; &#160; &#160; return id;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public void setId(Long id) {</span></div>
<div><span>&#160; &#160; &#160; &#160; this.id = id;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public String getFirstName() {</span></div>
<div><span>&#160; &#160; &#160; &#160; return firstName;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public void setFirstName(String name) {</span></div>
<div><span>&#160; &#160; &#160; &#160; this.firstName = name;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public String getLastName() {</span></div>
<div><span>&#160; &#160; &#160; &#160; return lastName;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public void setLastName(String lastName) {</span></div>
<div><span>&#160; &#160; &#160; &#160; this.lastName = lastName;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public String getEmail() {</span></div>
<div><span>&#160; &#160; &#160; &#160; return email;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; public void setEmail(String email) {</span></div>
<div><span>&#160; &#160; &#160; &#160; this.email = email;</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span>}</span></div>
</div>
<div><span><br /></span></div>
<div>
<h3>Add the UserController class&#160;</h3>
<div>Add a&#160;<span>UserController&#160;</span>class to the java\com\springapp\mvc folder that represents a Spring MVC controller. A controller &#160;is responsible for receiving requests from users and invoking services for business processing. This class contains the following annotations:</div>
<div>
<ul>
<li>
<b>@Controller</b>&#160;- indicates that this class is a MVC controller.&#160;</li>
<li>
<b>@Autowired</b>- &#160;informs the Spring framework to use dependency injection</li>
<li>
<b>@RequestMapping</b>&#160;-&#160;<span>specifies that the corresponding method is a controller&#160;</span>handler method.</li>
</ul>
<ul></ul>The following Java code represents the <span>UserController </span>class.&#160;</div>
</div>
<div><br /></div>
<div>
<div><span>package com.springapp.mvc;</span></div>
<div><span><br /></span></div>
<div><span>import org.springframework.beans.factory.annotation.Autowired;</span></div>
<div><span>import org.springframework.stereotype.Controller;</span></div>
<div><span>import org.springframework.ui.ModelMap;</span></div>
<div><span>import org.springframework.validation.BindingResult;</span></div>
<div><span>import org.springframework.web.bind.annotation.ModelAttribute;</span></div>
<div><span>import org.springframework.web.bind.annotation.PathVariable;</span></div>
<div><span>import org.springframework.web.bind.annotation.RequestMapping;</span></div>
<div><span>import org.springframework.web.bind.annotation.RequestMethod;</span></div>
<div><span><br /></span></div>
<div><span>@Controller</span></div>
<div><span>public class UserController {</span></div>
<div><span>&#160; &#160; @Autowired</span></div>
<div><span>&#160; &#160; private UserRepository userRepository;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @RequestMapping(value = "/", method = RequestMethod.GET)</span></div>
<div><span>&#160; &#160; public String listUsers(ModelMap model) {</span></div>
<div><span>&#160; &#160; &#160; &#160; model.addAttribute("user", new User());</span></div>
<div><span>&#160; &#160; &#160; &#160; model.addAttribute("users", userRepository.findAll());</span></div>
<div><span>&#160; &#160; &#160; &#160; return "users";</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @RequestMapping(value = "/add", method = RequestMethod.POST)</span></div>
<div><span>&#160; &#160; public String addUser(@ModelAttribute("user") User user, BindingResult result) {</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; userRepository.save(user);</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; return "redirect:/";</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; @RequestMapping("/delete/{userId}")</span></div>
<div><span>&#160; &#160; public String deleteUser(@PathVariable("userId") Long userId) {</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; userRepository.delete(userRepository.findOne(userId));</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; return "redirect:/";</span></div>
<div><span>&#160; &#160; }</span></div>
<div><span>}</span></div>
</div>
<div><br /></div>
<h3>Add the UserRepository class</h3>
<div>Add the&#160;UserRepository class that extends <span>org.springframework.data.jpa.repository.JpaRepository</span>. The <span>JpaRepository </span>class lets a bean of this type modify data stored in the database. &#160;</div>
<div><br /></div>
<div>The following Java code represents the&#160;<span>UserRepository </span>class.</div>
<div><br /></div>
<div>
<div><span>package com.springapp.mvc;</span></div>
<div><span><br /></span></div>
<div><span>import org.springframework.data.jpa.repository.JpaRepository;</span></div>
<div><span><br /></span></div>
<div><span>public interface UserRepository extends JpaRepository&#60;User, Long&#62; {</span></div>
<div><span>}</span></div>
</div>
<div><span><br /></span></div>
<h3><span>Modify the POM file to include Spring MVC dependencies</span></h3>
<div>
<div>Replace the POM that the Maven plug-in created with the following POM file. This new POM includes Spring dependencies that are required to use Spring MVC functionality. In addition, the dependency to use Hibernate functionality is also included.&#160;</div>
<div><br /></div>
<div>
<div><span>&#60;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</span></div>
<div><span>&#160;xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&#62;</span></div>
<div><span>&#160; &#160; &#60;modelVersion&#62;4.0.0&#60;/modelVersion&#62;</span></div>
<div><span>&#160; &#160; &#60;groupId&#62;com.springapp.mvc&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#60;artifactId&#62;Customer&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#60;packaging&#62;war&#60;/packaging&#62;</span></div>
<div><span>&#160; &#160; &#60;version&#62;1.0-SNAPSHOT&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#60;name&#62;SpringMVC Maven Webapp&#60;/name&#62;</span></div>
<div><span>&#160; &#160; &#60;url&#62;http://maven.apache.org&#60;/url&#62;</span></div>
<div><span><span> </span></span></div>
<div><span><span> </span> &#60;properties&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;spring.version&#62;3.2.0.RELEASE&#60;/spring.version&#62;</span></div>
<div><span>&#160; &#160; &#60;/properties&#62;</span></div>
<div><span><span> </span></span></div>
<div><span><span> </span></span></div>
<div><span>&#160; &#60;dependencies&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.springframework&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;spring-core&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;${spring.version}&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.springframework&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;spring-web&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;${spring.version}&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;javax.servlet&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;servlet-api&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;2.5&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;javax.servlet.jsp&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;jsp-api&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;2.1&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;scope&#62;provided&#60;/scope&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.springframework&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;spring-webmvc&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;${spring.version}&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.springframework&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;spring-test&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;${spring.version}&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;scope&#62;test&#60;/scope&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;junit&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;junit&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;4.8.2&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;scope&#62;test&#60;/scope&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;jstl&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;jstl&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;1.2&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.springframework.data&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;spring-data-jpa&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;1.2.0.RELEASE&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.hibernate.javax.persistence&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;hibernate-jpa-2.0-api&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;1.0.0.Final&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.hibernate&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;hibernate-entitymanager&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;3.6.10.Final&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.hsqldb&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;hsqldb&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;2.2.9&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;dependency&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;groupId&#62;org.json&#60;/groupId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;artifactId&#62;json&#60;/artifactId&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;version&#62;20080701&#60;/version&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/dependency&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;/dependencies&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#60;/project&#62;</span></div>
</div>
<div><br /></div>
<h3>Add a data persistence XML configuration file to the resources folder</h3>
</div>
<div>Add a data persistence XML configuration file that lets the Spring MVC application persist data into a database. In the resources folder, create a sub folder named META-INF. Add an XML file named <i>persistence.xml</i> in the META-INF folder.</div>
<div><br /></div>
<div>The following XML represents the <i>&#160;persistence.xml</i> configuration file. In this example, a HSQL database is used. Notice that values such as user name and password are specified using <span>property </span>elements. &#160;&#160;</div>
<div>
<div><br /></div>
<div><span>&#60;?xml version="1.0" encoding="UTF-8"?&#62;</span></div>
<div><span>&#60;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&#62;</span></div>
<div><span>&#160; &#160; &#60;persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;provider&#62;org.hibernate.ejb.HibernatePersistence&#60;/provider&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;properties&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.connection.url" value="jdbc:hsqldb:mem:spring" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.connection.username" value="sa" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.connection.password" value="" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;property name="hibernate.hbm2ddl.auto" value="create-drop" /&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/properties&#62;</span></div>
<div><span>&#160; &#160; &#60;/persistence-unit&#62;</span></div>
<div>&#60;/persistence&#62;</div>
</div>
<div><br /></div>
<h3>Add the webapp folder to the Maven project structure</h3>
<div>Add a new folder named webapp to the main folder. Add a subfolder named WEB-INF to the webapp folder. You add the following three files to this WEB-INF folder: web.xml, mvc-dispatcher-servlet.xml, and users.jsp (this file is located in a sub folder named pages). The users.jsp&#160;file calls the Java application logic defined within the <span>UserController </span>class.</div>
<div><br /></div>
<div>The web.xml file defines servlets for the web application (after all, a Spring MVC project is a web application). Within the web.xml file, &#160;you specify a Spring MVC servlet. A Spring MVC servlet is based on org.springframework.web.servlet.DispatcherServlet. In the following example, the name of the Spring dispatcher servlet is mvc-dispatcher.</div>
<div><br /></div>
<div>The following XML code represents the web.xml file.</div>
<div></div>
<div><span>&#60;web-app version="2.4"</span></div>
<div><span><span> </span>xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</span></div>
<div><span><span> </span>xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee&#160;</span></div>
<div><span><span> </span>http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&#62;</span></div>
<div><span><br /></span></div>
<div><span><span> </span>&#60;display-name&#62;Spring MVC Application&#60;/display-name&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;servlet&#62;</span></div>
<div><span><span>  </span>&#60;servlet-name&#62;mvc-dispatcher&#60;/servlet-name&#62;</span></div>
<div><span><span>  </span>&#60;servlet-class&#62;org.springframework.web.servlet.DispatcherServlet&#60;/servlet-class&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;load-on-startup&#62;1&#60;/load-on-startup&#62;</span></div>
<div><span><span> </span>&#60;/servlet&#62;</span></div>
<div><span><br /></span></div>
<div><span><span> </span>&#60;servlet-mapping&#62;</span></div>
<div><span><span>  </span>&#60;servlet-name&#62;mvc-dispatcher&#60;/servlet-name&#62;</span></div>
<div><span><span>  </span>&#60;url-pattern&#62;/&#60;/url-pattern&#62;</span></div>
<div><span><span> </span>&#60;/servlet-mapping&#62;</span></div>
<div><span>&#60;/web-app&#62;</span></div>
<div><span><br /></span></div>
<div>
<span>Notice the&#160;</span><span>servlet-name</span><span>&#160;element specifies </span><span>mvc-dispatcher</span><span>. This specifies the location of the mvc-dispatcher-servlet.xml. In this example, the name of the dispatcher servlet is mvc-dispatcher (this is the file that is created next).&#160;</span>
</div>
<div><span><br /></span></div>
<div>
<div>The mvc-dispatcher-servlet.xml informs the Spring framework where to find the controller (in this article, the controller is the <span>UserController &#160;</span>class. The dispatcher configuration uses the following element to specify the location of the controller:</div>
<div><br /></div>
<div><span>&#60;context:component-scan base-package="com.springapp.mvc"/&#62;</span></div>
<div><br /></div>
<div>This XML element informs the Spring framework to search the <span>com.springapp.mvc</span> package for a controller. The following XML represents the mvc-dispatcher-servlet.xml file.</div>
<div><br /></div>
<div>
<div><span>&#60;beans xmlns="http://www.springframework.org/schema/beans"</span></div>
<div><span>&#160; &#160; &#160; &#160;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</span></div>
<div><span>&#160; &#160; &#160; &#160;xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"</span></div>
<div><span>&#160; &#160; &#160; &#160;xmlns:jpa="http://www.springframework.org/schema/data/jpa"</span></div>
<div><span>&#160; &#160; &#160; &#160;xsi:schemaLocation="http://www.springframework.org/schema/beans</span></div>
<div><span>&#160; &#160; &#160; &#160; http://www.springframework.org/schema/beans/spring-beans.xsd</span></div>
<div><span>&#160; &#160; &#160; &#160; http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;context:component-scan base-package="com.springapp.mvc"/&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;property name="prefix" value="/WEB-INF/pages/"/&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;property name="suffix" value=".jsp"/&#62;</span></div>
<div><span>&#160; &#160; &#60;/bean&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;jpa:repositories base-package="com.springapp.mvc"/&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;property name="persistenceUnitName" value="defaultPersistenceUnit"/&#62;</span></div>
<div><span>&#160; &#160; &#60;/bean&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;property name="entityManagerFactory" ref="entityManagerFactory" /&#62;</span></div>
<div><span>&#160; &#160; &#60;/bean&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;tx:annotation-driven transaction-manager="transactionManager"/&#62;</span></div>
<div><span>&#60;/beans&#62;</span></div>
</div>
</div>
<div><span><br /></span></div>
<div>
<span>The last file to create is the user.jsp file. In this example, place the JSP file in a folder named pages (this is a sub-folder to WEB-INF). This JSP invokes Java methods defined in the </span><span>UserController</span><span>.</span>
</div>
<div><span><br /></span></div>
<div>
<div><span>&#60;!doctype html&#62;</span></div>
<div><span>&#60;%@taglib uri="http://www.springframework.org/tags" prefix="spring" %&#62;</span></div>
<div><span>&#60;%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %&#62;</span></div>
<div><span>&#60;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#60;html&#62;</span></div>
<div><span>&#60;head&#62;</span></div>
<div><span>&#160; &#160; &#60;meta charset="utf-8"&#62;</span></div>
<div><span>&#160; &#160; &#60;title&#62;Spring MVC Application&#60;/title&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"&#62;</span></div>
<div><span>&#160; &#160; &#60;meta name="viewport" content="width=device-width, initial-scale=1.0"&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#60;link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet"&#62;</span></div>
<div><span>&#160; &#160; &#60;link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet"&#62;</span></div>
<div><span>&#60;/head&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#60;body&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#60;div class="container"&#62;</span></div>
<div><span>&#160; &#160; &#60;div class="row"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;div class="span8 offset2"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;h1&#62;Users&#60;/h1&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;form:form method="post" action="add" commandName="user" class="form-horizontal"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="control-group"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:label cssClass="control-label" path="firstName"&#62;First Name:&#60;/form:label&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="controls"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:input path="firstName"/&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="control-group"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:label cssClass="control-label" path="lastName"&#62;Last Name:&#60;/form:label&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="controls"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:input path="lastName"/&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="control-group"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:label cssClass="control-label" path="email"&#62;Email:&#60;/form:label&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="controls"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form:input path="email"/&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="control-group"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;div class="controls"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;input type="submit" value="Add User" class="btn"/&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/form:form&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;c:if test="${!empty users}"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;h3&#62;Users&#60;/h3&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;table class="table table-bordered table-striped"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;thead&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;tr&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;th&#62;Name&#60;/th&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;th&#62;Email&#60;/th&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;th&#62;&#38;nbsp;&#60;/th&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/tr&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/thead&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;tbody&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;c:forEach items="${users}" var="user"&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;tr&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;td&#62;${user.lastName}, ${user.firstName}&#60;/td&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;td&#62;${user.email}&#60;/td&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;td&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;form action="delete/${user.id}" method="post"&#62;&#60;input type="submit" class="btn btn-danger btn-mini" value="Delete"/&#62;&#60;/form&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/td&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/tr&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/c:forEach&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/tbody&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/table&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#160; &#160; &#60;/c:if&#62;</span></div>
<div><span>&#160; &#160; &#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#160; &#160; &#60;/div&#62;</span></div>
<div><span>&#60;/div&#62;</span></div>
<div><span><br /></span></div>
<div><span>&#60;/body&#62;</span></div>
<div><span>&#60;/html&#62;</span></div>
</div>
<div><span><br /></span></div>
<div>
<span>In this example, notice that&#160;</span>JSTL tags are used. In this example, for each user in the database, a new table HTML table row is created and the user.lastName and user.FirstName methods (defined in the User class) are invoked.&#160;</div>
<div><br /></div>
<div>Each row also has a button defined by this HTML tag: input type="submit". &#160;When clicked, notice that the <span>delete </span>method defined in the <span>UserController</span> class is invoked. This deletes the user record from the database.&#160;</div>
<div><br /></div>
<div>Finally a new user is added to the database by clicking the Add User button. When the Add User button is clicked, the <span>addUser </span>method located in the <span>UserController </span>is invoked.&#160;</div>
<div><br /></div>
<div>
<div><span>@RequestMapping(value = "/add", method = RequestMethod.POST)</span></div>
<div><span>&#160; &#160; public String addUser(@ModelAttribute("user") User user, BindingResult result) {</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; userRepository.save(user);</span></div>
<div><span><br /></span></div>
<div><span>&#160; &#160; &#160; &#160; return "redirect:/";</span></div>
<div><span>&#160; &#160; }</span></div>
</div>
<div><span><br /></span></div>
<h2><span>BUILD THE MAVEN PROJECT</span></h2>
<div>
<div>
<span>After you convert the generated Maven project to a Spring MVC project, you can build the artifact by using Maven. The artifact that is built is a WAR file, as specified in the POM file. In this example, the </span><span>packaging </span><span>element in the POM file specifies war:</span>
</div>
<div><br /></div>
</div>
<div>
<div>&#60;modelVersion&#62;4.0.0&#60;/modelVersion&#62;</div>
<div>&#60;groupId&#62;com.springapp.mvc&#60;/groupId&#62;</div>
<div>&#60;artifactId&#62;Customer&#60;/artifactId&#62;</div>
<div>&#60;packaging&#62;war&#60;/packaging&#62;</div>
<div>&#60;version&#62;1.0-SNAPSHOT&#60;/version&#62;</div>
<div>&#60;name&#62;SpringMVC Maven Webapp&#60;/name&#62;</div>
<div>&#60;url&#62;http://maven.apache.org&#60;/url&#62;</div>
<div><br /></div>
<div>
<span>To create the&#160;</span>artifact&#160;<span>by running Maven, perform these steps:</span><br /><span>1.Start the Command Prompt.</span><br /><span>2. Change the directory to the location of POM file.</span><br /><span>3. Enter the following command: %M3_HOME%\bin\mvn clean package.</span><br /><span>4. The WAR file is placed in the target directory. In this example, the WAR file is named&#160;</span>Customer-1.0-SNAPSHOT.war<span>.</span><br /><span><br /></span><br /><h2>DEPLOY THE WAR FILE TO TOMCAT</h2>
</div>
</div>
<div>Deploy the WAR file that was built in the previous step by placing it in the Tomcat\webapps folder. Restart Tomcat. Once Tomcat is started, you can view the Spring MVC application by entering the following URL:</div>
<div><br /></div>
<div><span>http://[server name]:[port]/Customer-1.0-SNAPSHOT/</span></div>
<div><span><br /></span></div>
<span>The following illustration shows the Spring MVC application in a web browser.&#160;</span><br /><div><a href="http://2.bp.blogspot.com/-3HMnvx5Ayvk/UYg3le8Ve7I/AAAAAAAAAmg/o-UutqzXtyk/s1600/Maven33.png"><img border="0" height="248" src="http://2.bp.blogspot.com/-3HMnvx5Ayvk/UYg3le8Ve7I/AAAAAAAAAmg/o-UutqzXtyk/s640/Maven33.png" width="640"></a></div>
<br /><h2>CONCLUSION</h2>This article walked you through how to set-up a Spring MVC project using Maven and highlighted how the dispatcher, controller and view work together. Once you understand this, you can start to work on more complex Spring MVC applications.<br /><br /><h2>ABOUT THE AUTHOR</h2>I (Scott Macdonald) am a Senior Digital Marketing Content and Community &#160;lead at Adobe Systems with over 16 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If &#160;you would like to see more CQ or other Adobe Digital Marketing end to end walkthroughs like this, then leave a comment and let me know what content you would like to see.<br /><br /><br /><br />
</div>
]]></description>
				<content:encoded><![CDATA[<em><strong> -Scott MacDonald</strong></em>

<p>Scotts Digital Community article falls into a general programming discussion (as opposed to an Adobe Enterprise development article) and provides details on developing a Spring MVC application that persists data.</p>

<p>....</p>

<p><strong>.......</strong></p>


<p><strong><em>Read the full blog post at <a href="http://scottsdigitalcommunity.blogspot.in/2013/05/developing-spring-mvc-project-using.html" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>


]]></content:encoded>
			<wfw:commentRss>http://scottsdigitalcommunity.blogspot.com/feeds/3081701618993881433/comments/default</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AEM5.6: Socoadmin: reply button and refresh issues in moderation UI</title>
		<link>http://blogs.adobe.com/dmcmahon/2013/04/23/aem5-6-socoadmin-reply-button-and-refresh-issues-in-moderation-ui/</link>
		<comments>http://blogs.adobe.com/dmcmahon/2013/04/23/aem5-6-socoadmin-reply-button-and-refresh-issues-in-moderation-ui/#comments</comments>
		<pubDate>Mon, 13 May 2013 00:15:35 +0000</pubDate>
		<dc:creator>dmcmahon</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Adobe AEM]]></category>
		<category><![CDATA[Adobe AEM 5.6]]></category>
		<category><![CDATA[AEM 5.6]]></category>
		<category><![CDATA[David McMahon]]></category>
		<category><![CDATA[refresh]]></category>
		<category><![CDATA[reply]]></category>
		<category><![CDATA[socoadmin]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/dmcmahon/?p=1772</guid>
		<description><![CDATA[Issue If you are using the classic UI (/socoadmin) for social moderation in AEM5.6, you may notice some strange behaviour as follows Reply button disabled 1) Go to http://localhost:4502/socoadmin 2) Select a blog comment from Geometrixx Result: reply button is &#8230; <a href="http://blogs.adobe.com/dmcmahon/2013/04/23/aem5-6-socoadmin-reply-button-and-refresh-issues-in-moderation-ui/">Continue reading <span>&#8594;</span></a>
]]></description>
				<content:encoded><![CDATA[<em><strong> - David McMahon</strong></em>

<p><strong>Issue</strong></p>
<p>If you are using the classic UI (/socoadmin) for social moderation in AEM5.6, you may notice some strange behaviour as follows</p>
<div>
<p>Reply button disabled<br />
1) Go to <a title="Follow link" href="http://localhost:4502/socoadmin">http://localhost:4502/socoadmin</a><br />
2) Select a blog comment from Geometrixx</p>

<p>...</p>
<p><strong>........</strong></p>

<p><strong><em>Read the full blog post at <a href="http://blogs.adobe.com/dmcmahon/2013/04/23/aem5-6-socoadmin-reply-button-and-refresh-issues-in-moderation-ui/" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>

]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/dmcmahon/2013/04/23/aem5-6-socoadmin-reply-button-and-refresh-issues-in-moderation-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom CQ5 workflow step that integrates Twitter and Jabber</title>
		<link>http://dev.day.com/microsling/content/blogs/main/iksworkflowbenchmark.html</link>
		<comments>http://dev.day.com/microsling/content/blogs/main/iksworkflowbenchmark.html#comments</comments>
		<pubDate>Wed, 08 May 2013 00:00:01 +0000</pubDate>
		<dc:creator>Michael Marth</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Workflows]]></category>
		<category><![CDATA[Adobe AEM]]></category>
		<category><![CDATA[Adobe CQ]]></category>
		<category><![CDATA[CQ]]></category>
		<category><![CDATA[jabber]]></category>
		<category><![CDATA[michael marth]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[workflows]]></category>

		<guid isPermaLink="false">http://dev.day.com/microsling/content/blogs/main/iksworkflowbenchmark.html</guid>
		<description><![CDATA[
As part of the IKS project each CMS vendor completes a couple of benchmarks in order to establish a baseline against which future semantic improvements can be measured. For benchmark 3 &#34;Workflow Service&#34; Bertrand and I chose to implement th...]]></description>
				<content:encoded><![CDATA[<em><strong> -Michael Marth</strong></em>


<p>As part of the <a href="http://www.iks-project.eu/">IKS project</a> each CMS vendor completes a couple of <a href="http://wiki.iks-project.eu/index.php/Benchmarks">benchmarks</a> in order to establish a baseline against which future semantic improvements can be measured. For benchmark 3 &quot;Workflow Service&quot; Bertrand and I chose to implement the task &quot;Create a multi-channel (email, SMS, instant messaging, Twitter,...) notification service for workflow transitions&quot;. We have created an automated <a href="http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/workflow/exec/JavaProcessExt.html">workflow step</a> that can be inserted into a custom workflow and either send an e-mail, send a direct message on <a href="http://www.twitter.com">Twitter</a> or send a chat message on <a href="http://www.google.com/talk/">GTalk</a>/<a href="http://xmpp.org/">Jabber</a>. The corresponding message&#039;s payload is the path to the content node in the workflow plus an optional custom text.
</p>

<p>...</p>

<p><strong>........</strong></p>

<p><strong><em>Read the full blog post at <a href="http://dev.day.com/microsling/content/blogs/main/iksworkflowbenchmark.html" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/cqpost/2013/05/08/custom-cq5-workflow-step-that-integrates-twitter-and-jabber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating gallery components that display digital assets stored in the CQ DAM</title>
		<link>http://scottsdigitalcommunity.blogspot.com/2013/04/creating-gallery-components-that.html</link>
		<comments>http://scottsdigitalcommunity.blogspot.com/2013/04/creating-gallery-components-that.html#comments</comments>
		<pubDate>Fri, 03 May 2013 14:30:00 +0000</pubDate>
		<dc:creator>Scott Macdonald</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Adobe AEM]]></category>
		<category><![CDATA[Adobe CQ]]></category>
		<category><![CDATA[DAM]]></category>
		<category><![CDATA[Scott Macdonald]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/cqpost/?guid=027cadb016ebd6e7c05e5ad6959fa00d</guid>
		<description><![CDATA[You can create an interactive visual component that lets your AEM users engage with your Adobe CQ web site by viewing and clicking on images. When a user clicks on a thumbnail version of an image, a larger view of the image appears. In this workflow, t...]]></description>
				<content:encoded><![CDATA[<em><strong> -Scott MacDonald</strong></p>

<p>You can create an interactive visual component that lets your AEM users engage with your Adobe CQ web site by viewing and clicking on images. When a user clicks on a thumbnail version of an image, a larger view of the image appears. In this workflow, the component retrieves images from the Adobe CQ Digital Asset Management (DAM) repository.</p>

<p>...</p>

<p><strong>......</strong></p>


<p><strong><em>Read the full blog post at <a href="http://scottsdigitalcommunity.blogspot.in/2013/04/creating-gallery-components-that.html" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>


]]></content:encoded>
			<wfw:commentRss>http://scottsdigitalcommunity.blogspot.com/feeds/3104196126005010460/comments/default</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submitting Mobile Form Data to Adobe CQ</title>
		<link>http://scottsdigitalcommunity.blogspot.com/2013/04/submitting-mobile-form-data-to-adobe-cq.html</link>
		<comments>http://scottsdigitalcommunity.blogspot.com/2013/04/submitting-mobile-form-data-to-adobe-cq.html#comments</comments>
		<pubDate>Sat, 27 Apr 2013 00:00:00 +0000</pubDate>
		<dc:creator>Scott Macdonald</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Adobe CQ]]></category>
		<category><![CDATA[JCR]]></category>
		<category><![CDATA[JQuery Mobile API]]></category>
		<category><![CDATA[mobile data]]></category>
		<category><![CDATA[mobile form]]></category>
		<category><![CDATA[Scott Macdonald]]></category>

		<guid isPermaLink="false">https://blogs.adobe.com/cqpost/?guid=b18c07ec39900fa9e84b566e909289eb</guid>
		<description><![CDATA[You can create an Adobe CQ mobile form using JQuery Mobile API. When a mobile user fills in the form and clicks the submit button, form data is submitted to Adobe CQ. You can develop an OSGi bundle operation to process the submitted form data to meet y...]]></description>
				<content:encoded><![CDATA[<em><strong> -Scott MacDonald</strong></em>


<p>You can create an Adobe CQ mobile form using JQuery Mobile API. When a mobile user fills in the form and clicks the submit button, form data is submitted to Adobe CQ. You can develop an OSGi bundle operation to process the submitted form data to meet your business requirements.</p>


<p>...</p>

<p><strong>.......</strong></p>

<p><strong><em>Read the full blog post at <a href="http://scottsdigitalcommunity.blogspot.in/2013/04/submitting-mobile-form-data-to-adobe-cq.html" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>


]]></content:encoded>
			<wfw:commentRss>http://scottsdigitalcommunity.blogspot.com/feeds/4494315346509948764/comments/default</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe CQ/AEM support tools available</title>
		<link>http://blogs.adobe.com/dmcmahon/2013/04/24/adobe-cqaem-support-tools-available/</link>
		<comments>http://blogs.adobe.com/dmcmahon/2013/04/24/adobe-cqaem-support-tools-available/#comments</comments>
		<pubDate>Thu, 25 Apr 2013 07:00:53 +0000</pubDate>
		<dc:creator>dmcmahon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Adobe AEM]]></category>
		<category><![CDATA[Adobe CQ]]></category>
		<category><![CDATA[CQ]]></category>
		<category><![CDATA[WEM]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/dmcmahon/?p=1743</guid>
		<description><![CDATA[We have recently published a package with support tools that can be useful to help diagnose issues encountered with Adobe Experience Manager.&#160; As the tools project continues to mature, additional tools will be provided to ease the overall diagnosis and &#8230; <a href="http://blogs.adobe.com/dmcmahon/2013/04/24/adobe-cqaem-support-tools-available/">Continue reading <span>&#8594;</span></a>
]]></description>
				<content:encoded><![CDATA[<em><strong> -David McMahon</strong></em>

<p>We have recently published a package with support tools that can be useful to help diagnose issues encountered with Adobe Experience Manager.  As the tools project continues to mature, additional tools will be provided to ease the overall diagnosis and maintenance of CQ.</p>

<p>...</p>


<p><strong>......</strong></p>


<p><strong><em>Read the full blog post at <a href="http://blogs.adobe.com/dmcmahon/2013/04/24/adobe-cqaem-support-tools-available/" target="_blank">Adobe Digital Marketing Blog</a></em></strong></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/dmcmahon/2013/04/24/adobe-cqaem-support-tools-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ways to access your content with JCR (part 1)</title>
		<link>http://cqdump.wordpress.com/2012/11/26/ways-to-access-your-content-with-jcr-part-1/</link>
		<comments>http://cqdump.wordpress.com/2012/11/26/ways-to-access-your-content-with-jcr-part-1/#comments</comments>
		<pubDate>Mon, 10 Dec 2012 09:02:51 +0000</pubDate>
		<dc:creator>moderator</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[content management]]></category>
		<category><![CDATA[CQ]]></category>
		<category><![CDATA[JCR]]></category>
		<category><![CDATA[Jörg Hoh]]></category>

		<guid isPermaLink="false">http://cqdump.wordpress.com/?p=546</guid>
		<description><![CDATA[If you are a developer and need to work with databases, you often relay on the features your framework offers you to get your work done easily. Working directly with JDBC and SQL is not really comfortable, writing &#8220;SELECT something FROM table&#8221; with lots of constraints can be tedious … The SQL language offers only [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cqdump.wordpress.com&#38;blog=5932865&#38;post=546&#38;subd=cqdump&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong><em>- Jörg Hoh</em></strong></p>

<p>If you are a developer and need to work with databases, you often relay on the features your framework offers you to get your work done easily. Working directly with JDBC and SQL is not really comfortable, writing “SELECT something FROM table” with lots of constraints can be tedious …</p>

<p>The SQL language offers only the “select” statement to retrieve data from the database. JCR offers multiple ways to actually get access to a node:</p>
<ul>
	<li><a href="http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/Session.html#getNode%28java.lang.String%29"><code>session.getNode(path)</code></a></li>
	<li><a href="http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/Node.html#getNodes%28%29"><code>node.getNodes()</code></a></li>
	<li>JCR search</li>
</ul>
<p>Each of these methods serve for different purposes.</p>
<ul>
	<li><code>session.getNode(path)</code> is used, when you know exactly the path of a node. That’s comparable to a “select * from table where path = “/content/geometrixx/en” in SQL, which is a direct lookup of a well-known node/row.</li>
	<li><code>node.getNodes()</code> returns all child nodes below the node. This method has no equivalent in the SQL world, because in JCR there are not only distinct and independent nodes, but nodes might have a hierarchical relation.</li>
	<li>The JCR search is the equivalent of the SQL query, it can return a set of nodes. Yes, ANSI SQL 92 is much more powerful, but let’s ignore that for this article, okay?</li>
</ul>
<p>...</p>

<p><strong>----------</strong></p>

<p><em>Read the complete post on the </em><a href="http://cqdump.wordpress.com/2012/11/26/ways-to-access-your-content-with-jcr-part-1/" target="_blank">Things on a content management system</a><em> blog.</em></p>]]></content:encoded>
			<wfw:commentRss>http://cqdump.wordpress.com/2012/11/26/ways-to-access-your-content-with-jcr-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CQ coding patterns: Sling vs JCR (part 2)</title>
		<link>http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/</link>
		<comments>http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/#comments</comments>
		<pubDate>Thu, 22 Nov 2012 06:04:30 +0000</pubDate>
		<dc:creator>moderator</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CQ]]></category>
		<category><![CDATA[JCR]]></category>
		<category><![CDATA[Jörg Hoh]]></category>
		<category><![CDATA[SLING]]></category>

		<guid isPermaLink="false">http://cqdump.wordpress.com/?p=532</guid>
		<description><![CDATA[In the last posting I showed the benefits of Sling regarding resource access over plain JCR. But not only in resource access both frameworks offer similar functionality, but also in the important area of listening to changes in the repository. So today I want to compare JCR observation to Sling eventing. JCR observation is a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cqdump.wordpress.com&#38;blog=5932865&#38;post=532&#38;subd=cqdump&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<strong><em><p>- Jörg Hoh</p></em></strong>

<p>In the <a href="http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/">last posting</a> I showed the benefits of Sling regarding resource access over plain JCR. But not only in resource access both frameworks offer similar functionality, but also in the important area of listening to changes in the repository. So today I want to compare <a href="http://www.day.com/specs/jcr/2.0/12_Observation.html">JCR observation</a> to <a href="http://sling.apache.org/site/how-to-manage-events-in-sling.html">Sling eventing</a>.</p>

<p>JCR observation is a part of the JCR specification and is a very easy way to listen for changes in the repository.</p>
<p><pre>@component (immediate=true, metatype=false)
@service
class Listener implements ObservationListener {

  @Reference
  SlingRepository repo;

  Session session;
  Logger log = LoggerFactory.getLogger (Listener.class);

  @activate
  protected void activate () {
    try {
      Session adminSession = repo.loginAdministrative(null);
      session = adminSession.impersonate (new SimpleCredentials("author",new char[0]));
      adminSession.logout();
      adminSession = null;
      session.getObservationManager.addEventListener( this, // listener
        NODE_CREATED|NODE_DELETED|NODE_MOVED, // eventTypes
        "/", // absPath
        true, // isDeep
        null, // uuid
        null, //nodeTypeNames
        true // noLocal
      );
    } catch (RepositoryException e) {
      log.error ("Error while registering observation", e);
    }
  }

  @deactivate
  protected void deactivate() {
    session.getObservationManager.removeListener(this);
    session.logout();
    session = null:
  }

  private handleEvents (Events events) {
    while (events.hasNext()) {
      Event e = events.next();
      … // do here your event handling
     }
  }
}</pre></p>
<p>In JCR the creation of an observation listener is straight forward, also the event listening. The observation process is tied to the lifetime of the session, which is started and stopped at activation/deactivation of this sling service. This kind of implementation is a common pattern.
<img src="http://stats.wordpress.com/b.gif?host=cqdump.wordpress.com&amp;blog=5932865&amp;%23038;post=532&amp;%23038;subd=cqdump&amp;%23038;ref=&amp;%23038;feed=1" alt="" width="1" height="1" border="0" /></p>

<p>...</p>

<p>------</p>

<p><strong><em>Read the complete blog post at  <a title="http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/" href="http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/" target="_blank">http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/</a></em></strong> </p>

&nbsp;

&nbsp;]]></content:encoded>
			<wfw:commentRss>http://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CQ5 coding patterns: Sling vs JCR (part 1)</title>
		<link>http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/</link>
		<comments>http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 09:04:16 +0000</pubDate>
		<dc:creator>moderator</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CQ]]></category>
		<category><![CDATA[JCR]]></category>
		<category><![CDATA[Jörg Hoh]]></category>
		<category><![CDATA[SLING]]></category>

		<guid isPermaLink="false">http://cqdump.wordpress.com/?p=523</guid>
		<description><![CDATA[CQ5 as a complex framework is built on top of various other frameworks, on the server-side the most notably ones are JCR (with its implementation Apache Jackrabbit) and Apache Sling. Both are very powerful frameworks, but both of them have some overlap in functionality: reading data from the repository (Sling Resources vs JCR nodes/properties) notification [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cqdump.wordpress.com&#38;blog=5932865&#38;post=523&#38;subd=cqdump&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong><em>- Jörg Hoh</em></strong></p>

<p>CQ5 as a complex framework is built on top of various other frameworks, on the server-side the most notably ones are JCR (with its implementation Apache Jackrabbit) and Apache Sling. Both are very powerful frameworks, but both of them have some overlap in functionality:</p>
<ul>
	<li>reading data from the repository (<a href="http://sling.apache.org/site/resources.html">Sling Resources</a> vs <a href="http://www.day.com/specs/jcr/2.0/3_Repository_Model.html">JCR nodes/properties</a>)</li>
	<li>notification on repository events (<a href="http://sling.apache.org/site/eventing-and-jobs.html">Sling Eventing</a> vs <a href="http://www.day.com/specs/jcr/2.0/12_Observation.html">JCR observation</a>)</li>
</ul>
<p>In these 2 areas you can work with both frameworks, and achieve good results with both. So, the question is, in what situation should you prefer Sling and in what situation pure JCR.</p>

<p>First, and I hope you agree here, in 99% of all cases use the an abstracted framework is recommended over the use of concrete technology (everybody uses JDBC and noone a direct database interface for e.g. MySQL) . It usually offers more flexibility and an easier learning cure. Same here. While on pure JCR you only work with raw repository structures (nodes and properties), the Sling resource abstraction offers you easier handling (no need to deal with the repository exceptions any more) and much more options to interact with you business objects and services.</p>

<p>...</p>

<p>-----------</p>

<p><strong><em>Read the complete blog post at</em></strong> <a title="http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/" href="http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/" target="_blank">http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/</a></p>]]></content:encoded>
			<wfw:commentRss>http://cqdump.wordpress.com/2012/11/06/cq5-coding-patterns-sling-vs-jcr-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
