我是JavaServer Faces的新手。 我有一个简单的形式:
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title">#{msgs.leavereply}</h3>
<h1>#{!forumsBean.activeWithProject}</h1>
<h:form>
<h:inputTextarea value="#{forumpostsBean.text}" style="resize:none"/>
<h:commandButton value="#{msgs.add}" action="#{forumpostsBean.addForumpost}"/>
</h:form>
</div>
单击命令按钮,一切正常,执行方法forumpostsBean.addForumpost。
但是当我修改代码时:
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title">#{msgs.leavereply}</h3>
<h1>#{!forumsBean.activeWithProject}</h1>
<h:form>
<h:inputTextarea value="#{forumpostsBean.text}" style="resize:none" disabled="#{not forumsBean.active}"/>
<h:commandButton value="#{msgs.add}" action="#{forumpostsBean.addForumpost}" disabled="#{not forumsBean.active}"/>
</h:form>
</div>
如果未禁用项目,则只刷新当前页面,但不执行forumpostsBean.addForumpost方法。
在两种变体中,<h1>#{!forumsBean.activeWithProject}</h1>
都显示正确的值。
答案 0 :(得分:0)
您可能想要使用render =&#34;&#34;在按钮而不是只是禁用它所以它在页面加载时根本不是dom的一部分,然后当你在输入字段中键入数据时使用ajax调用来做部分ajax再次渲染div并显示它。适合测试。