⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scriptjsfbean.java

📁 openacs source for CPE wan management
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package org.openacs.web;import java.util.logging.Level;import java.util.logging.Logger;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.FinderException;import javax.ejb.RemoveException;import javax.faces.context.FacesContext;import org.openacs.ScriptLocal;import org.openacs.utils.Ejb;/** * * @author Administrator */public class ScriptJsfBean {    /** Creates a new instance of ScriptJsfBean */    public ScriptJsfBean() {        String name = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("scriptname");        if (name != null) {            this.name = name;            try {                ScriptLocal s = Ejb.lookupScriptBean().findByPrimaryKey(name);                description = s.getDescription();                text = new String (s.getScript());            } catch (FinderException ex) {                //Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);            }        }    }    private Object[] arrayScriptNames = null;    public Object[] getAll() throws FinderException {//        System.out.println ("ScriptJsfBean.getAll");        if (arrayScriptNames != null) {            return arrayScriptNames;        } else {            return arrayScriptNames = Ejb.lookupScriptBean().findAll().toArray();        }    }    private String description;    public String getDescription () {//        System.out.println ("ScriptJsfBean.getDescription");        return description;    }    public void setDescription (String description) {//        System.out.println ("ScriptJsfBean.setDescription");        this.description = description;    }    private String name;    public String getName () {//        System.out.println ("ScriptJsfBean.getName "+name);        return name;    }    public void setName (String name) {//        System.out.println ("ScriptJsfBean.setName="+name);        this.name = name;        /*        if (this.name == null || !this.name.equals(name)) {            this.name = name;            try {                ScriptLocal s = Ejb.lookupScriptBean().findByPrimaryKey(name);                description = s.getDescription();                text = new String (s.getScript());            } catch (FinderException ex) {                //Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);            }        }        */    }    protected String text = "";    /**     * Get the value of text     *     * @return the value of text     */    public String getText() {        return text;    }    /**     * Set the value of text     *     * @param text new value of text     */    public void setText(String text) {        this.text = text;    }    public boolean isNew () {        return name == null || name.equals("");    }    public String Save () {//        System.out.println ("ScriptJsfBean.Save () name="+name);        try {            ScriptLocal s = Ejb.lookupScriptBean().findByPrimaryKey(name);            s.setDescription(description);            s.setScript(text.getBytes());        } catch (FinderException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        }        return null;    }    public String Create () {//        System.out.println ("ScriptJsfBean.Create () name="+name);        try {            ScriptLocal s = Ejb.lookupScriptBean().create(name);            s.setDescription(description);            s.setScript(text.getBytes());        } catch (CreateException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        }        return null;    }    public String Delete () {//        System.out.println ("ScriptJsfBean.Delete () name="+name);        try {            Ejb.lookupScriptBean().findByPrimaryKey(name).remove();        } catch (FinderException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        } catch (EJBException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        } catch (RemoveException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        }        name = text = description = null;        return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -