Render和visible----------ADF Faces入门(文档阅读)
来源:互联网 发布:不列颠空战知乎 编辑:程序博客网 时间:2024/06/05 18:02
rendered属性有着严格的意义,也可以这么说,这哥特死板。当rendered属性设置为false的时候,在不和服务器交互的情况下,你没有办法在客户端显示这个组件。为了支持动态隐藏以及显示,RCF增加了visible属性(也就是rendered的弟弟,天空一声巨响,小子闪亮登场),当这属性设置为false的时候,在客户端这个组件标记是可用的,只是它不显示出来而已,所以只要调用setVisible(true)或者是setVisible(false) 你就可以让它显示或者是隐藏,前提是它哥哥是true(rendered),这个方法在JS,java中都可以调用。只有当你确切在无和服务器交互的情况下切换组件的可见性,例如在JS中切换,你应该使用visible,设置visible为false。此时,不可见的组件仍然要通过组件的声明周期,包括验证。如果你不需要在客户端切换组件的可见性,你应该选择大哥(rendered)。使用大哥可以提高服务器的性能以及客户端的响应时间,因为这个组件在客户端没有客户端的表现,以及不会通过该组件的声明周期。
大哥(rendered)的例子:
- <af:panelGroupLayoutlayout="horizontal">
- <af:inputTextlabel="Input some text"id="input"
- value="#{myBean.inputValue}"/>
- <af:commandButtontext="Enter"/>
- </af:panelGroupLayout>
- <af:panelGroupLayoutlayout="horizontal">
- <af:outputLabelvalue="You entered:"/>
- <af:outputTextvalue="No text entered"id="output1"
- rendered="#{myBean.inputValue==null}"/>
- <af:outputTextvalue="#{myBean.inputValue}"
- rendered="#{myBean.inputValue !=null}"/>
- </af:panelGroupLayout>
弟弟的例子(visible):
- <af:panelGroupLayoutlayout="horizontal">
- <af:inputTextlabel="Input some text"id="input"
- value="#{myBean.inputValue}"/>
- <af:commandButtontext="Enter"/>
- </af:panelGroupLayout>
- <af:panelGroupLayoutlayout="horizontal">
- <af:outputLabelvalue="You entered:"/>
- <af:outputTextvalue="No text entered"id="output1"
- visible="#{myBean.inputValue==null}"/>
- <af:outputTextvalue="#{myBean.inputValue}"
- visible="#{myBean.inputValue !=null}"/>
- </af:panelGroupLayout>
如何在客户端使用JavaScript操作visible,例子:
- <f:view>
- <af:resource>
- function showText()
- {
- var output1 = AdfUIComponent.findComponent("output1")
- var output2 = AdfUIComponent.findComponent("output2")
- var input = AdfUIComponent.findComponent("input")
- if (input.value == "")
- {
- output1.setVisible(true);
- }
- else
- {
- output2.setVisible(true)
- }
- }
- </af:resource>
- <af:document>
- <af:form>
- <af:panelGroupLayoutlayout="horizontal">
- <af:inputTextlabel="Input some text"id="input"
- value="#{myBean.inputValue}"clientComponent="true"
- immediate="true"/>
- <af:commandButtontext="Enter"clientComponent="true">
- <af:clientListenermethod="showText"type="action"/>
- </af:commandButton>
- </af:panelGroupLayout>
- <af:panelGroupLayoutlayout="horizontal">
- <af:outputLabelvalue="You entered:"clientComponent="false"/>
- <af:outputTextvalue="No text entered"id="output1"
- visible="false"clientComponent="true"/>
- <af:outputTextvalue="#{myBean.inputValue}"id="output2"
- visible="false"clientComponent="true"/>
- </af:panelGroupLayout>
- </af:form>
- </af:document>
- </f:view>
最后小提下,Visible和isShowing函数
如果一个组件的visible属性设置为false,当针对于它的一个子组件的isVisivle函数跑的时候,由于这个自组件是visible是设置为true的,因此这时候返回的是true,但是这个子组件实际上是不显示的。显而易见,这样是不合理的,因此RCF提供了isShowing()这个函数来解决这个问题。
本文转自:http://blog.csdn.net/com_d_d/article/details/6153624
- Render和visible----------ADF Faces入门(文档阅读)
- Render和visible----------ADF Faces入门(文档阅读)
- 优化(optimized)生命周期----ADF Faces入门(文档阅读)
- 监听客户端事件----ADF Faces入门(文档阅读)
- 实例化客户端组件----ADF Faces入门(文档阅读)
- JSF的生命周期--ADF Faces入门(文档阅读)
- 国际化及本地化页面---------ADF Faces入门(文档阅读)
- 关于Immediate属性的使用(注意)----ADF Faces入门(文档阅读)
- 在客户端访问组件属性----ADF Faces入门(文档阅读)
- 在Eclipse中使用ADF Faces和ADF task flow
- JSF, ADF Faces
- ADF FACES 布局
- adf faces 样式设定
- 使用 Ajax、JSF 和 ADF Faces 开发智能 Web UI
- 使用ADF Faces 之一:开发用户界面(基于AJAX)
- ADF FACES 部分页面渲染(PPR)技术
- 使用ADF Faces 之三:创建和使用ADF自定义合成组件
- ADF Faces & MyFaces Tiles Support
- 管理系统前台工作简化
- Eclipse C++ And Win7
- java方法的重载(Overload)与重写(Override)
- drupal安装停在数据库设置这一步的原因
- xp 下建立新的用户后administration用户就会消失的解决办法
- Render和visible----------ADF Faces入门(文档阅读)
- 冒泡排序算法
- Java 静态扫描工具:findbugs eclipse 插件 的介绍、安装、使用
- dedecms自定义字段的添加及如何实现在栏目页首页的调用
- ADF 中加入多个face-config.xml 文件
- .Net Framework下Timer类之对比
- 博客搬家,顺带来些学生时代乱七八糟写的东东
- SQL注入语句 (很全)
- 聚集索引和非聚集索引的区别: