Results 1 to 2 of 2
  1. #1
    chellede is offline Member
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Default Auto Complete - Please Assit

    Hi there! I inherited a website that is java based. I'm so frustrated because I am not a java programmer. I know enough to get by. I have been asked to take the text fields that are put into the database and create an autocompete from the database. I found a couple of examples, I just need some assistance in puttin the examples with what I currently have. I want to understand how to do this, I just dont know how to.

    Here's the website that I want to use (unless someone has other ideas)
    Ajax Tutorial: More Ajax Applications


    Here is my page

    Java Code:
                      <td width="90%" class="headGray">WARRANTY INFORMATION </td>
                      <td width="10%" class="headGray"><center>
                          <a href="javascript:collapseWarInf.slidedown()"><img src="/Intranet/images/plus.gif" width="9" height="9" border="0" /></a>&nbsp;<a href="javascript:collapseWarInf.slideup()"><img src="/Intranet/images/minus.gif" width="9" height="9" border="0"/></a>
                      </center></td>
                    </tr>
                  </table>
                  <div id="divWarInf" style="width: 100%;">
                    <table width="100%" border="0" class="tableBlue">
                      <tr>
                        <td width="20%" class="NormalBold">Puchase Order #:&nbsp;</td>
                        <td width="80%"><input name="txtPONum" type="text" id="txtPONum" value="<%=H.getPONum()%>" size="45"/></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Date Purchased:&nbsp;</td>
                        <td width="80%"><input name="txtDatePurchased" type="text" id="txtDatePurchased" value="<%=(H.getDatePurchased()!=null && !H.getDatePurchased().equals("")?Utils.MMddyyyy.format(H.getDatePurchased()):"")%>" size="45" onBlur="ValidateDate(this);"/>
                        <span class="WanView style2"> mm/dd/yyyy</span></td>
                      </tr>
                      <tr> 
                        <td width="20%" class="NormalBold">Vendor:&nbsp;</td>
                        <td width="80%"><input name="txtVendor" type="text" id="txtVendor" value="<%=H.getWarrVend()%>" size="45"/></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Vendor Contact:&nbsp;</td>
                        <td width="80%"><input name="txtVendContact" type="text" id="txtVendContact" value="<%=H.getWarrVendRep()%>" size="45"/></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Service Phone:&nbsp;</td>
                        <td width="80%"><input name="txtServicePhone" type="text" id="txtServicePhone" value="<%=H.getWarrServicePhone()%>" size="30"/>
                          <input name="txtServicePhoneExt" type="text" id="txtServicePhoneExt" value="<%=H.getWarrServicePhoneExt()%>" size="8"/></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Warranty Type:&nbsp; </td>
                        <td width="80%"><input name="txtWarrType" type="text" id="txtWarrType" value="<%=H.getWarrType()%>" size="45"/></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Warranty Start Date:</td>
                        <td width="80%"><input name="txtWarrStartDate" type="text" id="txtWarrStartDate" value="<%=(H.getWarrStartDate()!=null?Utils.MMddyyyy.format(H.getWarrStartDate()):"")%>" size="45" onBlur="ValidateDate(this);"/> 
                        <span class="WanView style2">mm/dd/yyyy</span></td>
                      </tr>
                      <tr>
                        <td width="20%" class="NormalBold">Warranty End Date:&nbsp;</td>
                        <td width="80%"><input name="txtWarrEndDate" type="text" id="txtWarrEndDate" value="<%=(H.getWarrEndDate()!=null?Utils.MMddyyyy.format(H.getWarrEndDate()):"")%>" size="45" onBlur="ValidateDate(this);"/><span class="WanView style2"> mm/dd/yyyy</span></td>
                      </tr>
                      <tr>

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    once the page is loaded, the auto complete will be rendered, displayed, hidden, populated with values, and allow the user to select a value in the pop-up baloon of possible values, - all by JavaScript.

    I would recommend creating a test bunch of JavaScript that implements the visual functionality (shows a baloon of options, lets you pick one, on picking one populates the corresponding text field). in a stand-alone page, like a simple flat HTML that just uses the javascript to do this. I would work to evolve a kind of generic parameterizable widget, or a function that you can call passing in the form text field name and allow this auto-complete engine with its general logic work on more than one text field on the screen if needed.

    When it works there in stand-alone mode, then work to have the values that get shown in the suggestion box be populated from the server side, if this is desired. For this, it would be a javascript driven (e.g. AJAX) call to a server-side request handler, that would be where the javascript autocomplete object (that we built in stand-alone mode above) would now invoke a request with some parameter, that you'd invent to hit a server-side (e.g. servlet) in your web application. this servlet would then do what ever is needed, like query the database for the possible matches and return the first few matches. the javascript back in the browser would then need to parse this and populate the values into the autocomplete suggestion list, which would be replacing the static text we had in the first self-contained version right.

    So really, this is a two-fold problem, getting javascript auto complete to work, and then getting the ajax servlet request handler and javascript client piece working. But both are really a lot of heavy on the javascript kinds of things.

    Now, there are several existing javascript frameworks that attempt to provide widget utilities and AJAX framework building blocks. The Yahoo user interface (YUI) toolkit is pretty easy to learn and is well documented. I also know of dojo, the google web toolkit, and a 'couple' more over here: List of JavaScript libraries - Wikipedia, the free encyclopedia

    Of course selecting a framework to use might depend on what ones are installed into this web site already. You might even have one that is just there and already in use, so just learning how to work withing how it is set up might save you from having to hack one of these other frameworks in.

Similar Threads

  1. Auto contrast and auto brightness
    By oxxxis in forum Java 2D
    Replies: 0
    Last Post: 01-21-2010, 08:32 PM
  2. Eclipse auto-complete lists duplicate methods
    By Red Hunt in forum Eclipse
    Replies: 1
    Last Post: 12-10-2009, 10:53 AM
  3. auto complete textarea
    By praba@spiretek.in in forum AWT / Swing
    Replies: 0
    Last Post: 11-16-2009, 07:06 AM
  4. Auto-complete/Auto-fix for custom statement
    By dark_cybernetics in forum Eclipse
    Replies: 0
    Last Post: 08-19-2008, 11:19 AM
  5. [SOLVED] Auto complete Text.
    By smartsubroto in forum New To Java
    Replies: 9
    Last Post: 06-27-2008, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •