Hi, and my first post

Hi, my name is Al Rodriguez. Have been with IBM since 1989; proud member of WebFacing team since 2005.

I will try to contribute posts related to WebFacing, mainly in the areas of customization and configuration. Let the remaining of this post be my first customization tip: Enhancing date input fields with a calendar widget. This tip reflects my opinion, and is in no way:

  • complete,
  • recommended,
  • supported,
  • well written … sorry.


Introduction

WebFacing is not just another screen scraper. Webfacing converts display files into standard J2EE artifacts, that can be understood and molded by Web designers.

WebFacing supports a large subset of DSPF keywords, but not all. The list is largely driven by customer input and is maintained here: list. There are many reasons why not all keywords are supported; they range from complexity to them representing 5250 concepts not applicable to web applications. But, let this be the subject of a future post… My point here is that it is very likely that initial conversion of set of DSPF’s by WebFacing will result in a working web application. But to generate a best of breed web application; some DSPF rework (not requiring logic changes), and web design work is likely required.

A strength of WebFacing lies in customization. But well designed web pages do not just happen; they are the result of creativity and web technology expertize.

This post illustrates several WebFacing customization techniques by adding calendar widgets to input date fields.


Background

Could create your own JavaScript calendar, or use one of the many available calendars on the web. Beware that some of these may be buggy / unsupported. In this post a calendar provided by Yahoo is used. Yahoo provides a library of consistent, widely used, open source UI Web controls; commonly known as the YUI library.

To use the calendar in a general web project, one would need to:

  1. Download files to project folder(s) and include required .js files in your source. For calendars the following would be required. Please note that yahoo.js needs to be included first; the order of the rest is not important:
    text1.gif
  2. Add code to instantiate, handle events, initialize, and display calendar. Links of interest: YUI Library, YUI blog, YUI theater, Yahoo design patterns

Prerequisites

There exists a 5250 application that includes input field used to collect dates.
52501.gif

Application has been WebFaced.
wf.gif

Incorporating calendar to WebFacing.

Adding the calendar to the WebFaced application is as easy as 1, 2, 3:

  1. Incorporate YUI files into project.
    folder.gif
    Please note that ‘usr’ folder is special in WebFacing; any .js files in it are included automatically in every page at run-time. The order in which these are included is unpredictable. If order is important files should be included separately. YUI requires that yahoo.js be included first; this could be done by adding the following to PageBuilder.jsp:
    text22.gif
  2. Create your own JavaScript code.
    Create new .js file (arod.js in folder structure above). Place it in ‘usr’ folder for automatic inclusion in all pages.
    Below, function initCal() shows the calendar; it also instantiates, registers selection handler, and renders calendar if necessary. An array of calendars is used to support multiple calendar instances in a page. Function handleSelect() is registered as handler and is called by the calendar when a selection is made; this function sets the value of the field with the selected date, and hides the calendar.
    text32.gif
  3. Tie it all together with Web Settings. Web Settings allow developers to customize the way DSPF files, records, and fields are rendered in a WebFacing application. As the name implies, Web Settings affect the way data is presented on the Web; they have no effect on existing 5250 behaviour. Web settings are persisted as special comments in the DSPF source. To have Web Setting changes reflected in the application re-conversion and re-publishing is required.
    Web settings can be configured in the Web Settings view. Open DSPF, select field, and use Web Settings view; notice that selections in this view are reflected as comments in source view. Only two ‘HTML override’ web settings will be used in this example:
    One inside the input field description to add a onmouseover event handler
    ws21.gif
    The other one after to create a <div> area to contain the calendar.
    ws12.gif

Done! The end result is that a calendar will pop up below the text field as the cursor hovers over it. Selecting a date in the calendar updates the value in the text field, and hides the calendar.

wfcal.gif


20 Comments on “Hi, and my first post”

  1. Edmund Reinhardt says:

    Very impressive, complete and useful.
    Thank Alfonso!

  2. This is good stuff and I’m glad to see YUI + WebFacing!

  3. Bert Rutledge says:

    The date field doesn’t lool like it is defined in the DDS as a date? Would this technique work with a screen field defined as a date?

  4. Al Rodriguez says:

    Hi Bert. Yes, it should work just fine. If field is defined as

    A C1FLD1 L B 2 11DATFMT(*ISO)

    in the DSPF. It’s initial value will be displayed as ‘2007-07-15’. The rest should work as described, that is selecting date from calendar will set field value to ‘20070405’.

  5. John says:

    Hello,

    I’m trying to make a simple hyperlink in a dds file in my new webfacing project. This is the way the WDSCi will make the Hyperlink

    A*%%WB 12 FLD 4 fld=|value=|func=ENTER

    I want to be able to do something like this…

    A*%%WB 12 FLD 4 fld=|value=+
    A*%%WB +|func=ENTER

    because the menuopt field in the display file has an edit word

    A MENUOPT R O 6 2EDTWRD(‘ 0.’)

    and the “.” is making the OPTCODE invalid in my aplication.

    Do you have any suggestions???

  6. VSelders says:

    This looks to be something really great. I apologize, up front, for my lack of skill here, but … I’m getting an “error on page” indicating that YAHOO is undefined. Certainly there is something obvious I am overlooking … please help

  7. Al Rodriguez says:

    Hi V,

    Error indicates JavaScript run time resolution problem; that is, a required js include is missing.

    YAHOO is a global variable, used by YUI to preserve namespace object. It is defined in yahoo.js. Has yahoo.js been added to project, and included in pageBuilder.jsp?

  8. Al Rodriguez says:

    Hi John, No suggestions off – hand. Please try posting question to:

    http://groups.google.com/group/ibm.software.websphere.studio400

  9. VSelders says:

    Thanks for your response and attention, I used the sample code, but wasn’t exactly sure where to put it. I tried it at the top and in the middle

  10. VSelders says:

    In an attempt to be more clear, I have the .js in place as depicted in diagram 1. Underneath that is a snippet of code for PageBuilder.jsp, followed by the code that goes in arod.js (per your example). Specifically, I don’t understand where to put the code in PageBuilder.jsp.

  11. Al Rodriguez says:

    I added the lines to the section, immediately following the style css .

  12. VSelders says:

    Al, thanks a ton, I don’t have it quite yet, but the fun part is making it work. Good job!

  13. Al Rodriguez says:

    You are welcome. Just read my last reply; looks like the blog tool ate some of my characters. It should have read:

    I added the lines to the <head> section, immediately following the style css <link>

  14. VSelders says:

    Starting over, but to be sure, we’re running V5R3 at this point, I don’t know if or how that relates to Webfacing, but I want to make sure that is my sticking point. Suffice it to say, I think I need to find a nice green screen shop and hole up! Sorry for the frustration.

  15. Al Rodriguez says:

    I used WDSC 6.0.1.3 and a V5R4 host to develop the example, there should be no problem using a V5R3 host.

    One suggestion is to first get familiar with JavaScript and the YUI library on their own; independent of WebFacing.

  16. Hey, I have written some similar javascript to this and I’m using it inside of a web page.
    The Textfield to calendar functionality works, but when I attempt to populate the textfield, nothing happens. I have placed an “alert” inside of the ‘handleSelect’ function, but it isn’t being called.

    I have the subscribe call in the script also.

    The text just isn’t getting populated, any ideas why?

    I would really appreciate your feedback, I looked all around the Yahoo! forums, theres nothing explicit. I’m thinking its a browser issue, but I need some kind of direction to go on. Please help!

    P.S. I have Firefox, Opera, and IE 5+. It doesn’t work in any of them.

  17. […] 20th, 2007 A previous post by one of this blog’s authors Al Rodriguez highlighted the potential power of WebFacing […]

  18. […] support? Better Subfile UI? Content Assist (e.g. Calendar widget for date […]

  19. irreddyirrado says:

    kznzpzayfqqtrelwwell, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch ;)


Leave a comment