fhg
Volume 10, Number 26 -- September 8, 2010

Get Thee to the Web, Part 1

Published: September 8, 2010

by Paul Tuohy

To the traditional IBM i programmer, the Web can be a strange and scary place. It is full of new mysterious terminology and seems to be populated by 12-year-olds.

But the reality is that the Web now plays an integral part in our applications, whether it is in providing a company face to the world or simply for internal systems. So, like it or not, it is a world we have to come to grips with.

In this series of three articles, I hope to help you to navigate your way to the Web, understand some of the basic concepts involved in Web development, and compare and contrast the main solutions available to identify which may be best for you. And to outline the items you must learn, regardless of which solution you choose.

One of the main problems that we face when looking at developing for the Web, is information overload. We are spoiled with choices and seemingly presented with multiple alternatives. So let's start by discussing the possible solutions.


Solutions

There are, of course, a host of excellent third-party solutions, and one of these may be the best business solution for your company. Third-party solutions aside, if you are looking at doing your own development, you are left with three choices: CGIDEV2, PHP, and Java.

But before you can decide which of these three solutions might be the best fit for your development environment, you need to separate out the components that are common to all three.

In other words, there is certain knowledge you must have, regardless of the solution you choose:

  • Designing and maintaining the interface
  • Tiered design
  • What a server does
  • Statelessness

Designing and Maintaining the Interface

Most traditional green-screen programmers cannot design Web pages. We may be able to code them, but we cannot design them. Have a look at Figure 1, which is the original home page I designed for System i Developer. Figure 2 is what it looked like after professional designers got their hands on it. See the difference?


Figure 1: The author's attempt at Web page design.


Figure 2: Professional Web designers create a different look.

When you think about it, these two samples are no different from what we do on a green screen. Although we may code many screens, we are actually following the rules laid down by CUA (Common User Access) that dictates which function keys are used for what, where items are on a screen, etc. The benefit we have on green screen is that there is a common design mechanism for everyone. When it comes to the Web, we need a designer to come up with our company's design rules. We then code the interface to work with those rules.

Programming a Web interface requires knowledge of three languages:

  1. HTML (Hypertext Markup Language) controls the content
  2. CSS (Cascading Style Sheets) defines the presentation
  3. Javascript controls behavior

Figure 3 shows four seemingly very different Web pages with the same content.


Figure 3: Four representations of the same content.

But each of the pages in Figure 3 has the exact same HTML. The important lines to note are contained in the <head> element toward the start of the page. The <link> element identifies the CSS style rules to be used (/css/css00.css) and the <script> element identifies the file (/JavaScript/jsFunctions.js) containing any Javascript functions used on the page. The four buttons specify that, when the button is clicked, the SwitchStyles() function is called with a parameter of 0, 1, 2, or 3. The SwitchStyles() function simply changes the name of the style sheet in the <link> element.

The following is the HTML code for the Web page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>Show Some Style</title>
  <link rel="stylesheet" id="CSSName" href="/css/css00.css"
        type="text/css">
  <script type="text/javascript" src="/JavaScript/jsFunctions.js">
  </script>
</head>
<body>
<div id="container">
   <div id="heading">
      <p>RPG Meets the Web! </p>
   </div>
   
   <div id="page">
	  <p><img src="/images/3layers.jpg" /> <br />
	     HTML is for Content. </p>
	  <p>CSS is for Presentation. </p>
	  <p>Javascript is for Behavior. </p>

	  <p>Select a style 
	     <button onClick="SwitchStyles(0)" >0</button>
	     <button onClick="SwitchStyles(1)" >1</button>
	     <button onClick="SwitchStyles(2)" >2</button>
	     <button onClick="SwitchStyles(3)" >3</button>
	  </p>
	</div>
</div>
</body>
</html>

For the sake of completion the next piece of code shows the contents of one of the CSS style sheets:

body {
	background: black;
      color: #00dd00;
}

h1 {
	color: blue;
}

button {
	background: black;
	color: blue;
	border: 0;
}

	
img { 
	float: right;
	padding-left: 10px;
	padding-right: 5px;
	padding-top: 5px;
	border: 0;
}

#heading {
	font-family:"Times New Roman", serif; 
	font-size: 30.0px;
	text-align: center;
	color: white;
	padding-top: 10px;
	padding-bottom: 5px; 
}

Finally, the following code shows the Javascript function SwitchStyles() or the contents of jsFunctions.js:

function SwitchStyles(newStyle) {

	sheetNames = new Array("css00.css", "css01.css", "css02.css", "css03.css");
	document.getElementById('CSSName').href = "/css/" + sheetNames[newStyle];

}

From our point of view, the most important of these languages is HTML. Our main concern is the content of the Web page.

Although we do not need to be experts in CSS, we must have an understanding of how it works: at least a basic knowledge is required.

In this day and age in is highly unlikely we will be able to avoid Javascript. But initially, as with CSS, we do not need to be experts--a basic knowledge is enough to get up and running. Also, I think it is very important that you have a basic understanding of HTML and CSS before you start on Javascript; one of the things you will be doing most in Javascript is playing around with styling rules.


Getting Started with HTML, CSS, and Javascript

So how do you go about learning HTML, CSS and Javascript? Well, again, you are spoiled for choice.

If you prefer classroom education, I am sure you can find many local institutes offering courses.

If you are more self motivated, a good place to start is at W3Schools.com where there are many excellent free tutorials on all things Web related.

I also recommend you have a look at SitePoint, which offers many excellent books (hard copy and electronic format), online courses, articles, podcasts, blogs, etc.

Getting started with HTML, CSS and Javascript is easy. All you need is a PC, a browser and an editor (and I know you have at least two of these or you would not be reading this article). You could manage with a simple text editor but you don't have to--there are many free choices available to you. You may want to have a look at:

Lastly, as you start out on your Web adventure, I recommend that you use Firefox as your development browser of choice. Not only is the error console a lot more helpful, but you also have a number of developer plug-ins that can make life a lot easier, such as Firebug, Web Developer Toolbar and the Javascript Venkman Debugger.


End of Part 1

In Part 2, we will look a little closer at the development of Web application on the i.


Paul Tuohy is CEO of ComCon, an iSeries consulting company, and is one of the co-founders of System i Developer, which hosts the RPG & DB2 Summit conferences. He is an award-winning speaker who also speaks regularly at COMMON conferences, and is the author of "Re-engineering RPG Legacy Applications," "The Programmers Guide to iSeries Navigator," and the self-study course called "iSeries Navigator for Programmers." Send your questions or comments for Paul to Ted Holt via the IT Jungle Contact page.




                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
SEQUEL SOFTWARE

MYTH: Accessing Data Is Complex and Expensive

REALITY: Dispel the myths of IBM i data access and
bring data to your desktop quickly with SEQUEL.

From simple ad hoc queries to executive dashboards, SEQUEL delivers
IBM i data in the format that works best for you. SEQUEL is the fastest,
easiest way to access your IBM i data.

Click here for a FREE Information Kit.


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Erwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

PowerTech:  FREE Webinar! Protect IBM i Data from FTP, ODBC, & Remote Command. Sept 15, 10 am CT
looksoftware:  RPG OA & Beyond Webinar. Sept 28 & 29. Enter to win an Amazon Kindle™
COMMON:  Join us at the Fall 2010 Conference & Expo, Oct. 4 - 6, in San Antonio, Texas


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
The iSeries Express Web Implementer's Guide: List Price, $49.95
The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
Can the AS/400 Survive IBM?: List Price, $49.00
Chip Wars: List Price, $29.95


 
The Four Hundred
Entry IBM i Server Deals Greased With License Discounts

Prices Jacked on Power Systems Tape Drives and Expansion Drawers

The Server Racket Strengthens in Q2, But Will It Hold?

Mad Dog 21/21: Craft Nouveau

IDC Raises Global IT Spending Projections for 2010

Four Hundred Stuff
MKS Offers Full Support for IBM i 7.1 in ALM Tool

Vanguard Adds Graphical Workflow Features to IBM i Imaging Solution

Valid and TGS Gang Up on Buddy Punchers

Quantum Adds Fibre Channel to Midrange De-dupe Boxes

CCSS Cracks Down on IBM i Jobs with Excessive I/O

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
September 4, 2010: Volume 12, Number 36

August 28, 2010: Volume 12, Number 35

August 21, 2010: Volume 12, Number 34

August 14, 2010: Volume 12, Number 33

August 7, 2010: Volume 12, Number 32

July 31, 2010: Volume 12, Number 31

TPM at The Register
IT workers getting back to work - sort of

Semi biz starts to cool off

HyTrust takes auditing, monitoring to the clouds

MokaFive outs bare-metal PC hypervisor

Cray and SGI push upgrades to latest supers

Gartner chops PC shipment forecasts for 2010

SGI bleeds less than expected

Xsigo rejiggers virtual I/O director for Ethernet

Big Blue finally punts an Opteron 6100 server

Project Horizon: VMware's plan to restitch the desktop

Retired joint chiefs chairman dons a Red Hat

Citrix eats VMLogix for self-service clouds

THIS ISSUE SPONSORED BY:

SEQUEL Software
WorksRight Software
inFORM Decisions


Printer Friendly Version


TABLE OF CONTENTS
Get Thee to the Web, Part 1

Avoid an Unnecessary CPYF Error

Admin Alert: Placing Additional Restrictions on i/OS Passwords

Four Hundred Guru

BACK ISSUES




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2010 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement