PDA

View Full Version : Please ModelData Example Class



baczek00
27 Aug 2010, 4:39 AM
Hi,

How to use ModelData please Here is an example of class http://www.sencha.com/helpcenter/index.jsp?topic=/com.extjs.gxt.help/html/tutorials/dozer.html with Dozer but I want without Dozer

Baczek00

sven
27 Aug 2010, 6:10 AM
What kind of example are you looking for exactly? What do you want to do?

baczek00
27 Aug 2010, 7:47 AM
I want to read text from the TextField and I noticed that this is
formBinding needed, and works on ModelData FormBinding.

Sorry for the double entry in the Forum

baczek00
27 Aug 2010, 12:45 PM
Hi, Sven

I have here is such a class program



package pl.baczeksoft.client;

import pl.baczeksoft.client.core.MyPanelEditTable;
import pl.baczeksoft.client.core.MyRowEditPanel;
import pl.baczeksoft.client.core.SpinnerField;
import pl.baczeksoft.client.form.BaseForm.CustomWindows;
import pl.baczeksoft.client.resources.Test;

import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.binding.FieldBinding;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowData;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class DatabaseSettings {

private void CreateGUI(ModelData MD){

Button btnTest = new Button("Test połączenia");
Button btnZapisz = new Button("Zapisz");
Button btnAnuluj = new Button("Anuluj");

TextField<String> DatabaseEdit = new TextField<String>();
DatabaseEdit.setFieldLabel("Baza");
DatabaseEdit.setName("database");

TextField<String> UserEdit = new TextField<String>();
UserEdit.setFieldLabel("Login");
//UserEdit.setName("company");

TextField<String> PasswordEdit = new TextField<String>();
PasswordEdit.setFieldLabel("Hasło");

final SpinnerField spinnerInteger = new SpinnerField();
spinnerInteger.setFieldLabel("Port");
spinnerInteger.setStepValue(Integer.valueOf(1));
spinnerInteger.setPropertyEditorType(Integer.class);
spinnerInteger.setFormat(NumberFormat.getFormat("##0"));
spinnerInteger.setAutoValidate(true);
spinnerInteger.setAllowDecimals(false);
spinnerInteger.setAllowBlank(false);
spinnerInteger.setMaxValue(65535);
spinnerInteger.setMinValue(0);
spinnerInteger.setValue(3050);


FormPanel PanelWnd = new FormPanel();
PanelWnd.setHeaderVisible(false);
PanelWnd.setLayout(new FlowLayout());
PanelWnd.setBorders(false);
PanelWnd.add(new MyRowEditPanel(DatabaseEdit));
PanelWnd.add(new MyPanelEditTable(UserEdit, PasswordEdit, spinnerInteger), new FlowData(40,0,0,0));


FormBinding binding = new FormBinding(PanelWnd);
binding.addFieldBinding(new FieldBinding(DatabaseEdit, "database"));
//binding.addFieldBinding(new FieldBinding(UserEdit, "company"));

binding.autoBind();
binding.bind(MD);


final CustomWindows DatabaseForm = new CustomWindows();
DatabaseForm.setLayout(new FitLayout());
DatabaseForm.setHeading(DatabaseForm.AppName+" - ustawienia połączenia");
DatabaseForm.setSize(650, 200);
DatabaseForm.add(PanelWnd);
DatabaseForm.setButtonAlign(Style.HorizontalAlignment.CENTER);
DatabaseForm.addButton(btnTest);
DatabaseForm.addButton(btnZapisz);
DatabaseForm.addButton(btnAnuluj);
DatabaseForm.show();
}

public DatabaseSettings(){
final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
final AsyncCallback<Test> callback = new AsyncCallback<Test>(){

@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}

@Override
public void onSuccess(Test result) {
// TODO Auto-generated method stub
CreateGUI(result);
}
};
greetingService.getDatabase(callback); -- Error
}


POJO Class:



package pl.baczeksoft.client.resources;

import java.io.Serializable;

import com.extjs.gxt.ui.client.data.BaseModelData;

public class Test extends BaseModelData implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;

public Test() {
// TODO Auto-generated constructor stub
}

public void setDatabase(String database) {
set("database", database);
}

public String getDatabase() {
return (String) get("database");
}
}




Implements Class



package pl.baczeksoft.server;

import pl.baczeksoft.client.GreetingService;
import pl.baczeksoft.client.resources.Test;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {

@Override
public Test getDatabase() {
// TODO Auto-generated method stub
Test DBF = new Test();
DBF.setDatabase("g");
// DBF.setPort(3050);
// DBF.setUser("SYSDBA");
// DBF.setPassword("masterkey");
return DBF;

}




Error:



2010-08-27 22:30:50 com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: [1282941050223000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
java.lang.NoClassDefFoundError: com/extjs/gxt/ui/client/data/BaseModelData
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.user.server.rpc.SerializationPolicyLoader.loadFromStream(SerializationPolicyLoader.java:196)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.loadSerializationPolicy(RemoteServiceServlet.java:89)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doGetSerializationPolicy(RemoteServiceServlet.java:251)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.getSerializationPolicy(RemoteServiceServlet.java:139)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareToRead(ServerSerializationStreamReader.java:445)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:236)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:186)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ClassNotFoundException: com.extjs.gxt.ui.client.data.BaseModelData
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 50 more

2010-08-27 22:43:49 com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: [1282941829381000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
java.lang.NoClassDefFoundError: com/extjs/gxt/ui/client/data/BaseModelData
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.user.server.rpc.SerializationPolicyLoader.loadFromStream(SerializationPolicyLoader.java:196)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.loadSerializationPolicy(RemoteServiceServlet.java:89)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doGetSerializationPolicy(RemoteServiceServlet.java:251)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.getSerializationPolicy(RemoteServiceServlet.java:139)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareToRead(ServerSerializationStreamReader.java:445)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:236)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:186)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ClassNotFoundException: com.extjs.gxt.ui.client.data.BaseModelData
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 50 more
What am I doing wrong?

sven
27 Aug 2010, 12:48 PM
You dont have the gxt.jar on your server classpath as it looks like

baczek00
27 Aug 2010, 1:58 PM
gxt.ja is, without a method getDatabase () works. So it's not. Somewhere I am doing mistake in writing getDatabase () just do not know where