JSF - 单击另一个组件时取消隐藏 jsf 组件
我正在尝试使用一个按钮来弹出上传对话框。 我试图实现此目的的方式与此类似:
<h:outputText value="Click Me" id="testit">
<a4j:support reRender="hideme" event="onclick" action="#{actions.switchTestRendered}"/>
</h:outputText>
<h:outputText id="hideme" value="back" rendered="#{actions.testRendered}"/>
使用支持 bean 中的代码:
private boolean testRendered = false;
public String switchTestRendered(){
setTestRendered(!isTestRendered());
System.out.println("Current Status:"+isTestRendered());
return "success";
}
public void setTestRendered(boolean testRendered) {
this.testRendered = testRendered;
}
public boolean isTestRendered() {
return testRendered;
}
当我按下“click me”标签时,我可以看到 switchTestRendered 正在运行,但“hideme”组件没有显示。
有什么建议吗? 谢谢!
I'm trying to have a button that brings up an upload dialog.
The way i'm trying to achieve this is similar to this:
<h:outputText value="Click Me" id="testit">
<a4j:support reRender="hideme" event="onclick" action="#{actions.switchTestRendered}"/>
</h:outputText>
<h:outputText id="hideme" value="back" rendered="#{actions.testRendered}"/>
With code in the backing bean:
private boolean testRendered = false;
public String switchTestRendered(){
setTestRendered(!isTestRendered());
System.out.println("Current Status:"+isTestRendered());
return "success";
}
public void setTestRendered(boolean testRendered) {
this.testRendered = testRendered;
}
public boolean isTestRendered() {
return testRendered;
}
When I press the 'click me' label I can see that the switchTestRendered is run but the 'hideme' component does not reveal.
Any suggestions?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
知道了。
我应该重新渲染我试图隐藏/显示的元素的父元素。
换句话说:
应该是:
谢谢!
本.
Got it.
I should have reRendered the parent of the element which I'm trying to hide/show.
In other words:
should be:
Thanks!
Ben.
从代码中只能看出,在“Click me”之后,“隐藏”组件渲染器没有更新。你必须找出原因
From the code it can only be seen that after 'Click me' the 'hide' component renderer is not updating. You have to find out why