File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes reponseXML  empty Ajax/Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "reponseXML  empty Ajax/Struts" Watch "reponseXML  empty Ajax/Struts" New topic

reponseXML empty Ajax/Struts

RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
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...


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


[ September 13, 2006: Message edited by: RoshaniG Gopal ]
(Added code UBB tags)
[ September 14, 2006: Message edited by: Merrill Higginson ]

Regards,<br />Roshani
Anay Nayak

Joined: Aug 15, 2006
Posts: 26
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

Joined: May 15, 2006
Posts: 180
Hi Anay,

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

Thanks again...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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!

Consultant, Sima Solutions
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
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.

Pandu Rangam

Joined: Dec 08, 2006
Posts: 24
This is very useful information.
Thanks a lot

SCJP 1.4,<br />SCWCD 1.4
I agree. Here's the link:
subject: reponseXML empty Ajax/Struts
It's not a secret anymore!