Reputation: 11
Which method is preferable if I want to read a variable in my HTML-page? Is there a difference between the two?
class SomePage extends Page {
private String someVariable = "Some value";
public SomePage() {
addModel("someVariable", someVariable);
}
}
or
class SomePage extends Page {
@Bindable
private String someVariable = "Something";
}
Upvotes: 1
Views: 133
Reputation: 985
The Apache Click documentation[1] is rich in content. Together with the online examples I can say how it is simply and intuitive. Specifically about your question, binding is explained in the application-autobinding section[3]. I tend to use the auto-binding mechanism only to request parameter and because of this warning in the docs:
we recommend using autobinding only for binding request parameters, not for Controls. It generally leads to code that is difficult to maintain. In a future release we will replace autobinding with a simpler implementation.
[1] http://click.apache.org/docs/user-guide/htmlsingle/click-book.html
[2] http://click.avoka.com/click-examples/home.htm
[3] http://click.apache.org/docs/user-guide/html/ch05s02.html#application-autobinding
Upvotes: 0