KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > listener > share > DeleteActionListener


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portal.faces.listener.share;
6
7 import java.util.List JavaDoc;
8 import org.exoplatform.faces.application.ExoFacesMessage;
9 import org.exoplatform.faces.core.component.InformationProvider;
10 import org.exoplatform.faces.core.event.ExoActionEvent;
11 import org.exoplatform.faces.core.event.ExoActionListener;
12 import org.exoplatform.portal.faces.component.UIBasicComponent;
13 import org.exoplatform.portal.faces.component.UIBody;
14 import org.exoplatform.portal.faces.component.UIContainer;
15
16 /**
17  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
18  * @since Aug 16, 2004
19  * @version $Id: DeleteActionListener.java,v 1.1 2004/09/26 02:25:48 tuan08 Exp $
20  */

21 public class DeleteActionListener extends ExoActionListener {
22   public void execute(ExoActionEvent event) throws Exception JavaDoc {
23     UIBasicComponent uiComponent = (UIBasicComponent) event.getSource() ;
24     // Cannot remove the container that has the Body component
25
if(uiComponent instanceof UIContainer) {
26       if(uiComponent.findComponentById(UIBody.COMPONENT_ID) != null) {
27         InformationProvider iprovider = findInformationProvider(uiComponent) ;
28         iprovider.addMessage(new ExoFacesMessage("#{UIContainer.msg.remove-body-container}")) ;
29         return ;
30       }
31     }
32     UIBasicComponent uiParent = (UIBasicComponent)uiComponent.getParent() ;
33     List JavaDoc children = uiParent.getChildren() ;
34     children.remove(uiComponent) ;
35     uiParent.setComponentModified(true) ;
36   }
37 }
Popular Tags