本项目由繁体中文和英文两种环境,切换语言的链接在页眉的右边,如图:
通过点击“English”,可以将整个系统的语言环境转换为“英文”,下面是从“英文”环境转为“繁体中文”环境后的页面情况:
标签已经转换为“繁体”环境,但是下拉列表中的内容还是“英文”的内容,产生这个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) 编辑 收藏