【发布时间】:2013-06-08 04:16:57
【问题描述】:
我阅读了很多关于 f:ajax 与其他 jsf 或 html 标签一起工作的内容,但似乎还不够!
我的页面中有一个带有(必要的?)f:ajax 标记的命令按钮,并且该操作从未触发。这是代码。
<html>
<h:head>
</h:head>
<h:body>
<h:form>
<h:commandButton action="#{bean.myFirstFunction}" value="Submit">
<f:ajax render=":wrap" />
</h:commandButton>
</h:form>
<h:panelGroup id="wrap">
<h:panelGroup id="content" rendered="#{bean.myVariable != null}">
<h:form>
<h:commandButton action="#{bean.mySecondFunction}" value="Submit">
<f:ajax render=":wrap" />
</h:commandButton>
</h:form>
</h:panelGroup>
</panelGroup>
<h:body>
</html>
所以像上面一样,我有两个按钮,第一个外包装工作,它必须显示一开始隐藏的包装面板。第二个已经结束,必须启动一个完全不同的动作。 (包装必须保持显示)
这是豆子。
@ManagedBean(name = "bean")
@ViewScoped
public class myBean {
private Object myVariable;
public void setMyVariable(Object o) { ... }
public Object getMyVariable() { ... }
@PostConstruct
public void init() {
this.myVariable = null;
}
public void myFirstFonction() {
this.myVariable = new Object();
}
public void mySecondAction() {
System.out.println("here");
}
}
当我启动时,我看到了第一个按钮。我点击它,第二个出现。 (所以第一个函数被调用,对象被实例化,并使用 ajax 标记呈现包装。 然而,当第二个按钮被点击时,什么都没有发生。
我只写了一部分代码,希望是这里的错误。
我认为是关于面板组的渲染选项,但我无法准确定位。
谢谢
【问题讨论】:
标签: jsf render commandbutton