CMPE 280 Web UI Design and Development March 19 Class Meeting

Slides:



Advertisements
Similar presentations
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the: course is a PowerPoint demonstration intended to introduce.
Advertisements

Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
USING WORDPRESS. WEEK 1 1.Why WP? 2.Setting Up WP 3.Exploring the Admin screen 4.Page Organization 5.Posting 6.Polls.
Tutorial 6 Creating a Web Form
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 9: HTML Frames.
CS 174: Web Programming February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
A detailed guide on how to set-up your printing storefront. Please Note: Storefronts are compatible with all browsers, however for optimal use of the admin.
CS 174: Web Programming April 9 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
In addition to Word, Excel, PowerPoint, and Access, Microsoft Office® 2013 includes additional applications, including Outlook, OneNote, and Office Web.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
CS 235: User Interface Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 24 Managing and Reporting Database Information 1 Morrison / Wells / Ruffolo.
CS 174: Web Programming September 30 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Introducing Microsoft Outlook Session Version 1.0 © 2011 Aptech Limited.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
CS 174: Web Programming October 12 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 174: Web Programming October 14 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
How Your Customers Will Pay Online & by Phone
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Session: 4. © Aptech Ltd. 2Creating Hyperlinks and Anchors / Session 4  Describe hyperlinks  Explain absolute and relative paths  Explain how to hyperlink.
CS 160 and CMPE/SE 131 Software Engineering February 11 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
CMPE 226 Database Systems April 19 Class Meeting Department of Computer Engineering San Jose State University Spring 2016 Instructor: Ron Mak
Education And Training CTC IT DIVISION PivotLink User Training April 2010.
CS 174: Web Programming October 28 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Using Templates and Mail Merge
Web Database Programming Using PHP
Intro to HTML CS 1150 Spring 2017.
Web Programming Language
(PubMed) MY NCBI (Advanced Course: Module 2)
Internet Business Associate v2.0
Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals Wikis are collections of searchable,
Introduction to Dynamic Web Programming
CMPE 280 Web UI Design and Development August 29 Class Meeting
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Web Database Programming Using PHP
In this session, you will learn about:
CMPE 280 Web UI Design and Development October 26 Class Meeting
CMPE 280 Web UI Design and Development October 19 Class Meeting
CMPE 280 Web UI Design and Development October 17 Class Meeting
CMPE 280 Web UI Design and Development October 24 Class Meeting
CMPE 280 Web UI Design and Development October 26 Class Meeting
PHP Training at GoLogica in Bangalore
CMPE 280 Web UI Design and Development January 30 Class Meeting
Unit I: Collecting Data with Forms
(PubMed) MY NCBI (Advanced Course: Module 2)
ISC440: Web Programming 2 Server-side Scripting PHP 3
CS 174: Server-Side Web Programming January 29 Class Meeting
CMPE 280 Web UI Design and Development January 30 Class Meeting
Forms, cont’d.
Web DB Programming: PHP
CMPE 280 Web UI Design and Development October 18 Class Meeting
CMPE 280 Web UI Design and Development January 29 Class Meeting
Web Programming Language
Tutorial 6 PHP & MySQL Li Xu
CMPE 280 Web UI Design and Development March 19 Class Meeting
PHP an introduction.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
CMPE 280 Web UI Design and Development August 27 Class Meeting
CMPE 280 Web UI Design and Development September 10 Class Meeting
Presentation transcript:

CMPE 280 Web UI Design and Development March 19 Class Meeting Department of Computer Engineering San Jose State University Spring 2019 Instructor: Ron Mak www.cs.sjsu.edu/~mak

Midterm Solution: Question #21 Why would a search engine company encourage you to practice good SEO? The search engine company wants to display the best results.

Midterm Solution: Question #22.a Ed’s Auto Repair Shop has hired you to develop a web application to enable his registered customers to log in, specify what’s wrong with their cars, and schedule repair appointments online. After a repair job is complete, the customer can access an itemized bill by clicking on a link. Ed’s account manager will have special privileges to perform tasks such as managing customer accounts and generating itemized repair bills. Sample functional requirements: Customers must be able to register. Customers must be able to log in. Customers must be able to make service appointments. Customers must be able to see their itemized repair bills. The account manager must be able to manage customer accounts. The account manager must be able to generate itemized repair bills.

Midterm Solution: Question #22.b Sample nonfunctional requirements: The web app must work on any of the popular web browsers. The web app must have a simple intuitive user interface. The web app must have response time of under 10 seconds. The web app must be available 24 by 7. There shall be a Spanish version of the web app.

Midterm Solution: Question #23 How can your Auto Repair Shop application (Question 22) use cookies? In the server application, cookies associate requests with their sessions.

Midterm Solution: Question #24 Give two examples of how your Auto Repair Shop application can use routing. A GET request for a form is routed to the controller code that will download the form to the client. A POST request from a form is routed to the controller code that will process the form data.

Midterm Solution: Question #25 How can your Auto Repair Shop application use AJAX? Ads can download asynchronously from the server for display in a corner of the screen. The itemized bill can appear without causing a refresh of the entire screen.

Midterm Solution: Question #26 Describe how your Auto Repair Shop application can use two jQuery UI widgets. The calendar widget for making appointments. The tab widget for different repair services.

Midterm Solution: Question #27 Why is it usually not preferable to include functionality with a WordPress theme? If you change themes, you lose the functionality.

Midterm Solution: Question #28 In the jQuery “pull quotes” example, briefly explain what steps are necessary to make each piece of text surrounded by the <span class="pq"> tag to become a pull quote in the right margin of the web page. Clone the text in each span with the “pq” class. Add class “pullquote” to the cloned text. Insert the cloned text before the spanned text. The CSS rule for class “pullquote” floats the cloned text to the right margin.

Midterm Solution: Question #29 What is the main purpose of the name attribute of an HTML text input tag? The name attribute allows server-side code to access the value that the user entered into the input tag.

Midterm Solution: Question #30 How can a form prompt a user to enter a phone number only in a standard format such as (408) 567-1234, but then satisfy a web application that can only process the number as a string of digits only, such as 4085671234? Explain briefly in words, with or without code snippets. Use a regular expression to match and capture the three groups of numbers. Then concatenate the captured groups and send the resulting string of digits to the application.

MongoDB Demo Install MongoDB: https://docs.mongodb.com/master/administration/install-community/ Start the MongoDB server: Start the MongoDB interactive shell: /usr/local/Cellar/mongodb/3.2.10/bin/mongod /usr/local/Cellar/mongodb/3.2.10/bin/mongo MongoDB shell version: 3.2.10 connecting to: test >

MongoDB Demo, cont’d Create the school database: Insert a document into the teacher collection: Who’s in there now? > use school switched to db school > db.teacher.insert( {id: 7003, last: "Rogers", first: "Tom"} ) WriteResult({ "nInserted" : 1 }) > db.teacher.find() { "_id" : ObjectId("582a7630f22e3c2f12d899ac"), "id" : 7003, "last" : "Rogers", "first" : "Tom" }

MongoDB Demo, cont’d Insert the rest of the teachers as an array of documents: > db.teacher.insert([ ... { id: 7008, last: "Thompson", first: "Art" }, ... { id: 7012, last: "Lane", first: "John" }, ... { id: 7051, last: "Flynn", first: "Mabel" } ... ])

MongoDB Demo, cont’d Find all of them and pretty print: > db.teacher.find().pretty() { "_id" : ObjectId("582a7630f22e3c2f12d899ac"), "id" : 7003, "last" : "Rogers", "first" : "Tom" } "_id" : ObjectId("582a7808f22e3c2f12d899ad"), "id" : 7008, "last" : "Thompson", "first" : "Art" "_id" : ObjectId("582a7808f22e3c2f12d899ae"), "id" : 7012, "last" : "Lane", "first" : "John" "_id" : ObjectId("582a7808f22e3c2f12d899af"), "id" : 7051, "last" : "Flynn", "first" : "Mabel" Find all of them and pretty print:

MongoDB Demo, cont’d A simple query with $or: > db.teacher.find( ... { $or: [ {id: 7008}, {first: "John"} ] } ... ).pretty() { "_id" : ObjectId("582a7808f22e3c2f12d899ad"), "id" : 7008, "last" : "Thompson", "first" : "Art" } "_id" : ObjectId("582a7808f22e3c2f12d899ae"), "id" : 7012, "last" : "Lane", "first" : "John"

MongoDB Demo, cont’d Update a document: > db.teacher.update( >" db.teacher.find() { "_id" : ObjectId(582a7630f22e3c2f12d899ac"), "id" : 7003, "last" : "Rogers", "first" : "Tom" } { "_id" : ObjectId("582a7808f22e3c2f12d899ad"), "id" : 7008, "last" : "Thompson", "first" : "Art" } { "_id" : ObjectId("582a7808f22e3c2f12d899ae"), "id" : 7012, "last" : "Lane", "first" : "John" } { "_id" : ObjectId("582a7808f22e3c2f12d899af"), "id" : 7051, "last" : "Flynn", "first" : "Mabel" } > db.teacher.update( ... {id: 7051}, ... {$set: {first: "Mabeline"}} ... ) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.teacher.find( {id: 7051} ).pretty() { "_id" : ObjectId("582a7808f22e3c2f12d899af"), "id" : 7051, "last" : "Flynn", "first" : "Mabeline" }

MongoDB Demo, cont’d Projection: Show only the ids and last names: > db.teacher.find( {}, {_id: 0, id: 1, last: 1} ) { "id" : 7003, "last" : "Rogers" } { "id" : 7008, "last" : "Thompson" } { "id" : 7012, "last" : "Lane" } { "id" : 7051, "last" : "Flynn" }

MongoDB Demo, cont’d Sort in ascending or descending order by last name: > db.teacher.find( {}, {_id: 0, id: 1, last: 1} ).sort({last: 1}) { "id" : 7051, "last" : "Flynn" } { "id" : 7012, "last" : "Lane" } { "id" : 7003, "last" : "Rogers" } { "id" : 7008, "last" : "Thompson" } > db.teacher.find( {}, {_id: 0, id: 1, last: 1} ).sort({last: -1}) { "id" : 7008, "last" : "Thompson" } { "id" : 7003, "last" : "Rogers" } { "id" : 7012, "last" : "Lane" } { "id" : 7051, "last" : "Flynn" }

Express/MongoDB Example A very simple example of Express on the server side accessing a MongoDB database. We will display some user documents that each contains a user name and an email address. Recall that a collection is analogous to to a relational table in a relational database. Recall that a document is analogous to a record. We will add new documents.

Project Dependencies: package.json {   "name": "MongoDBExample",   "version": "0.0.0",   "private": true,   "scripts": {       "start": "node app.js"   },   "dependencies": {       "body-parser": "~1.18.2",       "debug": "~2.6.9",       "express": "~4.15.5",       "jade": "~1.11.0",       "mongodb": "^2.2.25",       "monk": "^4.0.0",       "morgan": "~1.9.0",       "nodeunit": "^0.11.2"   } } Monk: “A tiny layer that provides simple yet substantial usability improvements for MongoDB usage within Node.JS.” https://www.npmjs.com/package/monk

Initialize the MongoDB Database Start the MongoDB shell. Insert the first document: /usr/local/Cellar/mongodb/3.2.10: mongo MongoDB shell version: 3.2.10 connecting to: test Server has startup warnings:  2017-10-19T02:30:02.649-0700 I CONTROL  [initandlisten]  2017-10-19T02:30:02.649-0700 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 > use nodetest1 switched to db nodetest1 > db.usercollection.insert({ "username" : "testuser1", "email" : "testuser1@testdomain.com" }) WriteResult({ "nInserted" : 1 }) Collection usercollection is automatically created the first time we add to it.

Initialize the MongoDB Database, cont’d > db.usercollection.find().pretty() { "_id" : ObjectId("59e8711733b5f794be534cda"), "username" : "testuser1", "email" : "testuser1@testdomain.com" } Yes, it was successfully inserted. So insert two more documents.

Initialize the MongoDB Database, cont’d > newstuff = [{ "username" : "testuser2", "email" : "testuser2@testdomain.com" }, { "username" : "testuser3", "email" : "testuser3@testdomain.com" }] [ { "username" : "testuser2", "email" : "testuser2@testdomain.com" }, "username" : "testuser3", "email" : "testuser3@testdomain.com" } ] > db.usercollection.insert(newstuff) BulkWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 2, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] })

Initialize the MongoDB Database, cont’d > db.usercollection.find().pretty() { "_id" : ObjectId("59e8711733b5f794be534cda"), "username" : "testuser1", "email" : "testuser1@testdomain.com" } "_id" : ObjectId("59e8715233b5f794be534cdb"), "username" : "testuser2", "email" : "testuser2@testdomain.com" "_id" : ObjectId("59e8715233b5f794be534cdc"), "username" : "testuser3", "email" : "testuser3@testdomain.com"

Express Project MongoDBExample

Connect to the MongoDB Database app.js var mongo = require('mongodb'); var monk = require('monk'); var db = monk('localhost:27017/nodetest1'); Use Monk to connect to the database nodetest1 at the default MongoDB port 27017. Make the database accessible to the controller: app.use(function(req, res, next) {     req.db = db;     next(); });

Routing routes/index.js var express = require('express'); var router = express.Router(); var ctrlMain = require("../controllers/main"); var modelMain = require("../models/modelMain"); console.log("Router:"); console.log(router); router.get('/', ctrlMain.home); router.get('/userlist’, modelMain.get_userlist); router.get('/newuser', ctrlMain.get_newuser); router.get('/userlist/:username', modelMain.get_showuser); router.post('/adduser', modelMain.post_adduser); router.get('/deleteuser/:username', ctrlMain.get_deleteuser); router.post('/deleteuser/:username', modelMain.post_deleteuser); module.exports = router;

Display all the Users models/modelMain.js module.exports.get_userlist = function(req, res)  {     var db = req.db;     var collection = db.get('usercollection');     collection.find({}, {},                      function(err, docs)                     {                         res.render('userlist', { "userlist" : docs });                     }); }; views/userlist.jade extends layout block content     h1.         User List     ul         each user in userlist             li                 a(href="mailto:#{user.email}")= user.username

Show a User models/modelMain.js module.exports.get_showuser = function(req, res)  {     var uname = req.params.username;     var db = req.db;     var collection = db.get('usercollection');          collection.find( { username : uname },                       function(err, doc)                       {                          if (err) {                              res.send("Find failed.");                          }                          else {                              res.render('showuser',                                          { title: 'Show User: ' + uname,                                           mail: doc[0].email })                      }); };

Show a User, cont’d views/showuser.jade extends layout block content     h1= title     p Email: #{mail}

Display the New User Form module.exports.get_newuser = function(req, res)  {     res.render('newuser', { title: 'Add New User' }); }; controllers/cntrlMain.js views/newuser.jade extends layout block content     h1= title     form#formAddUser(name="adduser",method="post",action="/adduser")         input#inputUserName(type="text", placeholder="username", name="username")         input#inputUserEmail(type="text", placeholder="useremail", name="useremail")         button#btnSubmit(type="submit") submit

Add a New User module.exports.post_adduser = function(req, res) {     // Set our internal DB variable     var db = req.db;     // Get our form values. These rely on the "name" attributes.     var userName = req.body.username;     var userEmail = req.body.useremail;     // Set our collection.     var collection = db.get('usercollection'); models/modelMain.js

Add a New User, cont’d models/modelMain.js // Submit to the database.     collection.insert( { "username" : userName,                          "email" : userEmail },                        function (err, doc)                         {                            if (err) {                                res.send("Insert failed.");                            }                            else {                                // Forward to success page                                res.redirect("userlist");                        }); };

Delete a User module.exports.get_deleteuser = function(req, res) {     var uname = req.params.username;     res.render('deleteuser', { "username" : uname} ); }; controllers/cntrlMain.js

Delete a User, cont’d models/modelMain.js module.exports.post_deleteuser = function(req, res)  {     var uname = req.params.username;     var db = req.db;     var collection = db.get('usercollection');     // Submit to the database.     collection.remove( { "username" : uname },                        function (err, doc)                         {                            if (err) {                                res.send("Delete failed.");                            }                            else {                                res.send("Successfully deleted " + uname);                        }); };

Assignment #5 Add a MongoDB database to your project. Create web pages to: display documents add and delete documents update documents You must use Express and either Monk or Mongoose to talk to the database. Monk: https://www.npmjs.com/package/monk Mongoose: https://www.npmjs.com/package/express-mongoose Due Friday, October 25