KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > BaseManagedBean


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.ui.web.admin;
15
16 import java.io.Serializable JavaDoc;
17
18 import javax.faces.application.FacesMessage;
19 import javax.faces.context.FacesContext;
20
21 import org.ejbca.core.model.authorization.AuthorizationDeniedException;
22 import org.ejbca.core.model.log.Admin;
23 import org.ejbca.ui.web.admin.configuration.EjbcaJSFHelper;
24 import org.ejbca.ui.web.admin.configuration.EjbcaWebBean;
25
26 /**
27  * Base EJBCA JSF Managed Bean, all managed beans of EJBCA should inherit this class
28  *
29  * @author Philip Vendil
30  * @version $Id: BaseManagedBean.java,v 1.3 2006/10/26 11:06:29 herrvendil Exp $
31  */

32 public abstract class BaseManagedBean implements Serializable JavaDoc{
33    
34   
35   protected EjbcaWebBean getEjbcaWebBean(){
36       return EjbcaJSFHelper.getBean().getEjbcaWebBean();
37   }
38   
39   protected void isAuthorizedNoLog(String JavaDoc resource) throws AuthorizationDeniedException{
40       getEjbcaWebBean().isAuthorizedNoLog(resource);
41   }
42   
43   protected void addErrorMessage(String JavaDoc messageResource){
44       FacesContext ctx = FacesContext.getCurrentInstance();
45       ctx.addMessage("error", new FacesMessage(FacesMessage.SEVERITY_ERROR,getEjbcaWebBean().getText(messageResource, true),getEjbcaWebBean().getText(messageResource, true)));
46   }
47   
48   protected void addNonTranslatedErrorMessage(String JavaDoc messageResource){
49       FacesContext ctx = FacesContext.getCurrentInstance();
50       ctx.addMessage("error", new FacesMessage(FacesMessage.SEVERITY_ERROR,messageResource,messageResource));
51   }
52   
53   
54   protected Admin getAdmin(){
55       return EjbcaJSFHelper.getBean().getAdmin();
56   }
57   
58
59     
60 }
61
Popular Tags