重新呈现richfaces/jsf组件时,如何维护jQuery/javasscript操纵的DOM的状态? [英] How to maintain state of the DOM manipulated by jQuery/javasscript when reRendering richfaces/jsf components?

查看:77
本文介绍了重新呈现richfaces/jsf组件时,如何维护jQuery/javasscript操纵的DOM的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jsf应用程序中渲染某些组件时遇到问题. 问题是当我在页面上使用jQuery例如隐藏按钮时.页面重新渲染后,该按钮将恢复为原来的形式,该形式本应被隐藏.

I've have problem when it comes to rendering some of my components in my jsf application. The problem is when i use jQuery on my page for example hiding the button. When the page reRenders the button come back to its original form which is supposed to be hidden.

有人在这方面有专门知识可以帮助我找到合适的解决方案吗?或者这里有些原则或技术被我盲目地误解了?

Has someone has expertise on this matter that will be able to help me find a suitable solution or there is some principles here or techniques which was i blindly misunderstood?

谢谢. :)

推荐答案

问题是当我在页面上使用jQuery例如隐藏按钮时.页面重新渲染后,按钮将恢复为原来的形式,应该被隐藏.

不要使用jQuery来操纵DOM,而应使用JSF Ajax来操纵DOM.

Don't use jQuery to manipulate the DOM, but use JSF Ajax instead to manipulate the DOM.

例如

<h:form>
    <h:selectBooleanCheckbox value="#{bean.checked}">
        <f:ajax render="buttons" />
    </h:selectBooleanCheckbox>

    <h:panelGroup id="buttons">
        <h:commandButton value="Submit" rendered="#{bean.checked}" />
    </h:panelGroup>
</h:form>

另请参见:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆