KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > datagrid > DatagridCheckboxTag


1 /*
2  * Created on 13 avr. 2004
3  *
4  * Copyright Improve SA 2004.
5  * All rights reserved.
6  */

7 package fr.improve.struts.taglib.layout.datagrid;
8
9 import javax.servlet.jsp.JspException JavaDoc;
10
11 import fr.improve.struts.taglib.layout.collection.CollectionTag;
12 import fr.improve.struts.taglib.layout.collection.SimpleItemContext;
13 import fr.improve.struts.taglib.layout.util.LayoutUtils;
14
15 /**
16  * Simplified collectionInput tag for the datagrid : only the property and key attributes are needed.
17  * @author jnribette
18  */

19 public class DatagridCheckboxTag extends AbstractDatagridColumnTag {
20     
21     protected SimpleItemContext createItemContext() {
22         DatagridItemContext context = new DatagridItemContext();
23         context.setColumnType(ColumnType.CHECKBOX);
24         return context;
25     }
26
27     protected String JavaDoc getType() {
28         return "checkbox";
29     }
30     
31     /**
32      * Build the input field value : use the Datagrid object.
33      */

34     protected Object JavaDoc buildInputFieldValue(CollectionTag in_parent, boolean in_anyError) throws JspException JavaDoc {
35         return "true";
36     }
37     
38     protected String JavaDoc buildAdditionalAttributes(CollectionTag in_parent) throws JspException JavaDoc{
39         // get the value from the current bean in the collection
40
Object JavaDoc value = LayoutUtils.getProperty(in_parent.getBean(), property);
41         if (value!=null && "true".equals(value.toString())) {
42             return "checked";
43         } else {
44             return "";
45         }
46     }
47 }
48
Popular Tags