Hi everyone.
I am a begginer with Vaadin and I’m traying to do a sample project with a client-server RPC, and I’m using this wiki
https://vaadin.com/wiki/-/wiki/Main/Creating+a+simple+component
and when i execute my app it shows this exception in the UI.
Here is what i have.
UI
[code]
package com.example.documentmanager.client;
import com.vaadin.annotations.Theme;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;
@SuppressWarnings(“serial”)
@Theme(“documentmanager”)
public class DocUI extends UI {
private static Navigator navigator;
public static final String PPAL_VIEW = "";
public static final String FILE_VIEW = "fileView";
@Override
protected void init(VaadinRequest request) {
navigator = new Navigator(this, this);
navigator.addView(PPAL_VIEW, new PrincipalView());
navigator.addView(FILE_VIEW, new FileView());
}
public static Navigator getAppNavigator(){
return navigator;
}
}
[/code]Widget
[code]
package com.example.documentmanager.client;
import java.io.File;
import java.util.Locale;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.util.FilesystemContainer;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings(“serial”)
public class PrincipalView extends Widget implements View {
private FilesystemContainer docs;
private Table documentList;
private Button viewInfoButton;
private FieldGroup fileInfo;
private FormLayout fileFields;
private String[] columns = new String[]
{“Name”, “Icon”, “Size”, “Last Modified”};
public PrincipalView() {
buildComponents();
}
private void buildComponents() {
VerticalLayout ppalLayout = new VerticalLayout();
docs = new FilesystemContainer(new File("C:/TEMP/javadoc/"));
documentList = new Table();
viewInfoButton = new Button("File Info");
fileFields = new FormLayout();
fileFields.setMargin(true);
createFileInfo();
documentList.setContainerDataSource(docs);
HorizontalSplitPanel split = new HorizontalSplitPanel();
ppalLayout.addComponent(split);
ppalLayout.setSizeFull();
VerticalLayout vl = new VerticalLayout();
vl.addComponent(documentList);
vl.addComponent(viewInfoButton);
vl.setExpandRatio(documentList, 1);
vl.setSizeFull();
split.addComponent(vl);
split.addComponent(fileFields);
documentList.setImmediate(true);
documentList.setSelectable(true);
documentList.setSizeFull();
}
private void createFileInfo(){
fileInfo = new FieldGroup();
for (String fieldName : columns) {
TextField field = new TextField(fieldName);
if (fieldName.equals("Icon")) {
field.setConverter(new Converter<String, ThemeResource>(){
@Override
public ThemeResource convertToModel(String value,
Class<? extends ThemeResource> targetType,
Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return (value != null && value.length() > 0 ? new ThemeResource(value) : null);
}
@Override
public String convertToPresentation(ThemeResource value,
Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return (value != null ? value.getResourceId() : "");
}
@Override
public Class<ThemeResource> getModelType() {
return ThemeResource.class;
}
@Override
public Class<String> getPresentationType() {
return String.class;
}
});
}
field.setWidth("100%");
fileFields.addComponent(field);
fileInfo.bind(field, fieldName);
}
fileInfo.setBuffered(false);
}
@Override
public void enter(ViewChangeEvent event) {
}
public Button getViewInfoButton() {
return viewInfoButton;
}
public Table getDocumentList() {
return documentList;
}
public FieldGroup getFileInfo() {
return fileInfo;
}
}
[/code]ServerRpc and ServerRpcImpl
[code]
package com.example.documentmanager.shared.servicerpc;
import java.io.File;
import com.vaadin.shared.communication.ServerRpc;
public interface DocumentManagerServerRpc extends ServerRpc {
public void setFileSelectedInSession(File file);
}
package com.example.documentmanager.shared.servicerpc;
import java.io.File;
public class DocumentManagerServerRpcImpl implements DocumentManagerServerRpc {
private static final long serialVersionUID = -2746786739091368385L;
@Override
public void setFileSelectedInSession(File file) {
System.out.println("El archivo es: " + file.getName());
}
}
[/code]Component
[code]
package com.example.documentmanager.server;
import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpc;
import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpcImpl;
import com.vaadin.ui.AbstractComponent;
public class PrincipalViewComponent extends AbstractComponent {
private static final long serialVersionUID = 2867497095079533979L;
DocumentManagerServerRpc rpc = new DocumentManagerServerRpcImpl();
public PrincipalViewComponent() {
registerRpc(rpc);
}
}
[/code]Connector
[code]
package com.example.documentmanager.client;
import java.io.File;
import com.example.documentmanager.server.PrincipalViewComponent;
import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpc;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@SuppressWarnings(“serial”)
@Connect(PrincipalViewComponent.class)
public class PrincipalViewConnector extends AbstractComponentConnector {
private DocumentManagerServerRpc rpc = RpcProxy.create(DocumentManagerServerRpc.class, this);
public PrincipalViewConnector() {
bindEvents();
}
private void bindEvents() {
getWidget().getViewInfoButton().addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
DocUI.getAppNavigator().navigateTo(DocUI.FILE_VIEW);
}
});
getWidget().getDocumentList().addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
rpc.setFileSelectedInSession((File) event.getProperty().getValue());
}
});
}
@Override
public PrincipalView getWidget() {
return (PrincipalView) super.getWidget();
}
@Override
protected Widget createWidget() {
return GWT.create(PrincipalView.class);
}
}
[/code]Widgetset.gwt.xml
[code]
<?xml version="1.0" encoding="UTF-8"?><!--
Uncomment the following to compile the widgetset for one browser only.
Multiple browsers can be specified as a comma separated list. The
supported user agents at the moment of writing were:
ie8,ie9,gecko1_8,safari,opera
The value gecko1_8 is used for Firefox and safari is used for webkit
based browsers including Google Chrome.
-->
<!-- <set-property name="user.agent" value="safari"/> -->
<!--
To enable SuperDevMode, uncomment this line.
See https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode for more
information and instructions.
-->
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->
[/code]web.xml
[code]
<?xml version="1.0" encoding="UTF-8"?>
DocumentManager
Vaadin production mode
productionMode
false
Document Manager
com.vaadin.server.VaadinServlet
Vaadin UI class to use
UI
com.example.documentmanager.client.DocUI
Legacy mode to return the value of the property as a string from AbstractProperty.toString()
legacyPropertyToString
false
Application widgetset
widgetset
com.example.documentmanager.client.DocumentManagerWidgetset
Document Manager
/*
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
[/code]When I execute this i have this:
[code]
java.lang.ClassNotFoundException: com.google.gwt.core.shared.GWTBridge
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java:109)
com.google.gwt.user.client.ui.UIObject.(UIObject.java:195)
com.example.documentmanager.client.DocUI.init(DocUI.java:21)
com.vaadin.ui.UI.doInit(UI.java:641)
com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)
com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
[/code]And another question:
At the wiki i said before there are a lot of comments about compiling and, as i'm using the eclipse plugin, i can not see the option to compile the application. Where is it or How can i compile with eclipse??
Thank you very much with these two questions