16.02.2015 Views

Step by step tutorial: how to build a bean for Servoy - Servoy Stuff

Step by step tutorial: how to build a bean for Servoy - Servoy Stuff

Step by step tutorial: how to build a bean for Servoy - Servoy Stuff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How <strong>to</strong> <strong>build</strong> a <strong>bean</strong> <strong>for</strong> <strong>Servoy</strong> - A <strong>step</strong> <strong>by</strong> <strong>step</strong> <strong>tu<strong>to</strong>rial</strong> brought <strong>to</strong> you <strong>by</strong> <strong>Servoy</strong> <strong>Stuff</strong><br />

Then we generate our getters and setters. Menu “Source > Generate Getters and Setters…”, we select<br />

all the properties, and click OK:<br />

Note that of the 10 properties, Eclipse will generate 19 methods, that’s because a getName() method<br />

has already been generated from our interface.<br />

We also know that we are going <strong>to</strong> <strong>for</strong>ward all the setXXX properties <strong>to</strong> the “real” component (the<br />

Swing <strong>bean</strong> or the Wicket <strong>bean</strong>), so <strong>to</strong> do it easily, we add a variable <strong>to</strong> hold it:<br />

protected ITextComponent component = new SwingTestBean();<br />

Note that:<br />

1/ the variable is protected (we will not need <strong>to</strong> had a getter and a setter <strong>for</strong> it)<br />

2/ the type of the variable is actually the interface ITextComponent, because it will then be capable of<br />

holding either a SwingTestBean or a WicketTestBean: again that’s one great advantage of interfaces.<br />

3/ we instantiated the variable with an instance of our SwingTestBean. Now why is that Well, the<br />

thing is that when <strong>Servoy</strong> will first call the <strong>bean</strong>, it will be done from the “Place Bean…” command<br />

30/37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!