View Javadoc
1   /*
2    * Copyright (C) 2003-2008 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.tree;
18  
19  import javax.jcr.Node;
20  
21  import org.exoplatform.ecm.webui.selector.ComponentSelector;
22  import org.exoplatform.portal.webui.container.UIContainer;
23  import org.exoplatform.webui.core.UIComponent;
24  
25  /**
26   * Created by The eXo Platform SAS.
27   *
28   * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008
29   */
30  public abstract class UIBaseNodeTreeSelector extends UIContainer implements ComponentSelector {
31  
32    protected UIComponent sourceUIComponent ;
33    protected String returnFieldName = null ;
34    /**
35     * On change.
36     *
37     * @param currentNode the current node
38     * @param context the request context
39     * @throws Exception the exception
40     */
41    public abstract void onChange(final Node currentNode, Object context) throws Exception;
42    public String getReturnFieldName() { return returnFieldName; }
43  
44    public void setReturnFieldName(String name) { this.returnFieldName = name; }
45  
46    public UIComponent getSourceComponent() { return sourceUIComponent; }
47    public void setSourceComponent(UIComponent uicomponent, String[] initParams) {
48      sourceUIComponent = uicomponent ;
49      if(initParams == null || initParams.length < 0) return ;
50      for(int i = 0; i < initParams.length; i ++) {
51        if(initParams[i].indexOf("returnField") > -1) {
52          String[] array = initParams[i].split("=") ;
53          returnFieldName = array[1] ;
54          break ;
55        }
56        returnFieldName = initParams[0] ;
57      }
58    }
59  
60  }