JSF 怎么将标签值传入BEAN
<h:selectOneRadiovalue="#{user.locale}"id="language_change_select"><f:selectItemitemV...
<h:selectOneRadio value="#{user.locale}" id="language_change_select" >
<f:selectItem itemValue="zh" itemLabel="#{msgs.zh_TWText}" />
<f:selectItem itemValue="en" itemLabel="#{msgs.enText}" />
</h:selectOneRadio>
比如要选择 1 或 2 将页面选择的值 传入到bean中处理返回页面
bean中怎么获取到页面的选择值呢
JSF <f:view locale="#{user.locale}"> 改变设定的properties 文件
bean 中值已经改变 但是运用的properties 文件还是没有加载 展开
<f:selectItem itemValue="zh" itemLabel="#{msgs.zh_TWText}" />
<f:selectItem itemValue="en" itemLabel="#{msgs.enText}" />
</h:selectOneRadio>
比如要选择 1 或 2 将页面选择的值 传入到bean中处理返回页面
bean中怎么获取到页面的选择值呢
JSF <f:view locale="#{user.locale}"> 改变设定的properties 文件
bean 中值已经改变 但是运用的properties 文件还是没有加载 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏10(财富值+成长值)
1个回答
展开全部
your backing bean is "user" according to your code. This might be wrong, "user" looks to me is a domain object property in your backing bean.
Assume your backing bean looks like this:
@ManagedBean(name="changeLocaleBean")
public class ChangeLocaleBean implements Serializable {
private User user;
private String lang;
public String getLang() { return lang; }
public void setLang(String lang) { this.lang = lang;}
......
// action handler
public String changeLocale() {
log.debug("changing user language to: " + this.lang);
// language has been changed, change user locale
this.user.setLocale(new Locale(this.lang));
// you need to push it to current session, might do a redrect to the current page.
return "currentPage.jsf?faces-redirect=true";
}
}
then your jsf page:
<h:selectOneRadio value="#{changeLocaleBean.lang}" id="language_change_select" >
<f:selectItem itemValue="zh" itemLabel="#{msgs.zh_TWText}" />
<f:selectItem itemValue="en" itemLabel="#{msgs.enText}" />
</h:selectOneRadio>
Assume your backing bean looks like this:
@ManagedBean(name="changeLocaleBean")
public class ChangeLocaleBean implements Serializable {
private User user;
private String lang;
public String getLang() { return lang; }
public void setLang(String lang) { this.lang = lang;}
......
// action handler
public String changeLocale() {
log.debug("changing user language to: " + this.lang);
// language has been changed, change user locale
this.user.setLocale(new Locale(this.lang));
// you need to push it to current session, might do a redrect to the current page.
return "currentPage.jsf?faces-redirect=true";
}
}
then your jsf page:
<h:selectOneRadio value="#{changeLocaleBean.lang}" id="language_change_select" >
<f:selectItem itemValue="zh" itemLabel="#{msgs.zh_TWText}" />
<f:selectItem itemValue="en" itemLabel="#{msgs.enText}" />
</h:selectOneRadio>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询