01 package net.sourceforge.wicketwebbeans.examples.css;
02 
03 import net.sourceforge.wicketwebbeans.containers.BeanForm;
04 import net.sourceforge.wicketwebbeans.model.BeanMetaData;
05 import net.sourceforge.wicketwebbeans.model.ElementMetaData;
06 import net.sourceforge.wicketwebbeans.model.api.JBean;
07 import net.sourceforge.wicketwebbeans.model.api.JBeans;
08 import net.sourceforge.wicketwebbeans.model.api.JProperty;
09 
10 import org.apache.wicket.ajax.AjaxRequestTarget;
11 import org.apache.wicket.markup.html.WebPage;
12 import org.apache.wicket.markup.html.form.Form;
13 
14 
15 public class CssPage extends WebPage
16 {
17     public CssPage()
18     {
19         TestBean bean = new TestBean();
20         
21         // Create the meta data
22         JBeans jbeans = new JBeans(
23             new JBean(TestBean.class)
24                 .columns(1)
25                 .css("greenBeanBorder")
26                 .propertyNames("firstName""lastName""rows")
27                 .propertiesnew JProperty("firstName").css("purpleColor") ),
28             new JBean(RowBean.class)
29                 .css("redBeanBorder"
30                 .dynamicCss("getRowCss")
31                 .propertiesnew JProperty("description").dynamicCss("getDescriptionCss") )
32         );
33         
34         BeanMetaData meta = new BeanMetaData(bean.getClass(), null, jbeans, this, null, false);
35         addnew BeanForm("beanForm", bean, meta) );
36     }
37 
38     public void save(AjaxRequestTarget target, Form form, TestBean bean)
39     {
40         info("Saved");
41     }
42     
43     public String getRowCss(RowBean bean, BeanMetaData beanMetaData)
44     {
45         if (bean.getAmount() 0) {
46             return "greaterThanZero";
47         }
48         
49         if (bean.getAmount() 0) {
50             return "lessThanZero";
51         }
52         
53         return null;
54     }
55 
56     public String getDescriptionCss(RowBean bean, ElementMetaData elementMetaData)
57     {
58         if (bean.getAmount() 0) {
59             return "fieldPositive";
60         }
61         
62         if (bean.getAmount() 0) {
63             return "fieldNegative";
64         }
65         
66         return null;
67     }
68 }
Java2html