Handle pages

Hi,

I am creating website and some of pages will have sophisticated forms. I would like implement these forms in Vaadin so I need some pages with URLs e.g.

/registerCompany

/editCompany

/updateSomething

that will be made in Vaadin but I don’t know details how should I do it.

  1. Should I create new Vaadin application for every form and embed them on pages with div, iframe or portlet? Won’t be communication between them hard to implement?

  2. Should I create one Vaadin application for all form/pages and handle different paths by URIHandler ?

  3. or You know other better solution?

Best regards,
Tomasz Prus

I do it like this (clutter omited):


public class WKOApplication extends Application  {
	private Window windowAdmin;

	void buildWindowAdmin() {
		if (windowAdmin == null) {
			windowAdmin = new AdminWindow("Administrator's page");
			addWindow(windowAdmin);
		}
		getMainWindow().open(new ExternalResource(windowAdmin.getURL()), "_self");
	}

this is my other “page”


public class AdminWindow extends Window {

	public AdminWindow(String caption) {
		super(caption);
		setName("admin");
		vlMain = new VerticalLayout();
		hlHeader = new HorizontalLayout();
		vlMain.addComponent(hlHeader);
		label = new Label();
		hlHeader.addComponent(label);
		shutdown = new Button("Shutdown the internet");
		vlMain.setSpacing(true);
		vlMain.setSizeFull();
		addComponent(vlMain);
.
.
.
.
	}

I don’t know exactly if this is what you are looking for… I see no reason to have multiple vaadin projects

Thank You very many :slight_smile:

If you do need the URLs to be directly accessible, you could also use URIFragmentUtility and anchors instead of subpages for identifying views. This would have the advantage that the browser does not need to reload the whole page when switching URL.

Maybe the view management in the
Navigator7
or
AppFoundation
add-ons would make this a little easier.

Probably followed solution is sufficient for me but is it correct?

public class CompanyApplication extends Application {

private Window window;

@Override
public void init() {

	final String path = getURL().getPath();
	if(path.endsWith("/add/")) {
	    window = new AddCompanyWindow();
	} else if(path.endsWith("/edit/")) {
		window = new EditCompanyWindow();
	} else if(path.endsWith("/admin/")) {
		window = new AdministrationWindow();
	}
	setMainWindow(window);
}

}