• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reponseXML empty Ajax/Struts

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Posting again..I am doing a double combo box with Ajax on Struts. I have all things in place..(I believe so) but i cant get the output on the JSP... Struts 1.2.9, JDK 1.4.
I had SOPs in the Class and I get the structure of the XML correct as made by the class. Ive checked out Merrill's link and made all necessary changes. Even Eric helped me some network error, but i cant seem to get the response on the JSP.. On IE the readyState goes on like 1-2-3-4. and it goes in the Loop for the reponse. But XRows.length returns 0. Dunno y??? PLEASE help...
------------------
Index.jsp
----------

--------------------

SecondOptionsAction.java
-------
------------------
struts-config.xml...
-------

-----------------------
I dont understand where I am doing wrong... Any help would be appreciated..

Regards,
Roshani

[ September 13, 2006: Message edited by: RoshaniG Gopal ]
(Added code UBB tags)
[ September 14, 2006: Message edited by: Merrill Higginson ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i can see two errors...

1)StringBuffer strXML= new StringBuffer("<?xml version=1.0 ?>"); the value 1.0 shoud be in quotes. new StringBuffer("<?xml version=\"1.0\" ?>");

2) You have not defined objddl variable
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anay,

Thanks a lot... Well your effort has helped me do the ajax implementation sucessfully..

Thanks again...
Cheers!!
Roshani
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't examined your code thoroughly, and couldn't tell you exactly what's wrong, but here are a few thoughts:

1- I'd suggest you actually create the second select box without any options in the first JSP rather than trying to build it from scratch in JavaScript. If you don't want it to be seen, you can easily use CSS to hide it (style="visibility:hidden") and then make it visible after the AJAX call. If you do it this way, you only have to worry about populating the options.

2- If you read my post referred to above, you should also note the comments I made about the responseText property vs. the responseXML property. The rule is, if you don't have perfectly formatted XML, the responseXML will be blank, and the responseText property will have the value. If you're not real familiar with JavaScript's XML parsing functions, you might be better off sending plain text and using String functions to parse through it.

3- Even though I've written a lot of dependent select boxes, I've done all mine using the DWR framework, which I find much easier to implement than writing the AJAX calls and parsing the data myself.

4- Here is a link to a BLOG entry of someone's code who is doing exactly what you're trying to do. You may find it helpful.

5- Good luck!
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
Thanks a lot for your inputs. I wanted to use ResponseXML as the client wanted to do so...(reasons??).
And yes, I read all your inputs on all the topics..Its so nice of you and all others who spare their precious time and give valuable suggestions.

I had already checked the link to the blog that you referred to. But of all the links that I found on net were either incomplete ( they were pointers to the way to do it) or they were on .NET. For a person like me, who understands little of .NET/VB the material was of little use.Plus none of them was on Struts framework with interaction with the DB.

Now that i have implemented it, I would like to give that code so that it may be put on javaranch and anybody else may be able to use it straight away. If you feel it would help people, i can post the working code.

Regards,
Roshani.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is very useful information.
Thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic