Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Form Submission And Saving Data To.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Website Development Introducing PHP The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database.
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Week 4  Using PHP with HTML forms  Form Validation  Create your own Contact form Please Visit:
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
Introduction to MVC Adding Model Classes NTPCUG Tom Perkins, Ph.D.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Part 06 – A More Complex Data Model Entity Framework and MVC NTPCUG Tom Perkins.
Using FrontPage Express. Slide 1 Standard toolbars and menus Time indicator: gives an approximation of download time of the page.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
By: Saurabh Dixit.  Groovy server pages  Taglibs  Validators in grails.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Website Development with PHP and MySQL Saving Data.
ITCS373: Internet Technology Lecture 5: More HTML.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen randomly using rand() function.
PHP Form Introduction Getting User Information Text Input.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
1 HTML forms (cont.)
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
PHP Form Processing * referenced from
Introduction to Forms in HTML WebPages Mrs. Mustoe.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Personalizing Web Sites Nasrullah. Understanding Profile The ASP.NET application service that enables you to store and retrieve information about users.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
A little PHP. Enter the simple HTML code seen below.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Uploading and Downloading Files.
© 2004 D. J. Foreman T&F-1 CS205 Tables & Forms. T&F-2 ©2007 D. J. Foreman Tables.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Jim Fawcett CSE686 – Internet Programming Spring 2014
A little PHP.
Computing with C# and the .NET Framework
Developing Web-applications with Grails framework
Jim Fawcett CSE686 – Internet Programming Spring 2012
How to Write Web Forms By Mimi Opkins.
Introduction to web design discussing which languages is used for website designing
Web Systems Development (CSC-215)
Chapter 6 Sub Procedures
Web Development Using ASP .NET
Introduction to Access 2010
Using FrontPage Express
CS205 Tables & Forms © 2012 D. J. Foreman.
HTML Forms What are clients? What are servers?
CS205 Tables & Forms © 2008 D. J. Foreman.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
CS205 Tables & Forms © 2004 D. J. Foreman.
Web Forms.
Presentation transcript:

Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Form Submission And Saving Data To Database

HTML Forms are usually used to gather data from users. This post will show how to make use of forms to save data to the database. This example will render a form that looks like this: And on click of Save, will save the data to the person table. Case Statement 2

We first need to create a domain class. For example: class Person { String firstName String lastName int age } You need to save this under grails-app/domain folder. It is advisable to create a package structure under this folder. Solution. Step 1: Create a Domain Class 3

When you start your application, Grails will automatically create a database table for each domain class you have. In our example, the table "person" will be created with columns "first_name", "last_name", and "age". Solution. Step 1: Create a Domain Class 4

This is an example of a view page code (form.gsp): Form First Name: Last Name: Age: Solution. Step 2: View Code 5

The form tag above specifies that on submit, the data will be passed to the save method/action of the person controller (PersonController.groovy). The rest is self explanatory. Solution. Step 2: View Code 6

Below is an example controller code to display the page above, and handle form submission: package com.myapp class PersonController { def form() { } def save() { def person = new Person(params) person.save() render "Success!" } Solution. Step 3: Controller Code 7

The first method form() will display form.gsp when the user accessed the url The second method will accept the submitted data from the HTML form. The code new Person(params) will create a Person instance, and automatically map data from the form to the instance by property name. Solution. Step 3: Controller Code 8

Since the form has the property firstName via the code, the instance returned by new Person(params) will populate the firstName property from the data in the form. This is also true for the other fields lastName and age. The code person.save() will save the data to the database, while render "Success!" will display the text to the browser as is. Solution. Step 3: Controller Code 9

This is just a simple example to understand how data is passed from HTML, to controllers, and then to the database. Remarks 10