If I understand your code correctly, its actually doing exactly what you've 
asked it to do.

You are calling a method called 'setCurrentBook(......))' which doesn't seem to 
do anything very much.

You are then defining a callback 'public void setCurrentBook(String bookname)' 
blah...

You are then *invoking* the call back
      bookServicesHolder.loadBookByName(bookName, callback);

Your call back sets a variable called 'currentBook' and I cannot see what you intend this to do from the code provided, but, as written, its not going to do anything very much. If if is a global variable then you will never get the result you require.

You need to carefully re-read the section in the GWT docs about Asynchronous calls. If you are using GWT you *MUST* use and fully understand asynchronous RPC - that's what Ajax is all about.

It *should* go something like this.

* Define an RPC callback for a particular service typically by using an 
anonymous inner class.

* Invoke the call back specifying the data object (book) you want to read

* On the successful asynchronous return, update the UI, by calling the update method from within the callback onSuccess method. There are many, many examples out there.

In short, don't update the UI until the callback returns.

If you don't want to make these calls asynchronous, then convert your program to a more servlet-centric approach. There are a (large) number of other web frameworks which will do this for you. GWT is all about Ajax and RPC.

HTH

Alan








On 1/3/2011 12:17 PM, Cesar Ruiz wrote:
It is also saving more books when reloading the page (but I dont care much about it as that wont be too painful to fix). But please I need some help on the RCP asyncronous calls. What workaround can I do?.

Kido.

On 3 January 2011 19:23, Kidowell <crui...@gmail.com 
<mailto:crui...@gmail.com>> wrote:

    Hello, I'm doing a project where in the interface shows a listBox that
    includes the names of some books, the thing is that you must choose
    one and you will look wether in pdf or txt. My problem is that when
    changing the listbox, itll show the just last book you chose, rather
    the current one.

    heres the program so far.

    http://kido180020783.appspot.com/


    Here's the part of the code that presents the problem.

      setCurrentBook(bookList.getItemText(bookList.getSelectedIndex()));
                   if (pdfFlag) {
                       if (!txtFlag) {
                           pdfBook.setSize(booksPanelWidth,
    booksPanelHeight);
                       } else {
                           booksPanelWidth =
    String.valueOf(BOOKS_PANEL_WIDTH / 2);
                           pdfBook.setSize(booksPanelWidth,
    booksPanelHeight);
                           txtBook.setSize(booksPanelWidth,
    booksPanelHeight);

                       }
                       pdfBook.setUrl("pdf/" + currentBook.getUriPath() +
    ".pdf");
                   } else {
    ......

    //This method is being called AFTER the line " pdfBook.setUrl("pdf/" +
    currentBook.getUriPath() + ".pdf");" wich is weird!!!!!!.
     public void setCurrentBook(String bookName) {
           AsyncCallback<Book> callback = new AsyncCallback<Book>() {

               public void onFailure(Throwable caught) {
                   throw new UnsupportedOperationException("Not supported
    yet.");
               }

               public void onSuccess(Book result) {
                   currentBook = result;
               }
           };
           bookServicesHolder.loadBookByName(bookName, callback);
       }



    I dont want the method to be Asyncronous, please I really need some
    help.

    --
    You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit"
    group.
    To post to this group, send email to google-web-toolkit@googlegroups.com
    <mailto:google-web-toolkit@googlegroups.com>.
    To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
    <mailto:google-web-toolkit%2bunsubscr...@googlegroups.com>.
    For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.




--
Cesar Ruiz.
--
You received this message because you are subscribed to the Google Groups "Google 
Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google 
Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to