窗口类:
它主要用来显示。
每一个Application可以设置一个主窗口比如:
Window mainWindow = new Window(messageSource.getMessage("main.window",null,Locale.CHINESE));
- setMainWindow(mainWindow);
还可以向主窗口添加多个子窗口如:
Window window=new Window(messageSource.getMessage("child.window.helloworld", null, Locale.CHINESE));
- mainWindow.addWindow(window);
可以设置这个窗口的icon
mainWindow.setIcon(new FileResource(new File(""),this));
是当前窗口显示后,背后的窗口变为不可使用。
设置是否可以拖拉窗口大小
window.setResizable(false);
spring +vaadin spring ioc依赖注入
package com.xq.vaadin;
import javax.annotation.Resource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
import com.vaadin.ui.Window;
@SuppressWarnings("serial")
public class SimpleAddressBook extends AbstractApplicationServlet {
private Class<? extends Application> clazz;
@Override
public void init(ServletConfig config) throws ServletException{
super.init(config);
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(
config.getServletContext());
ResourceBundleMessageSource messageSource=(ResourceBundleMessageSource)wac.getBean(ResourceBundleMessageSource.class);
System.out.println(messageSource);
com.xq.controller.HelloWorld application = (com.xq.controller.HelloWorld) wac.getBean(com.xq.controller.HelloWorld.class);
clazz = application.getClass();
}
@Override
protected com.xq.controller.HelloWorld getNewApplication(HttpServletRequest request)
throws ServletException {
// TODO Auto-generated method stub
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext());
return (com.xq.controller.HelloWorld) wac.getBean(com.xq.controller.HelloWorld.class);
}
@Override
protected Class<? extends Application> getApplicationClass()
throws ClassNotFoundException {
// TODO Auto-generated method stub
return clazz;
}
}
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext());return (com.xq.controller.HelloWorld) wac.getBean(com.xq.controller.HelloWorld.class);
这个是通过类去找bean.
在web。xml中
<servlet>
<servlet-name>HelloWorde</servlet-name>
<servlet-class>com.xq.vaadin.SimpleAddressBook</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>com.xq.vaadin.HelloWorld</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorde</servlet-name>
<url-pattern>/VAADIN2/*</url-pattern>
</servlet-mapping>
spring 中国际化,还有vaadin的页面配置:
<bean id="messageSource2" name="messageSource2" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="message-info"></property>
<property name="useCodeAsDefaultMessage" value="true"></property>
</bean>
<bean id="test" name="test" class="com.xq.controller.HelloWorld"></bean>
package com.xq.util;
import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
public class SpringContext {
private ApplicationContext context;
public void SpringContextHelper(Application application) {
ServletContext servletContext = ((WebApplicationContext) application.getContext()).getHttpSession().getServletContext();
context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
}
public Object getBean(final String beanRef) {
return context.getBean(beanRef);
}
public Object getBean(final Class class1){
return context.getBean(class1);
}
}
package com.xq.util;
import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
public class SpringContext {
private ApplicationContext context;
public void SpringContextHelper(Application application) {
ServletContext servletContext = ((WebApplicationContext) application.getContext()).getHttpSession().getServletContext();
context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
}
public Object getBean(final String beanRef) {
return context.getBean(beanRef);
}
public Object getBean(final Class class1){
return context.getBean(class1);
}
}
分享到:
相关推荐
vaadin中文入门学习。个人收集资料。
[Packt Publishing] Vaadin 7 学习教程 第2版 英文版 [Packt Publishing] Learning Vaadin 7 2nd Edition E Book ☆ 图书概要:☆ Master the full range of web development features powered by Vaadin built...
最新的vaadin官方学习资料,vaadin 版的
Vaadin is a component-based Java web framework for making applications look great and perform well, making your users happy. Vaadin promises to make your user interfaces attractive and usable while ...
最新的Vaadin学习资料,希望能帮到和我一样开始学习Web开发的人。
Vaadin 是一款使用 Apache V2 许可协议的开源产品,它由位于芬兰的 IT Mill 公司开发。其前身是 IT Mill 公司由 2000 年起开始研发的 Millstone 用户界面类库。2006 年,IT Mill 公司以 IT Mill Toolkit 作为正式...
Vaadin6.4.9_中文开发手册.Vaadin6.4.9_中文开发手册.
[Packt Publishing] Vaadin 7 UI 设计初学者指南 (英文版) [Packt Publishing] Vaadin 7 UI Design By Example Beginner's Guide (E-Book) ☆ 图书概要:☆ Build exciting Vaadin applications in no time ...
vaadin实例教程 [Packt Publishing] Vaadin 7 UI Design By Example Beginner's Guide
一本很好的vaadin参考书。作为入门、学习和实战参考
官方下载的api文档,好不容易才找到 vaadin-server-7.1.7-javadoc
vaadin 开发的帮助文档。可供你很轻松的入门学习它。值得一看
赠送jar包:android-json-0.0.20131108.vaadin1.jar; 赠送原API文档:android-json-0.0.20131108.vaadin1-javadoc.jar; 赠送源代码:android-json-0.0.20131108.vaadin1-sources.jar; 赠送Maven依赖信息文件:...
[Packt Publishing] Vaadin 7 开发经典实例 (英文版) [Packt Publishing] Vaadin 7 Cookbook (E-Book) ☆ 出版信息:☆ [作者信息] Jaroslav Holan , Ondrej Kvasnovsky [出版机构] Packt Publishing [出版日期...
Vaadin TableExport 源码 TableExport源码 Vaadin源码 1分只是为了生存
资源名称:Vaadin简介和HelloWorld 中文WORD版内容简介:本文档主要讲述的是Vaadin简介和HelloWorld;Vaadin(芬兰民间传说中的一种神话生物,是女神也是一种山岭驯鹿的神话祖先) 是一款使用 Apache V2 许可协议的...
非常实用的Vaadin7中文文档,里面详细介绍了vaadin的原理以及开发流程,和适合入门
vaadin 8 的官方文档,学习必备。此为2017年版本,web 开发的利器。