Re: Saving data on the server

2010-12-07 Thread David Cox
Thanks mate!

Some good info there.

For now, im going to stick with the serialize to file, just because
I'm a long way from actually doing something practical with the data,
and because i can quickly see what changes I have made.
The good thing about RPC implementation is I can just swap out the
method for something substantial later on.
I guess that was the intention at least.

/David

On 14 Nov, 00:30, Brett Thomas brettptho...@gmail.com wrote:
 The get and set functions are called getters and setters - they are part of
 the javabean specification:http://en.wikipedia.org/wiki/JavaBean

 I'm guessing the XML library you are using requires java objects to be
 defined as javabeans. I've seen a couple other libraries that do that too -
 not sure why they work that way.

 For the bigger picture, that all depends on your server setup. If you're
 just experimenting, I'd suggest using GWT with Google App Engine, and
 storing data via hibernate. Google has a good tutorial for using GWT with
 app engine/hibernate. I think a database is almost alwasy easier than
 serializing objects to a file.

 To your point about changing your data model: I've found that app engine is
 really bad for this. There isn't (I don't think) a simple way to delete all
 objects of this class out of the box. When I was just experimenting with
 app engine, I found it easier to just create new class definitions than
 modify existing classes.

 Good luck learning GWT!
 Brett







 On Sat, Nov 13, 2010 at 2:38 PM, David Cox cox.spir...@gmail.com wrote:
  So, i managed to solve my own problem again, but I'm no 100% on how i
  did it.

  What i did was remove all my functions in the class and then re-added
  them with the create getter and setter for private String

  Then i made sure that the variable was set using the actual setter
  function. ie: this.setTitle(Title).
  I also had other function in the class.
  Like myfucntion(String title, int counter) or something like that.
  Origionaly i have stuff like
  this.Title = title.

  I had to change these to this.setTitle(title). Even though all the
  setTitle function does exaclty: this.title = title.
  For some reason this fixes it.

  as far as i can tell, the rules for successful xml serialisation as as
  such:
  1. The each variable you want serialised must have a set command
  called that has the same name with a set prefix
  2. this function must be called at least once or that particular
  variable will not be searilised (once it is called though, you can
  then go back to using direct methods like this.Title = title. )
  3. each variable MUST also have a public function wiht the same name
  and a get prefix.

  It took me ages to work this out, and i would love it if someone out
  there could explain why.
  My only guess is that it does have 1 convenient feature, and that is,
  you can actually use this to determine which variables will be seen in
  the resulting serialised XML, but you can still work happily with all
  the other variables in an object (like counters and states) and not
  have them appear in the output.

  Nice one. Just wish i found a tutuorial out there that explained this
  to me from the start.

  Am still interested to hear what others do.

  /David

  --
  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.comgoogle-web-toolkit%2Bunsubs 
  cr...@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.



Re: Saving data on the server

2010-11-13 Thread David Cox
So, i managed to solve my own problem again, but I'm no 100% on how i
did it.

What i did was remove all my functions in the class and then re-added
them with the create getter and setter for private String

Then i made sure that the variable was set using the actual setter
function. ie: this.setTitle(Title).
I also had other function in the class.
Like myfucntion(String title, int counter) or something like that.
Origionaly i have stuff like
this.Title = title.

I had to change these to this.setTitle(title). Even though all the
setTitle function does exaclty: this.title = title.
For some reason this fixes it.

as far as i can tell, the rules for successful xml serialisation as as
such:
1. The each variable you want serialised must have a set command
called that has the same name with a set prefix
2. this function must be called at least once or that particular
variable will not be searilised (once it is called though, you can
then go back to using direct methods like this.Title = title. )
3. each variable MUST also have a public function wiht the same name
and a get prefix.

It took me ages to work this out, and i would love it if someone out
there could explain why.
My only guess is that it does have 1 convenient feature, and that is,
you can actually use this to determine which variables will be seen in
the resulting serialised XML, but you can still work happily with all
the other variables in an object (like counters and states) and not
have them appear in the output.

Nice one. Just wish i found a tutuorial out there that explained this
to me from the start.

Am still interested to hear what others do.

/David

-- 
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.



Re: Saving data on the server

2010-11-13 Thread Brett Thomas
The get and set functions are called getters and setters - they are part of
the javabean specification: http://en.wikipedia.org/wiki/JavaBean

I'm guessing the XML library you are using requires java objects to be
defined as javabeans. I've seen a couple other libraries that do that too -
not sure why they work that way.

For the bigger picture, that all depends on your server setup. If you're
just experimenting, I'd suggest using GWT with Google App Engine, and
storing data via hibernate. Google has a good tutorial for using GWT with
app engine/hibernate. I think a database is almost alwasy easier than
serializing objects to a file.

To your point about changing your data model: I've found that app engine is
really bad for this. There isn't (I don't think) a simple way to delete all
objects of this class out of the box. When I was just experimenting with
app engine, I found it easier to just create new class definitions than
modify existing classes.

Good luck learning GWT!
Brett

On Sat, Nov 13, 2010 at 2:38 PM, David Cox cox.spir...@gmail.com wrote:

 So, i managed to solve my own problem again, but I'm no 100% on how i
 did it.

 What i did was remove all my functions in the class and then re-added
 them with the create getter and setter for private String

 Then i made sure that the variable was set using the actual setter
 function. ie: this.setTitle(Title).
 I also had other function in the class.
 Like myfucntion(String title, int counter) or something like that.
 Origionaly i have stuff like
 this.Title = title.

 I had to change these to this.setTitle(title). Even though all the
 setTitle function does exaclty: this.title = title.
 For some reason this fixes it.

 as far as i can tell, the rules for successful xml serialisation as as
 such:
 1. The each variable you want serialised must have a set command
 called that has the same name with a set prefix
 2. this function must be called at least once or that particular
 variable will not be searilised (once it is called though, you can
 then go back to using direct methods like this.Title = title. )
 3. each variable MUST also have a public function wiht the same name
 and a get prefix.

 It took me ages to work this out, and i would love it if someone out
 there could explain why.
 My only guess is that it does have 1 convenient feature, and that is,
 you can actually use this to determine which variables will be seen in
 the resulting serialised XML, but you can still work happily with all
 the other variables in an object (like counters and states) and not
 have them appear in the output.

 Nice one. Just wish i found a tutuorial out there that explained this
 to me from the start.

 Am still interested to hear what others do.

 /David

 --
 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.comgoogle-web-toolkit%2bunsubscr...@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.



Saving data on the server

2010-11-12 Thread David Cox
Hi, I'm kinda new to GWT.

Anyway, I managed to perform an RPC call to the server for an array of
objects, each. The object class (with a few strings and a few ints) is
defined on the client side, but the server seems happy to reference to
it.

But now i want to have the server write (and later read) the data to
file.
I have been experimenting with Serialising Java Objects as XML from
the server side. However the server seems to only write each object in
the array, but not the data that is actually IN the object (ie: added
by the user)

?xml version=1.0 encoding=UTF-8?
java version=1.6.0_18 class=java.beans.XMLDecoder
 array class=com.mysite.client.myObject length=3
  void index=0
   object class=com.mysite.client.myObject/
  /void
  void index=1
   object class=com.mysite.client.myObject/
  /void
  void index=2
   object class=com.mysite.client.myObject/
  /void
 /array
/java

Even when I just reference one object: like myObject test = new
myObject(abc, 100, 10, blahblah); the xml output is just the class
definition.

I have looked at many example online and they say that i should see
the data in the object as well.
Perhaps because the class is client side and special in a gwt sort
of way, this is not possible?
Probably I am doing something silly.

Probably, even, gwt has better and more standardised ways saving and
retrieving data on the server side. What simple methods do others do?
I really like the sound of using serialisable xml because it seems to
mean that I don't have to update the save/load routine when I update
and develop the class. But maybe its better to just put it all in a
DB.

/David.

-- 
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.