一种轻松检查元素是否在jsf2中呈现的方法 [英] A way to easily check if an element was rendered in jsf2

查看:196
本文介绍了一种轻松检查元素是否在jsf2中呈现的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应该用来关闭模式面板并渲染多个元素的按钮.

I have a button that is supposed to close a modal panel and render several elements.

是否有一种简单的方法来检查在按下按钮后是否呈现了元素?

Is there an easy way to check if an element was rendered after the button was pressed?

示例按钮:

<a4j:commandButton onclick="#{rich:component('modal')}.hide();"  
    style="background-repeat:no-repeat;width:18px;height:18px;" 
    image="includes/images/close.gif"       
        render=":id1 :id2">
        <f:setPropertyActionListener target="#{Controller.attribute}" value="false" />
</a4j:commandButton>

推荐答案

我还有一个按钮在未渲染的div上不起作用.

提交表单时,必须保留按钮的所有父组件的rendered属性的条件.因此,它不仅应在使用按钮显示表单的请求期间评估true,而且还应在处理表单提交的请求期间评估true.最简单的方法是通过@ViewScoped将支持bean放入视图范围.

The conditon of the rendered attribute of all of the button's parent components must be preserved when you're submitting the form. So it should not only evaluate true during the request of presenting the form with the button, but it should also evaluate true during the request of processing the form submit. Easiest is to put the backing bean in the view scope by @ViewScoped.

此外,如果要重新渲染一个包含<h:form>的组件,则需要将该<h:form>的客户端ID显式添加到render属性.例如.当客户端ID为id1的组件又具有<h:form id="formOfId1">时.

Also, if you're re-rendering a component which in turn contains a <h:form>, you need to explicitly add the client ID of that <h:form> to the render attribute. E.g. when component with client ID id1 has in turn a <h:form id="formOfId1">.

render=":id1 :id2 :formOfId1"

您只需在网络浏览器的开发人员工具集中浏览HTTP流量即可调试所有功能(按Chrome/IE9/Firebug中的F12并选中网络"部分).

You can debug this all by just exploring the HTTP traffic in the webbrowser's developer toolset (press F12 in Chrome/IE9/Firebug and check the "Network" section).

  • commandButton/commandLink/ajax action/listener method not invoked or input value not updated - Points 5 and 7.

这篇关于一种轻松检查元素是否在jsf2中呈现的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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