WebSmart Developer Tip: Using esdiapixxx.js
As you develop applications with WebSmart you'll notice that in the header area of the generated HTML pages, several of our templates include a line similar to this one:
<script type="text/javascript" src="/websmart/v6.7/javascript/esdiapi011.js">
</script>
As an alternative to including all the JavaScript used in our templates inline, and cluttering up your code with dozens or hundreds of extra lines, we have designed the templates to pull in this JavaScript library, via the statement shown above.
But what does this do for you? What it means is that you have at your disposal over 30 different scripts, vetted by our own Development and Professional Services teams, that you can use to add handy features to your web pages. esdiapixxx.js (the sequence number may vary depending on the release you're working with) includes functions to attach events, manipulate cookies, make AJAX requests, highlight table rows, and drag objects, as well as many other more mundane tasks.
To give you a sense of what you can do with this, let's consider two examples.
Example 1: Positioning the Cursor to the First Field on the Page
The first example is from the Page at a Time Maint template, where the program is designed to automatically position the cursor to the first input-capable element on the page. In your template, you'll see this section in your HTML header:
<script type="text/javascript">
xl_AttachEvent(window, "load", WindowInit);
function WindowInit()
{
xl_FocusFirstElement();
}
</script>
Within esdiapi011.js, xl_FocusFirstElement() includes some 40 lines of JavaScript that finds your form elements and identifies the first element that is neither hidden nor disabled, to position the cursor there.
Example 2: Creating a URL String for an AJAX call.
Another function in esdiapi011.js is named 'xl_BuildURLWithFormElements'. This function is used to construct a string that (usually) comprises a URL, to emulate the format provided by a conventional HTML form submission. It finds every element name and value for a specified form and appends them to the specified string in the format ?name1=value1&name2=value2 or &name1=value1&name2=&value2, depending on whether an initial parm is present. This is useful for AJAX applications that require sending the server a lengthy URL with lots of parameters. For example, if you have a form with lots of input fields and you want to perform a database update using AJAX, this function makes it easy to construct the string.
Here is an illustration of a program we have been working on for a customer, where this has come in handy:
A program with many checkboxes and options, using esdiapi010.js to update the graph.
This page includes many checkboxes and options. The information in this form is sent in an AJAX get.
In order to extract all this information from the form for the AJAX get, we use a single function that grabs all the form variables and constructs a URL string from them. You can see this in the code shown below, where in line 55 we simply call xl_BuildURLWithFormElements to do the heavy lifting of creating the URL string for the AJAX call:
The call to xl_BuildURLWithFormElements()..
For additional information on esdiapixxx.js and documentation for all the functions currently shipped in it, go to the WebSmart ILE Developer Resources area of www.mybcdsoftware.com. If you don't yet have a mybcdsoftware.com login please visit our website to request an account.
Using WebSmart SmartSnippets
In last month's Technical Update we previewed several of the new features in the upcoming WebSmart 6.7, including SmartSnippets. In this article we'll take a closer look at another of the PML SmartSnippets we'll be shipping, and use it as an example illustrating how you can create your own custom SmartSnippets.
The gensmurfid SmartSnippet
The gensmurfid function has enough options that, unless you have the WebSmart IDE maximized on a wide screen browser, you probably won't even see all the parameters in the IDE Status bar. Because of its potential complexity and frequent use in business applications, it was a good candidate for 'smartsnippetization' (a word destined to quickly become part of your everyday conversations).
When you install WebSmart 6.7 and review your PML snippets you'll see an entry named 'Generate Smurf ID - WS'. Put your cursor at the spot in the PML where you want to add the function and double-click the snippet. When you do this, WebSmart pops up this window:
The gensmurfid SmartSnippet.
After you select your parameters, WebSmart adds the line of code:
gensmurfid("*IFNONE", "*WAS", 3, "*YES", "*YES", "*YES");
The Structure of SmartSnippets
SmartSnippets, built using the same tree structure as your templates, are just as easy to work with. Let's take a look at a few of the key elements in this particular instance.
To edit or copy a snippet, begin by right-clicking the entry in the IDE list and selecting the Change option. When you do this, WebSmart pops up an edit box where you can work with the code.
The gensmurfid SmartSnippet includes the following sections to define a couple of the label/option pairs. The first and third blocks define the labels, while the second is for a dropdown box (TYPE='DROPLIST';), and the fourth is a simple input field (TYPE='EDIT';):
PANEL='1'
{
TYPE='FLAT';
TITLE='Enter gensmurfid parameters';
CONTROLS='*'
{
CONTROL='U_OPTLABEL'
{
TYPE='LABEL';
X='24';
Y='20';
WIDTH='170';
HEIGHT='40';
Text='Creation option: (*IFNONE = only gen smurf ID if
pgmf_smurfid is blank)';
}
CONTROL='U_OPT'
{
TYPE='DROPLIST';
X='228';
Y='16';
WIDTH='150';
HEIGHT='22';
VALUE='*IFNONE';
VALUE='*NEW';
SELECTED='0';
}
CONTROL='U_EXTENDLABEL'
{
TYPE='LABEL';
X='24';
Y='130';
WIDTH='170';
HEIGHT='40';
Text='Extend life-expectancy each time program that
uses smurfs accessed:';
}
CONTROL='U_LIFE'
{
TYPE='EDIT';
X='228';
Y='96';
WIDTH='100';
HEIGHT='22';
VALUE='1';
}
As you can see, it's a simple matter to define your field names, locations and dimensions. And it's even easier to do when you use another snippet as your starting point: just find one that's reasonably similar to what you need and adjust the text, field names and coordinates as required.
Further down in the code for this snippet you'll find this line:
VALUE='gensmurfid(&%OPT#, &%DUR#, &U_LIFE#, "&U_EXTEND#",
"&U_PERSIST#", "&U_ENCRYPT#");';
This statement merges the values selected by the user, for the options provided, and generates the line of PML. And that's about all there is to it!
We are excited about this new IDE tool, even for our own use in developing applications. We're also on the lookout for other features and functions to add to the list of SmartSnippets we'll be shipping in the first set. So if there's one you'd like to see, and you're struggling to add it yourself, let us know and we'll add it to our to-do list. WebSmart 6.7 includes several different kinds of SmartSnippets, which present a wide variety of prompts and fields, so when you start to create your own new ones you shouldn't have too much trouble finding a solid starting point to work from.
If you have any questions about WebSmart 6.7 or SmartSnippets, please drop us a note.
Check out the New WebSmart Example Programs!
The Technical Support team took advantage of the late-December lull in support calls to create several more WebSmart PHP and ILE example programs. You'll find the latest additions at the top of the list at our website. The new examples are:
- Example 146 - Create an AJAX tooltip. Follow the instructions outlined in this example to add sophisticated AJAX tooltips to your record lists (illustrated below).
- Example 145 - WebSmart PHP Date Conversion. This program illustrates a programming technique you can use to convert several different date formats to YYYYMMDD.
- Example 144 - Use this example to help you add cookies to your WebSmart PHP programs. This example shows you how to set, retrieve and clear cookie values in your programs.
- Example 143 - Example 143 will walk you through the process of building two WebSmart PHP programs linking files with a parent/child relationship, with a customer maintenance program calling an order listing.
- Example 142 - Use a calendar pop-up in WebSmart PHP to populate your date fields.
Here is an example of the program in Example 146. The user has rolled the mouse over the first record in the list, and the tooltip immediately displays an illustrated item description:
Using AJAX to pop up a tooltip when the user mouses over a record.
If you have any questions about any of these programs, please drop a note to Technical Support.
Remember that we're always on the lookout for ideas for new examples, so if there's something you need to add to your website that you're finding a little challenging, and which you think others might also want to use, drop us a note and we'll take a crack at building it for you!
|
WebSmart Fundamentals Training in Atlanta, GA
The 4-day WebSmart Fundamentals public training class on the week of January 28-31 in Atlanta, Georgia is almost full! To sign up for this class, or request further information on future classes, please fill out our online training request form.
January is the perfect time to take advantage of training opportunities on fresh budgets and low ticket fares, and also a great time to take some time out from the cold.
If you you fly in a couple of days early, you can catch the 2008 NHL All Star game, or if you prefer natural wonders, be sure to make some time to climb Stone Mountain and immerse yourself in the new Georgia Aquarium, currently the world's largest.
Course Content
The WebSmart Fundamentals class is a comprehensive course that will give you a working knowledge of all the areas you need to be familiar with in order to begin developing applications with WebSmart. The course begins with an introduction to HTML (page structure elements, tables, images and links), then continues on to creating simple WebSmart programs. As you familiarize yourself with the tool, you'll add more features to your application: passing parameters between programs, customizing file access, and then prompting users for input and validating what they enter.
The class concludes with some exercises in securing applications, SQL, WebSmart’s Change Management interface and the new interactive debugger integrated into the WebSmart IDE.
Nexus 3.35 Available: Improved Firefox Support for Nexus Users!
Nexus 3.35 is now available for download. In addition to several other fixes and minor enhancements, version 3.35 now includes much better end-user and administrator support for Firefox.
Browser/CSS compatibility issues are a headache for any web developer, and in the case of Nexus, which allows you to create very complicated and feature-rich pages, it has been a challenge to navigate the tricky waters of sorting out solutions that work for both Firefox and IE. However, as Firefox usage has grown steadily over the last couple of years, it has become imperative to improve Firefox support in Nexus. Once you install this version, both you and your users can work with Nexus in either of the two leading browsers, though some minor inconsistencies in functionality remain.
If you have any questions about how upgrading Nexus to version 3.35 will affect you, please contact Technical Support. Any further updates related to this feature will be posted at our website.
New WebSmart Site Gallery Entry: Kawasaki Canada
The latest addition to the WebSmart Site Gallery is Kawasaki Canada, who have used WebSmart to build an online application for their national dealers.
This application has a secure login where Kawasaki dealers access Order Entry and Inquiry screens, a very slick Parts Inquiry, Claims Warranty, Vehicle Booking and many others. The application using JavaScript and Ajax has adjustable windows on many screens. It also uses image functions to
create new vehicle registration forms with watermark required to register vehicles to the Ministry of Transportation. Kawasaki is the pioneer in the Canadian Motorcycle industry in providing this.
This site is secured, and only registered dealers can log in, but we've posted some screen shots in the gallery.
If you have any questions about this site and how it was developed, please contact Technical Support.
Colin Dams has been a member of our professional services group for the last year and a half. During his time with us, Colin has worked primarily on enhancing several of our customers' existing sites, as well as creating entirely new web applications using BCD's wide selection web development tools including WebSmart, Nexus and Clover.
Colin grew up in central Vancouver Island and has lived here most of his life, including while attending the University of Victoria. After completing a degree in Math and Computer Science, Colin took a job in Morioka, Japan creating software for Japanese hospitals. The culture, the people and the experience left an indelible impression as well as a healthy appetite for sushi.
A new addition to his family, Isaac, prompted Colin's return to Victoria where he joined us here at BCD, helping create business web sites. The chance for creativity and design inherent in web development, as well as working with and for many different people, were reasons enough for Colin to jump on the opportunity to join the group. Since joining, Colin has enjoyed growing his skill set to include areas such as user experience and usability, which he has put to good use creating intuitive site navigation and flows in a complex procurement system that he recently helped develop.
Outside work you'll find Colin in the great and rugged outdoors of the Pacific Northwest, in particular: hiking our many stunning trails, hunting elusive gourmet mushrooms and climbing spectacular cliffs.
BCD has been experiencing burgeoning growth over the last year, particularly in the area of Professional Services, where the rapidly expanding team is tackling an ever-increasing number of business websites for small and large customers.
Our latest addition in that corner is Chelsea Fenton. Chelsea is sort of a local, having grown up in nearby Shawnigan Lake. A recent Computer Science graduate from the University of Victoria, Chelsea comes to us with the experience garnered from some time spent doing contract work in web design for the provincial government.
Not quite ready to step into the radical rental rates on the lower island, Chelsea is doing a bit of commuting, driving in every day from Cowichan Bay. When she's not working or driving, Chelsea enjoys camping and the ancient sport of curling.
Current
BCD Software Release Levels
These are the current release levels for all our products:
If you have any questions about how to get to the latest versions, please contact
Technical Support.
Summary
List of Recent Updates
WebSmart 6.64 - Revision 1908
There is a new PC-side update for WebSmart 6.64 (December 19, 2007). This version includes all previous updates, and requires that you have version 6.64 installed on the server, with all server-side updates. Revision 1908 includes the following items:
- Resolves an issue allowing you to re-enable repository extensions.
- Allows you to use breakpoints in the Main function.
- Resolves issues with validation of field transformations (fromfmt, edit words).
You can download the latest PC and server versions of WebSmart from our website, or go to the WebSmart Updates page to download just the client side, and read more about this update and previous ones.
Organizations
that Recently Purchased BCD Software
Asian Life Financial Assurance •
Bell County Information Systems •
Bristol Hospital •
Certainteed North America •
Clallam County - Central •
Clay County •
Coresource, Inc. •
Fiserv Health - Kansas •
Forefront •
GE Energy PS España •
Grecian Delight Foods •
Guild Mortgage •
Hans Johnsen Company •
Hard Rock Hotel and Casino •
Human Service Agency •
ICICI Prudential Life •
Isoclima •
J. Polep Distribution Services •
JAS Worldwide Management •
Kent Europe •
King Koil Mid Atlantic •
LGI, Inc. •
Malcolm Niles •
NASBA •
Peppler & Associates •
Professional Management, Inc. •
RCL Systems •
Rimadesio •
Rosedale Products, Inc. •
South East Express •
The Wensum Corporate Company •
TRI Corporation •
UAIG •
Village of Arlington Heights •
Walton County Courts •
White Knight Engineered Products •
Zimag Logistics
|