Results 1 to 3 of 3

Thread: ajax problem

  1. #1
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default ajax problem

    "There must be a server-side handler that will process the AJAX request. The only requirement of this component is that it return an XML file that represents a list of results based on the query passed to it from the client-side AJAX functions."

    1. how do i transform java beans to xml on server side?
    my java bean has name and phone number column in a row.
    2. how do i extract data from xml on client side?
    i know i need to use javascript to extract it but the problem is when it has multiple rows and columns.
    3. Is there easier way? tnn

    i encounter this link about AjaxXmlBuilder.. AjaxTags DOC - can u help me build xml from my java bean with name and phone number column in a row and lastly decode it

    i have a javascript xml extractor but its only useful on a single string
    (var message =
    xmlHttp.responseXML.getElementsByTagName("valids")[0].childNodes[0].nodeValue;
    document.getElementById("results").innerHTML=messa ge;)

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    On the Web application server, you need a servlet to handle AJAX requests. In your client, you need code to interpret what the servlet sent back. You do not have to send or receive XML, it can be plain text or whatever.

    Rather than doing this all yourself, you should find a toolkit that provides the support on both sides. Google Web Toolkit is one option. You do everything in Java in your IDE, and it will generate Javascript for your client and appropriate code for its servlet on the server. I'm sure there are other toolkits as well.

  3. #3
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    Quote Originally Posted by anthrax View Post
    1. how do i transform java beans to xml on server side?
    my java bean has name and phone number column in a row.
    With your JSP you can also create XML instead of HTML.
    Set the ContentType of your response to XML And then create some XML Stuff.
    Java Code:
    <%@ page contentType="text/xml"%>

    Quote Originally Posted by anthrax View Post
    2. how do i extract data from xml on client side?
    i know i need to use javascript to extract it but the problem is when it has multiple rows and columns.
    You can do this with javaScript take a look at some of the JS Frameworks like jQuery, dojo, prototype ...

    Quote Originally Posted by anthrax View Post
    3. Is there easier way? tnn
    Yes, use some JAVA Frameworks the have a AJAX Support like Struts2 with dojo or jQuery plugin, GWT or Icefaces

    Johannes

Similar Threads

  1. ajax jsp tag problem (formupdate.view ?)
    By anthrax in forum Advanced Java
    Replies: 1
    Last Post: 12-20-2009, 04:51 PM
  2. JSP - AJAX problem
    By MaheshReddy in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 01:54 AM
  3. Jsp with Ajax
    By sundarjothi in forum JavaServer Pages (JSP) and JSTL
    Replies: 16
    Last Post: 09-25-2008, 10:29 AM
  4. Problem reading an xml file with AJAX
    By Fiona80 in forum XML
    Replies: 0
    Last Post: 12-17-2007, 08:02 PM

Posting Permissions

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