Dear,
I am trying to embed Vaadin UI into my existed JSP pages. However, I failed to get it done, and I don’t know where I am wrong. Here are my codes:
web.xml:
…
RequestController
RequestController
com.mycompany.servlet.RequestController
MyUIServlet
com.mycompany.vaadin.MyUIServlet
RequestController
/rc/
MyUIServlet
/vaadin/
…
MyUIServlet.java:
public class MyUIServlet extends VaadinServlet {
@Override protected void servletInitialized() throws ServletException {
super.servletInitialized();
getService().addSessionInitListener( new SessionInitListener() {
@Override public void sessionInit( SessionInitEvent event ) throws ServiceException {
event.getSession().addUIProvider( new MyUIProvider() );
}
} );
}
}
MUIProvider.java:
public class MyUIProvider extends UIProvider {
@Override public Class< ? extends UI > getUIClass( UIClassSelectionEvent event ) {
return MyUI.class;
}
}
MyUI.java:
public class MyUI extends UI {
@Override public void init( VaadinRequest request ) {
final VerticalLayout layout = new VerticalLayout();
final TextField name = new TextField();
name.setCaption( “Type your name here:” );
Button button = new Button( “Click Me” );
button.addClickListener( new Button.ClickListener() {
public void buttonClick( Button.ClickEvent e ) {
layout.addComponent( new Label( "Thanks " + name.getValue() + “, it really works!” ) );
}
} );
layout.addComponents( new Component { name , button } );
layout.setMargin( true );
layout.setSpacing( true );
this.setContent( layout );
}
}
Test.jsp:
<%@ taglib uri=“/WEB-INF/tlds/vaadin.tld” prefix=“vaadin” %>
Vaadin UI TEST
When I set the url: “/rc?command=file&file=Test.jsp”, the browser shows only “Vaadin UI TEST”, but no vaadin UI I expected. I am new to Vaadin development, adn sorry for such detailed elaboration. Please kindly advise where I might get wrong.
Many thanks,
Joey