Hey folks,
thank you for your help.
I got it fixed. I missed to implement a zero-argument constructor in
Kontakt...
Damn... im so blind! But sometimes you need to have a night to rethink
on it again.
Okay, but there´s one new question.
In my database (dont know why it was designed this way) the date is
splitted into three integer-columns: day, month, year.
Okay, for my comparison i need to transform this into a Date-Object.
But this does not work, if im using the DateTimeFormat-Class of GWT.
It uses GWT.Create() in his code, what´s prohibeted on server-side
code, so that this error occurs:
Caused by: java.lang.UnsupportedOperationException: ERROR:
GWT.create() is only usable in client code! It cannot be called, for
example, from server code. If you are running a unit test, check that
your test case extends GWTTestCase and that GWT.create() is not called
from within an initializer or constructor.[...]
I use this Domain-Construtor for this:
public Domain(String adresse, String tld, int tag, int monat, int
jahr, Kontakt kontakt) {
DateTimeFormat fmt = DateTimeFormat.getFormat("dd.MM.yyy");
this.setRegistrar(new Kontakt("Keine Angabe"));
this.adresse=adresse;
this.tld=tld;
this.owner=kontakt;
this.next=fmt.parse((tag+"."+monat+"."+jahr));
return;
}
Do you may have an idea, how it could work?
Thank you for your recent help!
johannes
p.s.: greetings from germany.I hope my English is not as bad as I
think. :P
On 31 Mrz., 20:46, Katharina Probst <[email protected]> wrote:
> I think it's fine to have constructors with arguments (so long as you also
> have a zero-argument constructor), but, yes, Kontakt needs to be
> serializable too.
>
> kathrin
>
> On Wed, Mar 31, 2010 at 2:41 PM, Sean <[email protected]> wrote:
> > Don't have a constructor with arguments, only use Set/Gets.
>
> > What's a Kontakt? Is that serializable?
>
> > Fix the constructor and verify Kontakt is serializable and it should
> > work.
>
> > On Mar 31, 10:43 am, Johannes Stein <[email protected]>
> > wrote:
> > > Hey,
>
> > > ive got a problem and im searching for hours to find a solution.
> > > My problem is the following:
>
> > > I have a little RPC-Service which returns as a result a "Domain"-
> > > Object (Own custom-class).
> > > But this Domain-Object could not be serialized, though i have made
> > > this "Domain"-class serializable with
> > > com.google.gwt.user.client.rpc.IsSerializable.
>
> > > Im using GWT SDK 2.01 and getting the following compiling error:
>
> > > [ERROR] com.google.gwt.core.client.JavaScriptObject is not assignable
> > > to 'com.google.gwt.user.client.rpc.IsSerializable' or
> > > 'java.io.Serializable' nor does it have a custom field serializer
> > > (reached via com.vostokdomains.kis.client.objetcs.Domain)
>
> > > [ERROR] com.google.gwt.core.client.JavaScriptObject has no available
> > > instantiable subtypes. (reached via
> > > com.vostokdomains.kis.client.objetcs.Domain)
>
> > > I hope you can help me out!!
> > > --------------------------------------------
> > > Enclosed some code-snippets:
>
> > > package com.vostokdomains.kis.client.objetcs;
>
> > > import java.util.Date;
>
> > > import com.google.gwt.i18n.client.DateTimeFormat;
> > > import com.google.gwt.user.client.rpc.IsSerializable;
>
> > > ========== Domain-Object============
>
> > > public class Domain implements Comparable<Domain>, IsSerializable{
>
> > > private String adresse;
> > > private String tld;
> > > private Date create;
> > > private Date next;
> > > private int laufzeit;
> > > private double preis;
>
> > > private Kontakt registrar;
> > > private Kontakt admin;
> > > private Kontakt tech;
> > > private Kontakt owner;
>
> > > private String namesever1;
> > > private String nameserver2;
> > > private String records;
>
> > > Domain(){
>
> > > }
>
> > > public Domain(String adresse, String tld, int tag, int monat, int
> > > jahr, Kontakt kontakt) {
>
> > > DateTimeFormat fmt =
> > DateTimeFormat.getFormat("dd.MM.yyy");
>
> > > this.setRegistrar(new Kontakt("Keine Angabe"));
> > > this.adresse=adresse;
> > > this.tld=tld;
> > > this.owner=kontakt;
> > > this.next=fmt.parse((tag+"."+monat+"."+jahr));
>
> > > return;
>
> > > }
>
> > > public Domain(String adresse, String tld, Kontakt kontakt){
> > > this.setRegistrar(new Kontakt("Keine Angabe"));
> > > this.adresse=adresse;
> > > this.tld=tld;
> > > this.owner=kontakt;
> > > this.next=new Date();
> > > }
>
> > > [....]
>
> > > ================= DatabaseService ====================
>
> > > public class DatabaseServiceImpl extends RemoteServiceServlet
> > > implements
> > > DatabaseService {
>
> > > /**
> > > *
> > > */
> > > private static final long serialVersionUID = 1L;
>
> > > public Domain getDomains() {
>
> > > DBConnection conn = new DBConnection();
> > > conn.connect();
> > > Connection dbconn = conn.getConnection();
> > > System.out.print("TEST");
> > > Domain d = null;
>
> > > try {
> > > ResultSet rs = null;
> > > Statement stm = dbconn.createStatement();
> > > System.out.print("STATEMENT");
> > > stm.execute("SELECT * FROM domains");
> > > rs = stm.getResultSet();
>
> > > rs.next() ;
> > > Kontakt k = new Kontakt(rs.getString(2));
> > > d = new Domain(rs.getString(3), "tld",
> > k);
>
> > > } catch (SQLException e) {
> > > // TODO Auto-generated catch block
> > > e.printStackTrace();
> > > }
> > > return d;
>
> > > }
>
> > > }
>
> > > ======================== RPC Call ========================
>
> > > public class Kis implements EntryPoint {
>
> > > @Override
> > > public void onModuleLoad() {
>
> > > DatabaseServiceAsync rpc;
> > > rpc = (DatabaseServiceAsync)
> > GWT.create(DatabaseService.class);
> > > ServiceDefTarget target = (ServiceDefTarget) rpc;
> > > String moduleRelativeURL = GWT.getModuleBaseURL() +
> > > "DatabaseServiceImpl";
> > > target.setServiceEntryPoint(moduleRelativeURL);
> > > /*
> > > test.add();
> > > RootPanel.get().add(test.vpanel);*/
>
> > > rpc.getDomains(new AsyncCallback<Domain>() {
>
> > > public void onFailure(Throwable caught) {
>
> > > Window.alert("Übertragung fehlgeschlagen!" );
> > > }
>
> > > public void onSuccess(Domain rs) {
>
> > > //Expiration ex = new Expiration();
> > > //ex.create(rs,0);
> > > System.out.print(rs.getAdresse());
> > > //RootPanel.get().add(ex.vpanel);
>
> > > }
> > > }
> > > );
>
> > > }
>
> > > }
>
> > --
> > 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]<google-web-toolkit%[email protected]>
> > .
> > 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 [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.