Connecting Vaadin addon Wizards

I’m following this topic Connecting addon Vaadin in Cuba’s documentation to wrap the Wizards for Vaadin add-on .
I see that there is not something like a org/vaadin/teemu/wizards/Wizard.gwt.xml in their source code. I guess this is the cause I got this error as following:


Loading inherited module 'org.vaadin.teemu.wizards.Wizard'
[ERROR] Unable to find 'org/vaadin/teemu/wizards/Wizard.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source? 

I tried to integrated it as a Vaadin component into the Generic UI. Perhaps it isn’t possible.
Any help is welcome.

Btw, I’m just a 3 days with Cuba and I love it. I’m looking forward to buy a license. Well done, folks!

Hi,

This add-on does not have client side code so you can include it as usual Maven dependency, no need to use New UI Component action.

To include this add-on correctly you only need to go to Studio - Project Properties - Advanced, there add compile dependency for the web module: org.vaadin.addons:wizards-for-vaadin:1.1.1.

And after applying changes you will be able to use Wizard add-on in your code:


// Get Vaadin component from CUBA component
ComponentContainer vContainer = layout.unwrap(ComponentContainer.class);

Wizard wizard = new Wizard();
wizard.setSizeFull();

wizard.addStep(new EmptyWizardStep("First"));
wizard.addStep(new EmptyWizardStep("Last"));

vContainer.addComponent(wizard);

You can find my demo project here: https://github.com/jreznot/cuba-sample-vaadin-wizard-addon

We will improve documentation and New UI Component dialog, so it will enable you to use Vaadin add-ons without widget set.

Thank you so much for you reply.
That’s so much easier as I could imagine. I’ll try it following your demo project.
Congrats for amazing job!

I’m returning with some feedback to others and I’m adding one more question.

First of all, let me show the implementation of the Vaadin add-on I wrote:

As you adviced, in Cuba Studio | Project Properties - Advanced, I added compile dependency for the web module:
org.vaadin.addons:wizards-for-vaadin:1.1.1.

Next I copied the sample code in wizards-for-vaadin-demo with some adjustments. It works fine!

So I wrote the window controller like as following:


public class MyWizard extends AbstractWindow implements  WizardProgressListener  {
   @Inject
    private VBoxLayout vbox ; // This container was defined in window xml

    @Inject
    protected Messages messages;

    private Layout containerLayout;

   @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        containerLayout = (Layout) WebComponentsHelper.unwrap(vbox);

        wizard = new Wizard();
        wizard.addListener(this);
        wizard.addStep(new IntroStep(), "intro");
        wizard.addStep(new ListenStep(), "listen");
        wizard.addStep(new LastStep(), "last");

        wizard.getNextButton().setCaption(messages.getMessage(getClass(),"nextButton"));
        wizard.getBackButton().setCaption(messages.getMessage(getClass(),"backButton"));
        wizard.getFinishButton().setCaption(messages.getMessage(getClass(),"finishButton"));
        wizard.getCancelButton().setCaption(messages.getMessage(getClass(),"cancelButton"));

        wizard.setSizeFull();
        containerLayout.addComponent(wizard);
        // XXX This method doesn't exists 
        // containerLayout.setComponentAlignment(wizard, Alignment.TOP_CENTER)
     }

    // All methods here
}

There are also all that WizardStep implementations like as following (see the demo):


public class IntroStep implements WizardStep {

    public String getCaption() {   return "Intro";   }

    public Component getContent() {
       VerticalLayout content = new VerticalLayout();
       content.setSizeFull();
        content.setMargin(true);

        Label text = getText();
        content.addComponent(text);

        Embedded arrow = getArrow();
        content.addComponent(arrow);

        return content;
    }
    // Methods goes here
}

My new question now is how I could insert Cuba components (LookupField ) in a WizardStep’s getContent() method? One to pick a master entity like a Client and other to pick a enumeration like OrderStatus. I got this sample entities from your today webinar. Maybe should I use a AbstractFrame? And what about the DataStore required?

Could you give me some directions?

If I want to insert CUBA component to Vaadin VerticalLayout and then insert VerticalLayout to CUBA layout I will use unwrapComposition method to get Vaadin outer layout:


<layout>
    <vbox id="mainPane" height="100%">
        <!-- here we will add Vaadin component
             with CUBA component inside -->
    </vbox>
</layout>

public class Screen extends AbstractWindow {
    @Inject
    protected VBoxLayout mainPane;
    @Inject
    protected ComponentsFactory componentsFactory;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        Layout vMainPane = mainPane.unwrap(Layout.class);

        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setSpacing(true);
        verticalLayout.addComponent(new NativeButton("Vaadin native Button"));

        LookupField lookupField = componentsFactory.createComponent(LookupField.class);
        lookupField.setCaption("CUBA LookupField");
        lookupField.setOptionsList(Arrays.asList("Left", "Right", "Up", "Down"));
        // do not forget to set CUBA parent if you insert CUBA components to Vaadin layouts
        lookupField.setParent(mainPane);

        // obtain outer component from lookupField
        Component vLookupField = lookupField.unwrapComposition(Component.class);
        verticalLayout.addComponent(vLookupField);

        vMainPane.addComponent(verticalLayout);
    }
}

Do not forget to set CUBA parent if you insert CUBA components to Vaadin layouts, it is required for CUBA components functionality.

Thank you for gave me some direction.

My solution was create a AbstractFrame class and then I used the openFrame() method from the main class MyWizard to store that frame in a variable.
Finally I sent that variable to a WizardStep instance using a setter method. There I used your direction to display that frame inside the Wizard window. Works fine.

What I see if I use @Inject inside the WizardStep instance, it doesn’t works. But if I use it into a window frame, all works as expected.
Now I will go to use the DataStore feature to fill the LookupField controls. Wish me luck!

Thank you for you time.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/STUDIO-3092