从制造到创造
软件工程师成长之路
posts - 292,  comments - 96,  trackbacks - 0

本项目由繁体中文和英文两种环境,切换语言的链接在页眉的右边,如图:
snap0003.jpg

通过点击“English”,可以将整个系统的语言环境转换为“英文”,下面是从“英文”环境转为“繁体中文”环境后的页面情况:
snap0002.jpg

标签已经转换为“繁体”环境,但是下拉列表中的内容还是“英文”的内容,产生这个Bug的原因是由于整个下拉的List存储在生命期为 Session 的 DBean 中,而此所有 List 的初始化的代码都在 DBean 的构造函数中,这样,即使改变语言,由于DBean的生命期未结束,List的内容不会更根据语言环境而改变。

     /** MaintainClaimNoticeDBean
     
*/
    
public  MaintainClaimNoticeDBean() {
        
this .queryVO  =   new  QueryClaimNoticeDataVO();
        
this .nonGohVO  =   new  MaintainClaimNoticeDataVO();
        
this .gohVO  =   new  MaintainClaimNoticeGohDataVO();
        
this .cnService  =   new  MaintainClaimNoticeDataService();
        
this .msgService  =   new  MessageService();
        
this .gohService  =   new  MaintainClaimNoticeGohDataService();
        CodeTableService codeTableService 
=   new  CodeTableService();
        
try  {
            
this .selectItemCompanyFlag  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.COMPANY_FLAG, getLocale()));
            
this .selectItemHandleStatus  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.HANDLE_STATUS,
                                    getLocale()));
            
this .selectItemClaimNoticeClass  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.CLAIMNOTICE_CLASS,
                                    getLocale()));
            
this .selectItemPolicyStatus  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.POLICY_STATUS,
                                    getLocale()));
            
this .selectItemReCompanyCode  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.RE_COMPANY_CODE,
                                    getLocale()));
            
this .selectItemReinsuranceLevel  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.REINSURANCE_LEVEL,
                                    getLocale()));
        } 
catch  (BusiException e) {
            
this .setDisplayMsg(e.getExceptionMessage());
        }
    }


修改办法:
将所有下拉列表的初始化代码放在第一个下拉列表的get方法中:这里CompanyFlag是第一下拉列表:

     /**
     * Method getSelectItemCompanyFlag.
     * 
     * 
@return  SelectItem[]
     
*/
    
public  SelectItem[] getSelectItemCompanyFlag() {
        
this .reset();

        CodeTableService codeTableService 
=   new  CodeTableService();
        
try  {
            
this .selectItemCompanyFlag  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.COMPANY_FLAG, getLocale()));
            
this .selectItemHandleStatus  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.HANDLE_STATUS,
                                    getLocale()));
            
this .selectItemClaimNoticeClass  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.CLAIMNOTICE_CLASS,
                                    getLocale()));
            
this .selectItemPolicyStatus  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.POLICY_STATUS,
                                    getLocale()));
            
this .selectItemReCompanyCode  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.RE_COMPANY_CODE,
                                    getLocale()));
            
this .selectItemReinsuranceLevel  =  Tools
                    .ConverterListtoSelectItem(codeTableService
                            .getSelectOneListbox(
                                    GroupCodeConstant.REINSURANCE_LEVEL,
                                    getLocale()));
        } 
catch  (BusiException e) {
            
this .setDisplayMsg(e.getExceptionMessage());
        }

        
return   this .selectItemCompanyFlag;
    }

这样,每次进入页面,第一个标签中的下拉列表框的内容都由JSF通过该标签的getter方法得到。
 

posted on 2007-03-08 10:41 CoderDream 阅读(415) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

<2007年3月>
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用链接

留言簿(9)

我参与的团队

随笔分类(245)

随笔档案(239)

文章分类(3)

文章档案(3)

收藏夹(576)

友情链接

搜索

  •  

积分与排名

  • 积分 - 456484
  • 排名 - 114

最新评论

阅读排行榜

评论排行榜