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


Using the PFC Calendar with a Datetime Column
Using the PFC Calendar with a Datetime Column

In this article I'll share my experiences of working with the PFC DropDown Calendar and show you how to make this custom user object user-friendly. If you've tried to use this custom visual object, you may have discovered that the PFC Calendar won't populate a calendar if you use a datetime type instead of a date type column.

When I first tried to use the PFC DropDown Calendar with PowerBuilder 6.5, instead of the OLE calendar commonly used with PowerBuilder 5.0, I found I couldn't achieve its desired or declared functionality. Each time I accessed the date column with the datetime format column in it, the DropDown Calendar appeared blank instead of showing me a current date. And when I clicked the arrow on the Calendar, the date January 1, 1990, was implemented. This means that the PFC Calendar doesn't recognize the datetime column and therefore assumes it's incorrect and uses the predefined date of January 1, 1990. When the accessed field was blank, the Calendar produced exactly the same result.

After my first attempt at using PFC Calendar failed, I started to explore what might cause that kind of behavior and tried to determine the exact place the error occurred. As a result of my investigation, I discovered some pieces of logic missing inside the pfc_main/u_calendar object. I also learned about numerous reports made a few years ago addressing the issue of how to make PFC DropDown Calendar work with Sybase System 11, which uses the column types of datetime and smaldatetime. This problem has been fixed in PFC7, but my fix is so simple that it can be done easily regardless of the level of programming skills. Many people working with PB6.5 who wish to take advantage of PFC fixes just export the services in PB7 and import them into PB6. Many stand-alone services import into PB6 with no problems. This is one of them, although it may also require applying a fix to u_dw or even u_base, where pfc_u_calendar is inherited.

The following solution will make your PFC Calendar perform the same way no matter what date format is used.

  1. Go to pfc_main/u_calendar and open it.
  2. Go to Declare/User Object menu in the menu bar and open of_Reset function. Basically, of_Reset function serves to reset the u_calendar to the date that displayed in the DataWindow column or EditMask control. It's protected, which means you can't access it from your application, but you can make the necessary changes to its script.
  3. Find the following comment in the of_Reset function's script:
//gets the current date from the requesting object
Then find the script:
ls_date = idw_requestor.GetText()
below the comment, and add the following lines of code right after that line:
If ls_date = " " or IsNull(ls_date) then
Of_SetDate(today, ib_initialvalue)
End if
What does that code do and why do we need it? The code you just added checks whether string ls_date has any value in it. If it doesn't, the script calls of_SetDate() function, which sets the current date, optionally updating the date in the associated DataWindow column or EditMask control. Idw_requestor is used for DataWindow columns.

You should then add exactly the same code for the same reason after the line:

ls_date = iem_requestor.Text
where iem_requestor is used to implement DropDown Calendar on the EditMask control.

Now go ahead and locate the comment:

//Validate the date. //Keep track if the date was valid or not
Add the following line of code right after the last comment:
ls_date = Left(ls_date,10)
This code will give you a string ls_date in date format, removing the time value if your format is a datetime. We need that line because the second line of code will convert the string ls_date into a date format and apply that value to the instance variable id_resetdate, used as one of the arguments for of _SetDate function.

Each time your string is null or empty, the logic will call and execute of_SetDate() function, which otherwise will be missing. When you use the datetime format in our DataWindow, its script will correct the string that contains datetime-formatted data and transform it into a date format.

Finally, save all the changes and exit pfc_main/u_calendar object. Your PFC DropDown Calendar is ready to go.

To register columns you want to use with the PFC DropDown Calendar in your u_dw DataWindow control, you should enable the DropDown Calendar calling the u_dw of_SetDropDownCalendar function and then use the of_Register function. In that function you can specify column names you want to register or register all eligible columns using a specified display style. The default display style is NONE or 1. The default style will display the calendar automatically when the column of DropDownListBox style gives focus and doesn't display automatically when the column is of Edit or EditMask style; instead, you display the calendar by coding the call to the u_dw_pfc_DDCalendar event.

If you use the DropDownListBox style and the default display style, you can write the following code in your DataWindow constructor event:

This.of_SetDropDownCalendar(TRUE)
This.iuo_calendar.of_Register("column name", this.iuo_calendar.NONE)
iuo_calendar is the instance name of u_calendar. If your columns are of Edit or EditMask styles, you may use style 2 (DDLB) or 3 (DDLB_WITHARROW). For both of these styles function will convert registered columns to the DropDownListBox edit style. The user displays the calendar by clicking the down arrow, which disappears (style 2) or remains (style 3) after the calendar displays.

Your need to display the calendar on registered columns depends on some specific conditions. In this case you should use u_dw function of_SetDropDownCalendar (Boolean). Boolean specifies whether to enable (TRUE) or disable (FALSE) the DropDown Calendar.

Figure 1 shows the DropDown Calendar is populated when the registered date column gets focus; in Figure 2 the same DropDown Calendar is populated on the same column but with no date in it. Therefore the current day is shown.

Now you can run the application and enjoy your PFC Calendar.

About Oleg Podgoretsky
Oleg Podgoretsky, a senior application engineer and designer for UserTechnology Associates in Arlington, Virginia, has worked with PowerBuilder since version 5.0. He has a master's degree in aerospace from Leningrad (now St. Petersburg) Engineering Academy and a PhD in technical sciences.

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...