Welcome to the Web Developer and Business Applications Forum

Here's how you can participate: Below are the general forums where you can post. Select the one that best fits the topic you wish to address.

To create a new discussion thread/topic: click on the forum link below where you'd like to add your thread, such as Tips and Tricks Exchange. Then, once you've logged in, click on the New Topic link at the top. This will allow you to create a new thread.

To respond to a current thread or post: click on the forum where the post resides, then click on the link to the thread you are responding to, and at the top click the Reply link.

If you have any questions, please feel free to call us at 630-916-0662.



A Message Board, Guestbook, or Poll hosted for your website.
Register Login New Posts Chat
 
mrc > Forums > m-Power Tips and Tricks > Spice up your web apps with AJAX
 
Username:  
Password:  
 
   
 


Thread Tools Search This Thread 
Reply
 
Author Comment
 
mrcuser
Moderator
Registered: 11/29/05
Posts: 67

    05/12/09 at 09:56 AMReply with quote#1

Want to make your web application interface easier and more powerful? One way to do that is with AJAX.

AJAX stands for Asynchronous Javascript And Xml. This means that your end users can interact with the database without having to click the "Accept" button. Want to see an example? Check out the Report I built with this very documentation: http://www.mrcwindows.com/mrcjava/servlet/MRCFORUM.R00010s. Notice that when you start typing in the customer name, you get a drop-down list of suggestions based on what you typed. That's an example of AJAX functionality at work! For the purpose of this forum article, we'll call it "AJAX suggest".

What is it good for?
Now, you may be thinking, "Sure, it looks cool, but how can I use it in my web apps?" Here are a few ways it can help:

  1. First and foremost, the AJAX suggest feature helps usability. Maybe you don't know how to spell what you're looking for, or maybe it's a pain to type out. Either way, typing in a few letters and then choosing the correct option is much easier for the user.

  2. AJAX suggest can also save time. Let's say you work for a company that manufactures car parts and you want to run a report for a specific type of brake pad sold over the last 3 years. You could just start typing in "brake pad", and let AJAX suggest do the rest. It's far easier than scrolling through a list of products, especially if it's a long list.

  3. You can install certain Record Selections into your Inquiry to limit which records are available in your AJAX suggestion list. For example, you could limit a list to only show active customers, or, with the assistance of Advanced Record Level Security, limit records based on who is running the report!

Ooh…that sounds tricky
Some developers get nervous when they have to add powerful functionality like AJAX suggest to their reports. They fear that it will be too complicated and they may inadvertently break something else in the process. Is this you? What if I told you that you could add this AJAX suggest feature to your Reports or Maintenance screen in three steps? Don't believe me? Let's try it:

(These directions are for customers who are adding functionality to applications built after May 8th, 2009. For older applications, please refer to these instructions).
  1. Build a standard Multiple Record Inquiry over the table that will serve as the list for your AJAX suggest dropdown. Nothing special has to be done to the inquiry, just make sure you note the correct field name.

  2. After building your retrieval, let's build the report (or single record maintenance) application that you wish to contain AJAX suggest functionality. For this document, we will assume you want to add the functionality to a report.

    • Be sure to add a Record Selection with a value of "?" for the field that will have the AJAX function (Without the record selection, your end user would not be able to select any records!).

    • Once the report is built, head into m-Painter.

    • Click the Page dropdown & select Prompt.

    • Click the Source button

  3. I assume some will be trepidacious about making changes in the source, but this is the easy part!

    • Find this text:
      Code:
      </head>
      

      Directly before it add this code:
      Code:
             <script type="text/javascript">
             window.onload = function(){
             set_ajax_suggest("DD.I99999s", "RET FIELD",  "R001");
              } 
            </script>
      

      Note: Maintenance applications already have an onload function by default, so if including with a Maintenance application, simply insert the one line beginning with set_ajax_suggest.
      Note: If calling a Maintenance application replace R001 with the name of your field from your maintenance application.

    • Replace DD.I99999s with the correct data dictionary and application name that you built in Step #1. Replace RET FIELD with the name of your field from the Retrieval in Step #1. Replace R001 with the correct number of your record selection (if necessary) [R001 assumes the first record selection].

    • Find the following text (Replace R001 with the correct record selection number, as necessary):
      Code:
      <input value="${select.R001}"
      
      Once you have found the above text, add autocomplete="off". This stops the browser from offering your end users previously typed values, which would block the view of your AJAX.

That's all there is to it?
That’s it! Click “Save” and enjoy your AJAX functionality. See, wasn't that easy?

Note: Was your application built before May 8, 2009 and you want to add the above functionality? The process is just as easy, but you will have to add a few more sections of text. Click here to find out how!

__________________
User Forum Moderator
mrc
555 Waters Edge, Ste 120
Lombard, IL 60148
mrc@mrc-productivity.com
http://www.mrc-productivity.com
Previous Thread | Next Thread
Reply

  Bookmarks  
Digg Diggdel.icio.us del.icio.usStumbleUpon StumbleUponGoogle Google

mrc (US)
555 Waters Edge
Suite 120
Lombard, IL 60148
630-916-0662
mrc (UK)
Argyle House
1 Dee Road
Richmond, Surrey
TW9 2JN
+44-20-8322-7720