<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    J2EE劍俠行

    直覺我的J2EE應(yīng)用生涯,打造我心中的一把利劍。

    常用鏈接

    統(tǒng)計

    技術(shù)鏈接

    最新評論

    用二維數(shù)組管理好你零亂的狀態(tài)、分類和其它常用選項

    ??? 很長時間沒有寫B(tài)LOG了,先啰嗦幾句。
    ??? 我已經(jīng)從一家不知名的小公司又一次回到了大公司里了,這是我7年工作來又一次回歸大公司。當然了小公司有小公司的心胸狹窄和陰險,大公司有嚴格的管理制度和進升方式,這都不能夠相提并論。所以建議有能力的朋友在大公司里做事,能夠讓自己用正確的方式做正確的事。
    ?-----------------------天行鍵,君子以自強不息!
    ??? 話入正題。
    ??? 在大家的編碼過程當中,有沒有遇到過這么一種情況,很多零亂的狀態(tài)、分類和其它常用選項常常是定義死了。但是沒有一個完整的東東來約束他,在每個模塊當中使用相關(guān)的信息時,往往重新COPY一次,或者COPY過來修改一次。如果多人協(xié)作的話,務(wù)必會讓代碼變的零亂、不好管理等。
    ??? 本次主要是把一些靜態(tài)的分類、狀態(tài)或者其它常用選項使用二維數(shù)組管理起來。如果你是一個使用JSTL或者STRUTS做前臺表現(xiàn)的話,你就更應(yīng)該好好關(guān)注了。
    ??? 以下以一個審核的狀態(tài)做示例,使用代碼實現(xiàn)(光說不練是假功夫).
    創(chuàng)建Config.java
    package?com.antbee;

    import?java.util.ArrayList;
    import?java.util.List;


    /**
    ?*?<p>
    ?*?</p>
    ?*?
    ?*?<p>
    ?*?Copyright:?版權(quán)所有?(c)?2002?-?2006
    ?*?</p>
    ?*?<p>
    ?*?Company:?Antbee
    ?*?</p>
    ?*?
    ?*?
    @author?@家軍
    ?*?
    @version?1.0
    ?
    */

    public?class?Config?{
    ????
    /**
    ?????*?客戶狀態(tài)
    ?????
    */
    ????Object?vec[][]?
    =?{?{?new?Integer(1),?new?String("申請"),new?String("apply")},
    ????????????{?
    new?Integer(2),?new?String("待審核"),new?String("auditing")?},
    ????????????{?
    new?Integer(3),?new?String("簽約"),new?String("sign?up")?},
    ????????????{?
    new?Integer(4),?new?String("續(xù)簽中"),new?String("nominator")?},
    ????????????{?
    new?Integer(5),?new?String("過期"),new?String("overdue")?}?};
    ????
    public?List?Stutas?=?GetConfigEntity(vec);????
    ????
    public?List?GetConfigEntity(Object?allconfig[][])?{
    ????????List?ConfigList?
    =?new?ArrayList();
    ??? ??? ConfigEntity first = new ConfigEntity();
    ??? ??? first.setTypeSeri(Integer.valueOf("0"));
    ??? ??? first.setTypeCnName("請選擇");
    ??? ??? first.setTypeEnName("Pls Select");
    ??? ??? ConfigList.add(first);
    ????????
    for(int?i=0;i<allconfig.length;i++){
    ????????????ConfigEntity?configEntity?
    =?new?ConfigEntity();????????????
    ????????????configEntity.setTypeSeri(Integer.valueOf(allconfig[i][
    0].toString()));
    ????????????configEntity.setTypeCnName(allconfig[i][
    1].toString());
    ????????????configEntity.setTypeEnName(allconfig[i][
    2].toString());
    ????????????ConfigList.add(configEntity);
    ????????}
    ????????
    return?ConfigList;
    ????}
    }
    對應(yīng)的PO實體類ConfigEntity.java(如果有數(shù)據(jù)庫的話,你就可以直接從數(shù)據(jù)庫當中取)
    package?com.antbee;

    import?java.io.Serializable;

    public?class?ConfigEntity?implements?Serializable?{
    ???????
    /**?The?cached?hash?code?value?for?this?instance.??Settting?to?0?triggers?re-calculation.?*/
    ????
    private?int?hashValue?=?0;

    ????
    /**?The?composite?primary?key?value.?*/
    ????
    private?java.lang.Integer?typeSeri;

    ????
    /**?The?value?of?the?simple?typeName?property.?*/
    ????
    private?java.lang.String?typeCnName;
    ????
    ????
    /**?The?value?of?the?simple?typeName?property.?*/
    ????
    private?java.lang.String?typeEnName;

    ????
    /**
    ?????*?Simple?constructor?of?AbstractDicType?instances.
    ?????
    */
    ????
    public?ConfigEntity()
    ????{
    ????}

    ????
    /**
    ?????*?Constructor?of?AbstractDicType?instances?given?a?simple?primary?key.
    ?????*?
    @param?typeSeri
    ?????
    */
    ????
    public?ConfigEntity(java.lang.Integer?typeSeri)
    ????{
    ????????
    this.setTypeSeri(typeSeri);
    ????}

    ????
    /**
    ?????*?Return?the?simple?primary?key?value?that?identifies?this?object.
    ?????*?
    @return?java.lang.Integer
    ?????
    */
    ????
    public?java.lang.Integer?getTypeSeri()
    ????{
    ????????
    return?typeSeri;
    ????}

    ????
    /**
    ?????*?Set?the?simple?primary?key?value?that?identifies?this?object.
    ?????*?
    @param?typeSeri
    ?????
    */
    ????
    public?void?setTypeSeri(java.lang.Integer?typeSeri)
    ????{
    ????????
    this.hashValue?=?0;
    ????????
    this.typeSeri?=?typeSeri;
    ????}

    ????
    /**
    ?????*?Return?the?value?of?the?TYPE_NAME?column.
    ?????*?
    @return?java.lang.String
    ?????
    */
    ????
    public?java.lang.String?getTypeCnName()
    ????{
    ????????
    return?this.typeCnName;
    ????}

    ????
    /**
    ?????*?Set?the?value?of?the?TYPE_NAME?column.
    ?????*?
    @param?typeName
    ?????
    */
    ????
    public?void?setTypeCnName(java.lang.String?typeCnName)
    ????{
    ????????
    this.typeCnName?=?typeCnName;
    ????}???

    ????
    /**
    ?????*?Return?the?value?of?the?TYPE_NAME?column.
    ?????*?
    @return?java.lang.String
    ?????
    */
    ????
    public?java.lang.String?getTypeEnName()
    ????{
    ????????
    return?this.typeEnName;
    ????}

    ????
    /**
    ?????*?Set?the?value?of?the?TYPE_NAME?column.
    ?????*?
    @param?typeName
    ?????
    */
    ????
    public?void?setTypeEnName(java.lang.String?typeEnName)
    ????{
    ????????
    this.typeEnName?=?typeEnName;
    ????}?
    ????
    ????
    /**
    ?????*?Implementation?of?the?equals?comparison?on?the?basis?of?equality?of?the?primary?key?values.
    ?????*?
    @param?rhs
    ?????*?
    @return?boolean
    ?????
    */
    ????
    public?boolean?equals(Object?rhs)
    ????{
    ????????
    if?(rhs?==?null)
    ????????????
    return?false;
    ????????
    if?(!?(rhs?instanceof?ConfigEntity))
    ????????????
    return?false;
    ????????ConfigEntity?that?
    =?(ConfigEntity)?rhs;
    ????????
    if?(this.getTypeSeri()?==?null?||?that.getTypeSeri()?==?null)
    ????????????
    return?false;
    ????????
    return?(this.getTypeSeri().equals(that.getTypeSeri()));
    ????}

    ????
    /**
    ?????*?Implementation?of?the?hashCode?method?conforming?to?the?Bloch?pattern?with
    ?????*?the?exception?of?array?properties?(these?are?very?unlikely?primary?key?types).
    ?????*?
    @return?int
    ?????
    */
    ????
    public?int?hashCode()
    ????{
    ????????
    if?(this.hashValue?==?0)
    ????????{
    ????????????
    int?result?=?17;
    ????????????
    int?typeSeriValue?=?this.getTypeSeri()?==?null???0?:?this.getTypeSeri().hashCode();
    ????????????result?
    =?result?*?37?+?typeSeriValue;
    ????????????
    this.hashValue?=?result;
    ????????}
    ????????
    return?this.hashValue;
    ????}
    }
    具體使用方法
    /*Antbee?@家軍
    */
    Config?n?
    =?new?Config();
    List?View_Stutas?
    =?n.Stutas;????????request.setAttribute("View_Stutas",?View_Stutas);
    頁面當中示例:
    <c:forEach?items="${View_Stutas}"?var="View_Stutas">
    ??????????????
    <option?value="<c:out?value="${View_Stutas.typeSeri?}"?/>"><c:out?value="${View_Stutas.typeEnName}"/></option>
    ???????????
    </c:forEach>
    可以看出,在實體類里一共有三個方法,其它有兩個名字, 一個是中文名字,一個是英文名字,你可以在頁面當中截取本地語言并顯示其中一個語言就行。

    posted on 2006-09-05 13:31 @家軍 閱讀(1288) 評論(0)  編輯  收藏 所屬分類: J2EE技術(shù)類

    主站蜘蛛池模板: 亚洲综合色成在线播放| 久草福利资源网站免费| 成人免费视频软件网站| 亚洲制服丝袜精品久久| 美丽的姑娘免费观看在线播放 | 97公开免费视频| 久久亚洲美女精品国产精品| 久久国产乱子伦精品免费看| 亚洲AV无码专区在线播放中文 | 亚洲av无码有乱码在线观看| 在线精品免费视频无码的| 亚洲精华国产精华精华液| 日本免费电影一区| 九一在线完整视频免费观看| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 麻豆一区二区免费播放网站| 亚洲一区精彩视频| 四虎免费久久影院| 免费无遮挡无遮羞在线看| 亚洲一级Av无码毛片久久精品| 国产免费久久久久久无码| 亚洲av午夜福利精品一区人妖| 免费观看黄色的网站| 亚洲偷自拍另类图片二区| 亚洲AV无码乱码在线观看牲色| 免费看一区二区三区四区| 亚洲人成在线精品| 亚洲国产一成久久精品国产成人综合 | 成年轻人网站色免费看| 美女被免费视频网站| 亚洲午夜久久久久妓女影院| 2021在线永久免费视频| 亚洲国产精品无码中文lv| 91麻豆国产自产在线观看亚洲| 日韩精品久久久久久免费| 亚洲GV天堂无码男同在线观看 | 男人的天堂亚洲一区二区三区| 免费无码又爽又黄又刺激网站| 婷婷亚洲综合五月天小说 | 免费无码看av的网站| 中国一级特黄高清免费的大片中国一级黄色片 |