YOUR FEEDBACK
andy.mulholland wrote: intriguing !!! We have full scale 'Mashup Factories' in Chicago USA and Utrec...
AJAXWorld RIA Conference
Early Bird Savings Expire Friday Register Today and SAVE !..


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
POWERBUILDER LINKS YOU MUST CLICK ON


Incorporating Popup and Lookup Windows into JSP HTML DataWindows
Incorporating Popup and Lookup Windows into JSP HTML DataWindows

When moving applications to the Web, one of the challenges facing developers is how to migrate rich client features to a browser environment.

Two features that can give your Web applications a boost in both appearance and functionality are popup calendars and lookup (search) windows. They both apply the same concept - create a mapping between an HTML DataWindow column on a parent window and a selection made in a child window. In this article I provide an overview of how to leverage this mapping and incorporate these two common features into a Web-based application.

Popup Calendar
The Internet is rife with popup calendars. We've all encountered this functionality when making a flight or hotel reservation. Click an icon and a calendar pops up in its own window; choose a date and your selection appears in the input field of the parent form. What are the inner workings of such a feature and how do we create a common calendar object that we can associate with a date or datetime column in an HTML DataWindow?

Figure 1 shows a simple DataWindow containing two date fields, beg_dt and end_dt.

We return the date selected from the popup calendar to these fields. Two things need to occur to make the popup calendar feature work. First, the JavaScript that displays the calendar needs to be triggered; second, the user's date selection needs to be returned to the corresponding date field on the parent page. Let's start by diving into the JavaScript.

calendar.js will contain three functions (see Listing 1). The openCalendar function receives a column (fieldname) and row parameter. This allows the popup window to return the selected date to the correct column and row in the parent window. This function also calls the HTML page that's used to construct the calendar (see Listing 2). The setDate function sets the selected date back into the proper field on the parent window.

Once the JavaScript is written, the next task is to figure out how to trigger it. One way is to add a computed expression to our DataWindow and then code that expression to render as HTML in the PB NVO calendar object. Referring back to Figure 1, the computed expression associated with the beg_dt field is:

'<img border="0" src="images/popcalendar.gif" width="20" height="15"
style="cursor:hand"onClick="openCalendar( ~'beg_dt~', event, ~'1~' );" >'

This expression will create an image that, when clicked, calls the JavaScript and passes the required parameters.

Assuming a PB NVO has been created, we now need to code the of_html function for this object. This is the code that will force the above computed expression to render as HTML using the modify statement as shown:

datastore ds
string sz_html
ds = create datastore
ds.dataobject = "d_calendar"
ds.InsertRow(0)

ds.Modify
("c_beg_dt.HTML.ValueIsHTML='YES'")
ds.Modify ("c_end_dt.HTML.ValueIsHTML='YES'")
sz_html =
ds.object.datawindow.data.html
destroy ds
return sz_html
Now a calendar icon will appear when the code is rendered in a browser. Clicking the icon will cause the popup calendar to appear. Thanks to the calendar.js JavaScript, any selection made on the calendar will be sent back to the associated date field.

After the calendar object and its associated HTML DataWindow have been coded, the object needs to be published to EAServer. Once published, we can export Java stubs so that a JavaServer Page (see Listing 3) can use those stubs to call the back-end component, in this case the calendar object. The JSP will import calendar.js so it knows how to display the popup calendar. Remember, calendar.js calls calendar.html (see Listing 2).

HTML Lookup Windows
Most rich clients use lookup windows of some type to look up and select values. What happens when we try to migrate this functionality to the Web? Consider an HTML client sales order form in which a user selects an item from a dropdown list of products. For a big company, this product list would be unreasonably large. Then consider that for a 10-line order form, the same list of items will be retrieved 10 times. You can see the problem: massive amounts of redundant data flowing over the network, consuming bandwidth and server resources. Add to this dysfunction the inability to display multiple columns (i.e., product description, size, and price) in a dropdown ListBox and it becomes apparent that it's time to search for a better, more efficient solution.

Consider an approach in which a user can create a product list based on some search criteria. For example, show me products under $10, or size medium and color red. The benefits would be twofold: no list of products would be generated until a search criteria was entered and only products matching the search criteria would be retrieved. Sounds ideal, doesn't it? Well, it's a reality. And it takes place in an HTML lookup window.

The HTML lookup window is implemented much the same way as the popup calendar. We place an icon next to an input field, the user clicks the icon, and a child window is spawned. After the user makes a selection, it's sent back to the parent window. As with the popup, we create a mapping between the lookup window and its parent window. This mapping is the point of departure from the popup's functionality. Unlike the popup, when we implement an HTML lookup window we need to map both a data and a display value. This approach is derived from the DDDW attribute that allows for the selection of a column for data and a column for display. The advantage to this approach is that we can display multiple columns. When a user selects a given row or multiple rows, we're able to distinguish the data value from the display value.

The lookup window can also be coded to prompt the user for criteria on which to base its display list.

About Dean Jones
Dean Jones is the founder of two companies: PowerTeam, Inc., a consulting company, and Outlook Technologies, Inc., an Internet service provider. A member of TeamSybase and a certified PowerBuilder developer professional, he's been developing with PB since version 2.0a.

PBDJ LATEST STORIES . . .
Virtualization is actively being used by Sybase IT to help solve power/cooling issues as well as transform the datacenter into an environment that brings greater benefits to their customers, especially the engineering organization. Average CPU utilization was very low on physical serve...
Must have at least 5 years of recent experience (within the last 7 years) in building, testing, and supporting complex (multiple interfaces with database(s) and other applications) and mission-critical Windows applications using PowerBuilder. Must have at least 5 years of experience wr...
Join Scott Guthrie as he discusses Microsoft’s commitment to web standards development, Rich Internet Applications and how Microsoft is contributing to help move the web forward. Join Adobe’s Kevin Lynch as he demonstrates how Flash and HTML come together to make the most engaging,...
Particularly in a means of moving PowerBuilder applications to the web. What I’m looking for doesn’t require a server license or the installation of unmanaged code to the web server, and works well across different browsers (not just Internet Explorer). The WPF DataWindow will help...
"The rise of Enterprise Architecture is proof that organizations need to manage the impact of changes in competition, technology and regulations across their enterprise," said Dan Lahl, director of Intelligent Enterprise for Sybase. "PowerDesigner 15's unique Link and Synch technology ...
With PowerBuilder 11 Sybase gave developers what we have long hoped for – the possibility of taking an application created in a client/server architecture and turning it into a Web application, almost without having to move the code; and it's better if you don't use a server applicat...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING POWERBUILDER / SYBASE NEWS
Medmatics, LLC, a leading vendor of on-demand, anticoagulation software for private practices and ho...