Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
becki:linux:apache_click [2010-05-04 09:43] becki |
becki:linux:apache_click [2010-05-05 13:24] (aktuell) becki |
||
---|---|---|---|
Zeile 2: | Zeile 2: | ||
===== Useful Links == | ===== Useful Links == | ||
- | [[http://click.apache.org/|Home Page]] - [[http://click.apache.org/docs/user-guide/html/|User Guide]] - [[http://click.apache.org/docs/click-api/|API]] - [[http://etb-111:8080/click-examples/|Demo and Code]] | + | [[http://click.apache.org/|Home Page]] - [[http://click.apache.org/docs/user-guide/html/|User Guide]] - [[http://click.apache.org/docs/click-api/|API]] - [[http://click.apache.org/docs/extras-api/|Extras API]] - [[http://www.avoka.com/click-examples/|Demo and Code]] |
===== General == | ===== General == | ||
Zeile 50: | Zeile 50: | ||
Make a symlink from Tomcat to your project ''$CATALINA_HOME/webapps/translator'' -> ''translator/WebContent'' in order to get your page in the browser. | Make a symlink from Tomcat to your project ''$CATALINA_HOME/webapps/translator'' -> ''translator/WebContent'' in order to get your page in the browser. | ||
- | ===== Template <> Class mapping == | + | ===== Template ⇔ Class mapping == |
- The URL request to eg ''home.htm'' is automatically mapped to the class ''Home.java'', or, if not found: ''HomePage.java''. [[http://click.apache.org/docs/user-guide/html/ch04s02.html#application-automapping|More]] | - The URL request to eg ''home.htm'' is automatically mapped to the class ''Home.java'', or, if not found: ''HomePage.java''. [[http://click.apache.org/docs/user-guide/html/ch04s02.html#application-automapping|More]] | ||
- If no associated class can be found, ''redirect.html'' is used which results in the default URL (eg. ''home.htm'') and finally in the associated default class (''HomePage.java''). | - If no associated class can be found, ''redirect.html'' is used which results in the default URL (eg. ''home.htm'') and finally in the associated default class (''HomePage.java''). | ||
- The associated Velocity template for the class is specified by the requested file in the URL, eg. ''home.htm'' | - The associated Velocity template for the class is specified by the requested file in the URL, eg. ''home.htm'' | ||
- | - The associated Velocity template my by modified by the class by overwriting the [[ http://click.apache.org/docs/click-api/org/apache/click/Page.html#getTemplate%28%29|getTemplate]] method of the Page class. | + | - The associated Velocity template may by modified by the class by overwriting the [[ http://click.apache.org/docs/click-api/org/apache/click/Page.html#getTemplate%28%29|getTemplate]] method of the Page class. |
===== Border Page Template == | ===== Border Page Template == | ||
Zeile 73: | Zeile 73: | ||
FIXME Why is @Bindable not recognized? Add more jar files?? Look in Template! | FIXME Why is @Bindable not recognized? Add more jar files?? Look in Template! | ||
- | ===== Binding of Controls == | + | ===== Template ⇔ Class Binding == |
- | FIXME | + | FIXME Verify this paragraph! |
- | [[http://click.apache.org/docs/user-guide/html/ch02.html#classes|Page class overview]] | + | Java classes can be accessed by the Velocity templates by adding them to the ''model'' Map of the Page class. Adding can be done explicitely (by calling a method), implizitely (by making them public) or by using an annotation. More: [[http://click.apache.org/docs/user-guide/html/ch02.html#classes|Page class overview]], [[http://click.apache.org/docs/user-guide/html/ch04s02.html#application-autobinding|Autobinding]] |
+ | |||
+ | ==== Manual adding == | ||
+ | |||
+ | Distinguish between plain dynamic data types like ''String'' or ''Date'' and Click Control types like ''Checkbox'' or ''FormTable''. | ||
+ | |||
+ | Plain data types are made available for the Velocity template by calling ''Page.addModel()'' in the constructor of the Page class or in ''Page.onInit()''. | ||
+ | |||
+ | Click Control types must be added with ''Page.addControl()'' in ''Page.onInit()'' | ||
+ | |||
+ | ==== Automatic adding == | ||
+ | |||
+ | As default, all public attributes of a Page class are added automatically to the Page's ''model''. | ||
+ | |||
+ | ==== Adding by annotation == | ||
+ | |||
+ | Alle attributes of a Page, annotated with ''@Bindable'' are added automatically to the Page's ''model''. | ||
+ | |||
+ | The @Bindable annotation is only respected, when autobinding ist set to ''annotation'' in ''click.xml'': | ||
+ | <code xml> | ||
+ | <pages package="sb.translator.page" autobinding="annotation"/> | ||
+ | </code> | ||
+ | |||
+ | Alle Java files must import Bindable: | ||
+ | <code java> | ||
+ | import org.apache.click.util.Bindable; | ||
+ | </code> | ||
+ | |||
+ | <note tip>Using the @Bindable annotation seems to be the best way of binding :?:</note> | ||
===== Request Parameter Binding == | ===== Request Parameter Binding == |