【问题标题】:Hiding an a4j:outputPanel and showing it on submit a4j command button隐藏 a4j:outputPanel 并在提交 a4j 命令按钮上显示它
【发布时间】:2010-07-04 13:57:16
【问题描述】:
从现在开始,我有这个:
.....
<a4j:commandButton action="#{ChoixContratBean.Submit1}" reRender="suite" value="valider" > </a4j:commandButton>
</a4j:outputPanel>
<a4j:outputPanel display="none" id="suite">
<jsf:outputText id="reponseeFormule"............
有效。套件面板被重新渲染。但我想隐藏这个名为套件的输出面板。并在用户通过 commandButton 验证后显示它...我不知道该怎么做,有人有想法吗?
谢谢!
【问题讨论】:
标签:
ajax
jsf
richfaces
ajax4jsf
【解决方案1】:
好吧,我终于在几个小时后发现了。 (经过几个小时的搜索,我发布了这个问题,我是 Richfaces 的初学者)
这不是很复杂,但是有一个你不想掉进去的小陷阱。最终的代码是这样的:
......<a4j:outputPanel id="check">
<richfaces:panel rendered="#{ChoixContratBean.essaiValid}">
<jsf:outputText value="#{ChoixContratBean.check}" /></richfaces:panel>
</a4j:outputPanel>
</td>
</tr>
</table>
</richfaces:simpleTogglePanel>
<a4j:commandButton action="#{ChoixContratBean.Submit1}" reRender="suite, check" value="valider"> </a4j:commandButton>
<a4j:outputPanel id="suite" >
<richfaces:simpleTogglePanel rendered="#{ChoixContratBean.suite}" switchType="ajax"......
首先必须将 outputPanel 渲染为 true,否则 ajax 将不会触及它。那是我的第一个错误,我想我可以制作一个 outputPanel 渲染 =“#{ChoixContrat.someBool},并在链接到命令按钮的 ajax 操作中更改它。但是不,如果它首先设置为 render = false,ajax 将不会”无法将其更改为 true,因为它一开始就无法访问!您必须在组件中的 back bean 中设置 render=some boolean,该组件包含您要隐藏的内容,并且在 outputPanel id= 套件中为以我的例子为例。这样,outputPanel 总是被渲染,但是无论你的 contrainer 的属性在后面设置为 false 还是 true,在 ajax 方法中,其中的组件都将保持隐藏或可见..
希望我很清楚,因为我是法国人.....