Directory

← Back

SpringVaadinIntegration

Integration Spring and Vaadin. And some useful features.

Author

Rating

Popularity

<100

Now you can use Spring Framework in your Vaadin projects.

Features:

  • Spring Framework integration
  • No AOP dependencies!
  • Vaadin's Views Autowiring
  • Vaadin's Views caching
  • Vaadin's SystemMessages customization
  • Apache Shiro integration
  • Portlet support
  • Initial OSGI support

Vaadin 7.6.x -> SpringVaadinIntegration 3.2.x Vaadin 7.2.x -> SpringVaadinIntegration 3.x Vaadin 7.1.x -> SpringVaadinIntegration 2.x Vaadin 7.0.x -> SpringVaadinIntegration 1.x

More info. http://vaadin.xpoft.ru/

Sample code

@Component
@Scope("prototype")
@Theme("myTheme")
public class MyUI extends UI
{
    @Autowired
    private MyClass myClass;

    @Override
    protected void init(final VaadinRequest request)
    {
        DiscoveryNavigator navigator = new DiscoveryNavigator(this, this);
        navigator.navigateTo(UI.getCurrent().getPage().getUriFragment());
    }
}
@Component
@Scope("prototype")
@VaadinView(MainView.NAME)
public class MainView extends Panel implements View
{
    public static final String NAME = "profile";

    @Autowired
    private transient ApplicationContext applicationContext;

    @Autowired
    private SimpleForm form;

    @PostConstruct
    public void PostConstruct()
    {
        MainLayout mainLayout = new MainLayout();
        mainLayout.setContent(form);

        setContent(mainLayout);
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event)
    {
    }
}
    <servlet>
        <servlet-name>Vaadin Application</servlet-name>
        <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
        ...
        <init-param>
            <param-name>systemMessagesBeanName</param-name>
            <param-value>DEFAULT</param-value>
        </init-param>
    </servlet>
vaadin.communicationError.Caption = Error
vaadin.communicationError.Message = It's a communication error. Is Jetty run?
@Component
@Scope("prototype")
@VaadinView(value = UIScopedView.NAME, cached = true)
public class UIScopedView extends Panel implements View
{
    public static final String NAME = "ui_scoped";

    private final Label statusLabel = new Label();
    private boolean scoped = false;

    public UIScopedView()
    {
        try
        {
            Thread.sleep(5000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }

        setSizeFull();
        VerticalLayout layout = new VerticalLayout();
        layout.setSpacing(true);
        layout.setMargin(true);

        layout.addComponent(new Label("At first time, it's loading about 5 seconds."));
        layout.addComponent(new Label("Now click \"Go back\" button, than \"Go to the UI scoped View\" again."));
        layout.addComponent(statusLabel);
        layout.addComponent(new Button("Go back", new Button.ClickListener()
        {
            @Override
            public void buttonClick(Button.ClickEvent event)
            {
                Page.getCurrent().setUriFragment("!" + MainView.NAME);
            }
        }));

        statusLabel.setCaption("State");
        statusLabel.setValue("First time");

        setContent(layout);
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent)
    {
        if (scoped)
        {
            statusLabel.setValue("Already scoped");
        }

        scoped = true;
    }
}
@Component
@Scope("prototype")
@VaadinView(RoleAdminView.NAME)
@RequiresRoles("admin")
public class RoleAdminView extends Panel implements View
{
...
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Add SystemMessages bean support. Now you can use Spring Beans as source for SystemMessages.

Released
2012-10-09
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.0+
Vaadin 7.1+ in 2.0
Vaadin 7.1 in 2.0.2
Vaadin 7.2+ in 3.0
Vaadin 7.3+ in 3.1
Vaadin 7.6+ in 3.2
Browser
Browser Independent

Vaadin Add-on Directory

Find open-source widgets, add-ons, themes, and integrations for your Vaadin application. Vaadin Add-on Directory
The channel for finding, promoting, and distributing Vaadin add-ons.
Online