Sending a value from a celltable to a view

33 views
Skip to first unread message

Sandney Farias

unread,
Aug 24, 2011, 4:31:04 PM8/24/11
to google-we...@googlegroups.com
I'm using a celltable and trying to send the register key when the user click in one item. My first doubt is about the correct way to send and get this value. 
This the code to send the value

selectionModel
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

                public void onSelectionChange(SelectionChangeEvent event) {
                    Banco selected = selectionModel.getSelectedObject();
                    
                    if (selected != null) {
                        History.newItem("RootPlace:banco/"+selected.getKey());
                    }
                }

            });

I'm getting the value in this way Window.Location.getHash().substring(Window.Location.getHash().indexOf("/")+1) as a string, that can't be cast to a key value

As you can see my doubt should be very stupid but I googled a lot and found nothing that could help me to solve the question. 

I apologize if my question is very basic and appreciate any response or indication of page where I can find a way to solve my problem.

Thank's Sandney

Abduxkur Ablimit

unread,
Aug 24, 2011, 9:24:06 PM8/24/11
to google-we...@googlegroups.com
try   String  token=History.getToken();  //RootPlace:banco/123
  String key = token.split("/")[1]


From: Sandney Farias <sandne...@gmail.com>
To: google-we...@googlegroups.com
Sent: Thursday, August 25, 2011 4:31 AM
Subject: Sending a value from a celltable to a view

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/oLws2h-77psJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Sandney Farias

unread,
Aug 25, 2011, 8:16:38 AM8/25/11
to google-we...@googlegroups.com, Abduxkur Ablimit
Sugar_xj,

I'm getting the value. My problem is that the application get a string value and isn't possible cast this to a key value.

Let me try to explain what I'm trying to do. I have a UI with a celltable where the user will click in one line and my application will send the key value to another UI. Like as send a value by GET method between two pages, I need the key value because the application will use it to make a query like this   

Datastore.query(banco).filter(banco.key.equal(key)).asSingle();

Thank's,

Sandney Farias

Abduxkur Ablimit

unread,
Aug 25, 2011, 9:56:08 PM8/25/11
to google-we...@googlegroups.com
selectionModel
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

                public void onSelectionChange(SelectionChangeEvent event) {
                    Banco selected = selectionModel.getSelectedObject();
                    
                    if (selected != null) {
                        History.newItem("RootPlace:banco/"+selected.getKey());
                    }
                }

            });

I'm getting the value in this way Window.Location.getHash().substring(Window.Location.getHash().indexOf("/")+1) as a string, that can't be cast to a key value

What do you mean you getting the value but isn't possible to case this to key-value?

what String are you getting ? and what is the key-value you are expecting  to cast? for example  you get the String   "RootPlace:banco/123"
Cc: Abduxkur Ablimit <suga...@yahoo.com>
Sent: Thursday, August 25, 2011 8:16 PM
Subject: Re: Sending a value from a celltable to a view

Sandney Farias

unread,
Aug 26, 2011, 12:30:52 PM8/26/11
to google-we...@googlegroups.com, Abduxkur Ablimit
For example  you get the String   "RootPlace:banco/123" I got the string and extract "123", but when I'll use it in the line Datastore.query(banco).filter(banco.key.equal(key)).asSingle(); 
the key have to be a object of KEY type and isn't possible cast a String type to a Key type.

Thank`s again.

Abduxkur Ablimit

unread,
Aug 28, 2011, 10:20:22 PM8/28/11
to google-we...@googlegroups.com
now I understood what you said  that you " isn't possible cast a String type to a Key type."
you get String from url anyway, maybe you should try to change the type of banco.key as String type  or create a String field for 
banco.key and setters getters....


From: Sandney Farias <sandne...@gmail.com>
To: google-we...@googlegroups.com
Cc: Abduxkur Ablimit <suga...@yahoo.com>
Sent: Saturday, August 27, 2011 12:30 AM

Subject: Re: Sending a value from a celltable to a view
For example  you get the String   "RootPlace:banco/123" I got the string and extract "123", but when I'll use it in the line Datastore.query(banco).filter( banco.key.equal(key)). asSingle(); 
the key have to be a object of KEY type and isn't possible cast a String type to a Key type.

Thank`s again.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
Reply all
Reply to author
Forward
0 new messages