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

📄 hwmodeljsfbean.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.Map;import java.util.Map.Entry;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.HardwareModelLocal;import org.openacs.utils.Ejb;/** * * @author Administrator */public class HwModelJsfBean {    /** Creates a new instance of HwModelJsfBean */    public HwModelJsfBean() {//        System.out.println("HwModelJsfBean.constructor");        /*        FacesContext ctx = FacesContext.getCurrentInstance();        Map<String,Object> rm = ctx.getExternalContext().getRequestMap();        for (Entry<String,Object> e : rm.entrySet()) {            System.out.println ("RequestMap: "+e.getKey()+" -> "+e.getValue());        }        Map<String,String> rpm = ctx.getExternalContext().getRequestParameterMap();        for (Entry<String,String> e : rpm.entrySet()) {            System.out.println ("RequestParameterMap: "+e.getKey()+" -> "+e.getValue());        }        */        String hwid = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("hwid");        if (hwid != null) {            setId (Integer.parseInt(hwid));        }    }    private Object[] arrayAll = null;    public Object[] getAll() throws FinderException {//        System.out.println("HwModelJsfBean.getAll");        if (arrayAll != null) {            return arrayAll;        } else {            return arrayAll = Ejb.lookupHardwareModelBean().findAll().toArray();        }    }    protected Integer id = null;    /**     * Get the value of id     *     * @return the value of id     */    public Integer getId() {        return id;    }    /**     * Set the value of id     *     * @param id new value of id     */    public void setId(Integer id) {//        System.out.println("HwModelJsfBean.setId=" + id);        if (id != null && (this.id == null || this.id != id)) {            this.id = id;            try {                HardwareModelLocal s = Ejb.lookupHardwareModelBean().findByPrimaryKey(id);                displayName = s.getDisplayName();                hclass = s.getHclass();                manufacturer = s.getManufacturer();                oui = s.getOui();                version = s.getVersion();            } catch (FinderException ex) {                //Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);            }        }    }    public boolean isNew() {        return id == null;    }    private String oui;    public String getOui() {        return oui;    }    public void setOui(String oui) {        this.oui = oui;    }    private String hclass;    public String getHclass() {        return hclass;    }    public void setHclass(String hclass) {        this.hclass = hclass;    }    private String manufacturer;    public String getManufacturer() {        return manufacturer;    }    public void setManufacturer(String manufacturer) {        this.manufacturer = manufacturer;    }    private String version;    public String getVersion() {        return version;    }    public void setVersion(String version) {        this.version = version;    }    private String displayName;    public String getDisplayName() {        return displayName;    }    public void setDisplayName(String displayName) {        this.displayName = displayName;    }    public String Save() {//        System.out.println("ScriptJsfBean.Save () id=" + id);        try {            HardwareModelLocal s = Ejb.lookupHardwareModelBean().findByPrimaryKey(id);            s.setDisplayName(displayName);            s.setHclass(hclass);            s.setManufacturer(manufacturer);            s.setOui(oui);            s.setVersion(version);        } catch (FinderException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        }        return null;    }    public String Create() {//        System.out.println("ScriptJsfBean.Create () id=" + id);        try {            HardwareModelLocal s = Ejb.lookupHardwareModelBean().create(null);            id = (Integer)s.getId();            s.setDisplayName(displayName);            s.setHclass(hclass);            s.setManufacturer(manufacturer);            s.setOui(oui);            s.setVersion(version);        } catch (CreateException ex) {            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);        }        return null;    }    public String Delete() {//        System.out.println("ScriptJsfBean.Delete () id=" + id);        try {            Ejb.lookupHardwareModelBean().findByPrimaryKey(id).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);        }        id = null;        displayName = oui = version = hclass = manufacturer = null;        return null;    }}

⌨️ 快捷键说明

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