[英]how to set to OldValue the primefaces selectOneMenu programmatically
Java / PrimeFaces 3.5 Java / PrimeFaces 3.5
I would like to rollback primeFaces selectOneMenu Old Value and reload it updating the component at screen.我想回滚 primeFaces selectOneMenu Old Value 并重新加载它以更新屏幕上的组件。
The selectOneMenu is loaded with FIRST, SECOND , THIRD values and default value is setted with FIRST selectOneMenu 加载了 FIRST、SECOND、THIRD 值,默认值设置为 FIRST
If I change the selectOneMenu value From FIRST to THIRD, I would like to set it to FIRST again.如果我将 selectOneMenu 值从 FIRST 更改为 THIRD,我想再次将其设置为 FIRST。
<p:selectOneMenu id="statusProposta" value="#{propostaBean.propostaComercial.proposta_Status}" items="#{propostaBean.statusProposta}" valueChangeListener="#{propostaBean.regraStatusProposta}" > <p:ajax event="change" process="statusProposta" update="statusProposta" /> <f:selectItem itemLabel="" itemValue="" /> <f:selectItems value="#{propostaBean.statusProposta}" /> </p:selectOneMenu>
StatusProposta : StatusProposta :
public enum StatusProposta { FIRST,SECOND and THIRD .....公共枚举 StatusProposta { FIRST、SECOND 和 THIRD .....
Bean :豆角,扁豆 :
public void regraStatusProposta(ValueChangeEvent ev){
**I dont know how to set the old value and update it in screen.**
...
public void regraStatusProposta(ValueChangeEvent ev){
//get old value first
Object oldValue=ev.getOldValue();
}
http://forum.primefaces.org/viewtopic.php?f=3&t=36447 http://forum.primefaces.org/viewtopic.php?f=3&t=36447
resetinput 重置输入
blog post: Reset Values for JSF 2.2 博客文章:重置JSF 2.2的值
posted by Howard at primefaces forum 霍华德在primefaces论坛上发布了
http://www.primefaces.org/showcase/ui/resetInput.jsf http://www.primefaces.org/showcase/ui/resetInput.jsf
public void reset() {
RequestContext.getCurrentInstance().reset("form:panel");
}
I've created this utility for PrimeFaces which checks if the component is visible, otherwise it would log a WARN on console.我为 PrimeFaces 创建了这个实用程序,它检查组件是否可见,否则它会在控制台上记录一个 WARN。
public static void resetUIComponents(String... componentsId) {
for (String id : componentsId) {
if (FacesContext.getCurrentInstance().getViewRoot().findComponent(id) != null) {
PrimeFaces.current().resetInputs(id);
}
}
}
So you can use it like this:所以你可以像这样使用它:
ViewUtils.resetUIComponents("form:id1", "form:id2")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.