Introduction to MVC Programming using Agavi, part 2nd (i)

Source: Internet
Author: User
Tags file system xmlns contact form

Introduction to MVC Programming using Agavi, part 2nd: Adding Forms and database support using Agavi and doctrine 1

Brief introduction

In part 1th of this series, I introduced Agavi and explained some of the features that make Agavi suitable for building scalable, compliant Web applications. By using the sample application Web automobiles Sales Platform (WASP), I showed you the basics of creating a new Agavi project to help you understand Agavi's recommended file system layouts and familiarize yourself with Agavi's command-line build scripts. I also covered the underlying components of all Agavi applications-actions (actions), views, and routes (Routes)-and showed some built-in Agavi input validators.

Although Agavi used to provide static content, it is also a good way to handle more complex situations. In part 2nd, you'll examine Agavi's ability to handle complex content--in the next few sections, you'll learn how to receive, validate, and process input from Web Forms and connect Agavi applications to MySQL databases.

Create a form using Agavi

First, the index page for the Wasp application is quickly browsed (Figure 1):

Figure 1. Index page for wasp application

You have prepared the code in the previous article to handle two links to static content. Let's move on and start working on the "Contact Us" link. As the name suggests, this link points to a contact form through which you can contact a car dealer. The overall process of implementing this functionality is similar to the process of building staticcontentaction in the previous article.

Start the Agavi build script first and enter the following values:

shell> agavi action-wizarD
...
Module name: Default
Action name: Contact
Space-separated list of views to create for Contact [Success]: Input Error Success

This will create a new contactaction and 3 other views. You are already familiar with the two standard views of Contactsuccessview and Contacterrorview, which are displayed based on the success or failure of the operation. The third view Contactinputview is new, is the first view that the user sees, and displays a Web form that will accept user input.

Add a new route for the contactaction in the $wasp_root/app/routing.xml file, as shown in Listing 1:

Listing 1. Default/contactaction Routing Definition

<?xml version="1.0" encoding="UTF-8"?>
<ae:configurations xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0"
 xmlns="http://agavi.org/agavi/config/parts/routing/1.0">
 <ae:configuration>
  <routes>
    ...
   <!-- action for contact form "/contact" -->
   <route name="contact" pattern="^/contact$" module="Default"
    action="Contact" />

  </routes>
 </ae:configuration>
</ae:configurations>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.