UIBaseNodeTreeSelector.java

  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. import javax.jcr.Node;

  19. import org.exoplatform.ecm.webui.selector.ComponentSelector;
  20. import org.exoplatform.portal.webui.container.UIContainer;
  21. import org.exoplatform.webui.core.UIComponent;

  22. /**
  23.  * Created by The eXo Platform SAS.
  24.  *
  25.  * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008
  26.  */
  27. public abstract class UIBaseNodeTreeSelector extends UIContainer implements ComponentSelector {

  28.   protected UIComponent sourceUIComponent ;
  29.   protected String returnFieldName = null ;
  30.   /**
  31.    * On change.
  32.    *
  33.    * @param currentNode the current node
  34.    * @param context the request context
  35.    * @throws Exception the exception
  36.    */
  37.   public abstract void onChange(final Node currentNode, Object context) throws Exception;
  38.   public String getReturnFieldName() { return returnFieldName; }

  39.   public void setReturnFieldName(String name) { this.returnFieldName = name; }

  40.   public UIComponent getSourceComponent() { return sourceUIComponent; }
  41.   public void setSourceComponent(UIComponent uicomponent, String[] initParams) {
  42.     sourceUIComponent = uicomponent ;
  43.     if(initParams == null || initParams.length < 0) return ;
  44.     for(int i = 0; i < initParams.length; i ++) {
  45.       if(initParams[i].indexOf("returnField") > -1) {
  46.         String[] array = initParams[i].split("=") ;
  47.         returnFieldName = array[1] ;
  48.         break ;
  49.       }
  50.       returnFieldName = initParams[0] ;
  51.     }
  52.   }

  53. }