KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > tree > TreeComponentTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.tree;
14
15 import javax.servlet.jsp.JspException JavaDoc;
16
17 import com.tonbeller.wcf.component.Component;
18 import com.tonbeller.wcf.component.ComponentTag;
19 import com.tonbeller.wcf.controller.RequestContext;
20 import com.tonbeller.wcf.selection.SelectionModel;
21
22 /**
23  * TreeComponent
24  * @author av
25  */

26 public class TreeComponentTag extends ComponentTag {
27   String JavaDoc model, selectionModel;
28   
29   public Component createComponent(RequestContext context) throws JspException JavaDoc {
30     // find the model
31
if (model != null) {
32       TreeModel tm = (TreeModel)context.getModelReference(model);
33       if (tm == null)
34         throw new JspException JavaDoc("model \"" + model + "\" not found");
35       TreeComponent tc = new TreeComponent(getId(), null, tm);
36       if (selectionModel != null) {
37         SelectionModel sm = (SelectionModel)context.getModelReference(selectionModel);
38         tc.setSelectionModel(sm);
39       }
40       return tc;
41     }
42     
43     // create testdata
44
TestTreeModel ttm = new TestTreeModel();
45     MutableTreeModelDecorator mtmd = new MutableTreeModelDecorator(ttm);
46     TreeComponent tc = new TreeComponent(id, null, mtmd);
47     tc.setDeleteNodeModel(ttm.getDeleteNodeModel());
48     return tc;
49   }
50
51   /**
52    * Sets the model.
53    * @param model The model to set
54    */

55   public void setModel(String JavaDoc model) {
56     this.model = model;
57   }
58
59   /**
60    * Sets the selectionModel.
61    * @param model The selectionModel to set
62    */

63   public void setSelectionModel(String JavaDoc selectionModel) {
64     this.selectionModel = selectionModel;
65   }
66 }
67
Popular Tags