RichFaces 四种客户端函数

添加评论 63 views 2010年5月30日

RichFaces融合了Jquery脚本技术,对页面进行封装成各种各样的组件,这些组件完全不比当前流行的各种其他富客户端的界面差而且还优越于他们。RichFaces提供了四种客户端的Javascript函数,分别为一下几种:

  1. #{rich:clientId(‘id’)}
  2. #{rich:element(‘id’)}
  3. #{rich:component(‘id’)}
  4. #{rich:findComponent(‘id’)}

* rich:clientId(‘id’) – returns client id by short id or null if the component with the id specified hasn’t been found
* rich:element(‘id’) – is a shortcut for document.getElementById(#{rich:clientId(‘id’)})
* rich:component(‘id’) – is a shortcut for #{rich:clientId(‘id’)}.component
* rich:findComponent(‘id’) – returns an instance of UIComponent taking the short ID of the component as a parameter.

假设你有个jsf页面如下:

<h:form id="form">
   <rich:calendar popup="true" id="calendar"/>
</h:form>

则考虑以下四种情况:
1.#{rich:clientId(‘calendar’)}将会返回该结果:“form:calendar”

2.#{rich:element(‘calendar’)}该函数等同于:document.getElementById(‘form:calendar’)

3.#{rich:component(‘calendar’)}将会在rich components上调用Javascript api:

document.getElementById(‘form:calendar’).component

4.#{rich:findComponent(‘id’)}是一个Javascript函数,可以用来测试或原型没有绑定已管理的javabean的组件。

例如:

<h:inputText id="input">
  <a4j:support event="onkeyup" reRender="output" />
</h:inputText>
<a4j:outputPanel id="output">
   #{rich:findComponent('input').value}
</a4j:outputPanel>

h:inputText标签里没有值绑定了受管理的javabean,这意味着该组件的值不回保存到该model中。
a4j:support 用于发送一个请求,当键盘按起的时候并且会渲染到‘output’组件。

  1. 还没有评论.想坐沙发?
  1. 还没有 trackbacks
订阅评论