KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > component > UIPageBrowser


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.component;
6
7 import org.exoplatform.commons.exception.ExoPermissionException;
8 import org.exoplatform.container.SessionContainer;
9 import org.exoplatform.faces.core.component.UINode;
10 import org.exoplatform.portal.session.ExoPortal;
11 import org.exoplatform.portal.session.RequestInfo;
12 import org.exoplatform.services.portal.PortalACL;
13 import org.exoplatform.services.portal.PortalConfigService;
14 import org.exoplatform.services.portal.model.Node;
15 import org.exoplatform.services.portal.model.Page;
16 /**
17  * @email: tuan08@users.sourceforge.net
18  * @version: $Id: UIPageBrowser.java,v 1.9 2004/09/28 18:19:21 tuan08 Exp $
19  */

20 public class UIPageBrowser extends UINode {
21   static final public String JavaDoc UI_NAVIGATION_NODE_FORM = "UINavigationNodeForm" ;
22   static final public String JavaDoc UI_PAGE = "UIPage" ;
23   
24   private PortalConfigService service_ ;
25   private String JavaDoc returnModule_ ;
26   
27   public UIPageBrowser(PortalConfigService service) throws Exception JavaDoc {
28     setId("UIPageBrowser") ;
29     setRendererType("ChildrenRenderer") ;
30     service_ = service ;
31     RequestInfo rinfo = (RequestInfo)SessionContainer.getComponent(RequestInfo.class) ;
32     String JavaDoc owner = rinfo.getPortalOwner() ;
33     
34     UIPageList uiPageList = (UIPageList) addChild(UIPageList.class) ;
35     uiPageList.queryDescriptions(owner, null, null) ;
36     addChild(UIPageModelForm.class).setRendered(false) ;
37   }
38   
39   public PortalConfigService getPortalConfigService() { return service_ ; }
40   
41   public void setReturnModule(String JavaDoc name) { returnModule_ = name ;}
42   
43   public void goBack() {
44     UIPortal uiPortal = (UIPortal) getAncestorOfType(UIPortal.class);
45     if(UI_NAVIGATION_NODE_FORM.equals(returnModule_)) {
46          UIPageNodeForm uiForm =
47         (UIPageNodeForm)uiPortal.getPortalComponent(UIPageNodeForm.class);
48       uiPortal.setBodyComponent(uiForm) ;
49     } else {
50       uiPortal.setBodyComponent(uiPortal.getCurrentUIPage()) ;
51     }
52   }
53   
54   public void setSelectNodeReferencePage(String JavaDoc refPage) throws Exception JavaDoc {
55     UIPortal uiPortal = (UIPortal) getAncestorOfType(UIPortal.class);
56     Page page = service_.getPage(refPage) ;
57     PortalACL acl = service_.getPortalACL() ;
58     if(!acl.hasViewPagePermission(page, uiPortal.getOwner())) {
59       throw new ExoPermissionException("selectPage", "onwer") ;
60     }
61     if(UI_NAVIGATION_NODE_FORM.equals(returnModule_)) {
62       UIPageNodeForm uiNavigationNodeForm =
63         (UIPageNodeForm)uiPortal.getPortalComponent(UIPageNodeForm.class);
64       uiNavigationNodeForm.returnReferencePage(refPage) ;
65       uiPortal.setBodyComponent(uiNavigationNodeForm) ;
66     } else {
67       Node selectNode = uiPortal.getSelectedNode() ;
68       selectNode.getPageReference(ExoPortal.XHTML_MIME_TYPE).setPageReference(refPage) ;
69       uiPortal.setSelectedNode(selectNode) ;
70     }
71   }
72 }
Popular Tags