You have to accept the asynchronous nature of RPC-Requests in GWT and
stop trying to build smth. synchronous around them. This code:
-----------------------------------
doc = getDoc(); //(where doc is a Document object)
String subject =
doc.getElementsByTagName("Image").item(0).getChildNodes().item(1).toString();
String subject2 =
doc.getElementsByTagName("Image").item(1).getFirstChild().getNodeValue();
-----------------------------------
should not be executed in the onload-routine but in the
onResponseReceived()-method (or in any other procedure that you call
out of it).


On 10 Nov., 07:12, mives29 <[EMAIL PROTECTED]> wrote:
> hi all. ive re-done my code just a while ago(been a busy week) and my
> code kinda bothers me.  here's the code re-done:
>
> Entrypoint onModuleLoad() method:
>
> doc = getDoc(); //(where doc is a Document object)
> String subject =
> doc.getElementsByTagName("Image").item(0).getChildNodes().item(1).toString();
> String subject2 =
> doc.getElementsByTagName("Image").item(1).getFirstChild().getNodeValue();
>
> Entrypoiny getDoc() method:
> public Document getDoc() {
>           XmlParserUtil xmlParser = new XmlParserUtil("image_uris.xml");
>           int i = 0;
>           while (doc==null) {
>                   doc = xmlParser.getDocument();
>           }
>         return doc;
>   }
>
> here's the service implementation:
> public class XmlParserUtil {
>         String url;
>         Document doc;
>         RequestBuilder requestBuilder;
>         public String xmlStr;
>
>         public XmlParserUtil(String xmlFileName) {
>                 this.url = xmlFileName;
>         }
>
>         public Document getDocument() {
>                 RequestCallback xmlRcb = new RequestCallback()
>                 {public void onResponseReceived(Request arg0, Response arg1) {
>                         xmlStr = arg1.getText();
>                         doc = XMLParser.parse(xmlStr);
>                 }
>                 public void onError(Request request, Throwable exception) {
>                         // TODO Auto-generated method stub
>
>                 }};
>                 try {
>                         requestBuilder = new 
> RequestBuilder(RequestBuilder.GET,url);
>                         requestBuilder.sendRequest(null,xmlRcb);
>                 }
>                 catch (RequestException ex) {
>                         GWT.log(ex.getMessage(), ex);
>             }
>                 return doc;
>         }
>
> }
>
> my problem is on the Entrypoint logic. you see the getDoc() method
> there?
>
> it has this:
>
>           while (doc==null) {
>                   doc = xmlParser.getDocument();
>           }
>
> which just loops around until the service implementation has already
> populated the parsed document.
>
> what bothers me with this code is that it seems to break AJAX. the
> execution "stays" here until the document object is not null anymore,
> which kills the purpose of using AJAX (coz it seems not asynchronous
> anymore).
>
> is there any lister that i can implement on my entrypoint class that
> "listens" if the service has already received a reply? (or a listener
> of that sort)
>
> thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to