Hitachi Vantara Pentaho Community Wiki
Child pages
  • Advanced Guide to MVC in Pentaho XUL Applications

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

FooController.java

Code Block
 /**
  * The Controller has two roles 1) setup bindings for view state and 2) handle UI events
 **/ 
public class FooController extends AbstractXulEventHandler {
	private FooViewModel fooViewModel;

	public FooController() {
		fooViewModel = new FooViewModel(); //FYI we prefer to inject the models via an IOC container, but for the sake of simplicity...
	}

	// This is the name with which to register instances of this controller.  Typically we would set this, but for simplicity we hardcode it.
	public String getName() {
		return "fooController";  //this name should match event handler aliases in the XUL source file
	}

	public void onLoad() {
		bind(fooViewModell, "name", "nameTextbox", "value");
		bind(fooViewModell, "okEnabled", "okButton", "!disabled");
	}

	// The XUL framework will find and call this method when the Search button is clicked
	public void displaySearchDialog() {
		XulSearchDialog searchDialog = new XulSearchDialog();
		searchDialog.show(); //I wish launching a XulDialog were this easy!
		this.name = searchDialog.getName();
	}
}

...