http://yfyang.iteye.com/blog/262041
http://blog.csdn.net/gengv/archive/2009/06/12/4263633.aspx
http://www.vine-server.com/blog/index.php?UID=1234967481
http://www.experts-exchange.com/Programming/Languages/Java/J2EE/Frameworks/JSF/Q_24123308.html
http://codingclues.eu/2008/richfaces-richmodalpanel-with-richcomponentcontrol-does-not-show-data/
Recently I stumbled across a problem with the rich:modalPanel component of the JBoss RichFaces component library, which didn’t want to show the data of a backing been.
Let’s assume the following scenario:
You have a DataTable with several rows. Each row contains a “See details…” button. This button will popup a modal panel using rich:componentControl and the panel is populated with data of a backing bean. This backing bean is filled with actual data by clicking our “See details…” button using a4j:actionparam
Expressed in code, this might look like this:
<rich:column>
<a4j:commandButton value=“See details…” id=“det”>
<rich:componentControl for=“popup”
operation=“show” event=“onclick”
disableDefault=“true”/>
<a4j:actionparam name=“id” assignTo=“#{popupBean.dataId}”
value=“#{rowdata.dataId}”/>
<!– some more actionparams … –>
</a4j:commandButton>
</rich:column>
Well, everything seems fine, doesn’t it? The properties for the bean of the popup are set with a4j:actionparam, the rich:componentControl displays the popup, which then accesses its data.
So let’s test it. Hugh, there is no data in your popup?
There is one thing we missed. The problem is, that the rich:componentControl triggers simple JavaScript code, that is executed before the JSF lifecycle is processed and the bean’s data is set. So your popup is displayed, but at this time, the bean does not have the correct values.
How can we solve this? Well, it’s pretty easy, because we have the reRender attribute on the a4j:commandLink. Simply re-render the fields of your popup, that should hold the actual data. Or embedd them in a a4j:region. This works, because the reRender action is executed after the JSF lifecycle has passed and the values of the bean are now set correctly.
Just one hint at the end: don’t re-render the whole popup, since this way it will be hidden again.
The slightly modified working code:
<rich:column>
<a4j:commandButton value=“See details…” id=“det”
reRender=“popup_dataIdField, …”>
<rich:componentControl for=“popup”
operation=“show” event=“onclick”
disableDefault=“true”/>
<a4j:actionparam name=“id” assignTo=“#{popupBean.dataId}”
value=“#{rowdata.dataId}”/>
<!– some more actionparams … –>
</a4j:commandButton>
</rich:column>
分享到:
相关推荐
在本文中,我们将深入探讨 RichFaces 标签的使用,特别是 `rich:componentControl` 和 `rich:modalPanel` 标签,以及 `inputNumberSlider` 和 `PanelBar` 组件。RichFaces 是一个功能丰富的 JavaServer Faces (JSF) ...
在Java的富客户端框架(RichFaces)中,`rich:componentControl`标签和`rich:modalPanel`标签是两个非常重要的组件,它们用于创建交互式的用户界面。`rich:componentControl`标签允许开发者通过AJAX操作来控制其他组件...
`rich:modalPanel`标签用于创建模态对话框,可以设置宽度、高度等样式属性,并通过`rich:componentControl`控制其显示和隐藏。 **示例代码:** ```xml <rich:modalPanel id="panel" width="350" height="100"> ...
`rich:modalPanel` 标签用于创建一个模态面板,即一个弹出式的窗口,常用于需要用户进行确认或填写信息的场景。 - **属性解析**: - `id`:组件的唯一标识符。 - `width` 和 `height`:设置面板的宽度和高度。 -...
例如,`<rich:calendar>`用于日期选择,`<rich:slider>`用于创建滑动条,`<rich:modalPanel>`则用于创建模态对话框。 2. **Ajax支持**: RichFaces的强项之一是其内置的Ajax功能。它使用A4J(Ajax for JSF)库,...
`<rich:modalPanel>`是RichFaces中的一个弹出对话框组件,可以在页面上显示一个模态窗口,通常用于展示信息、确认操作或收集用户输入。用户可以设置其大小、位置、关闭按钮以及其他交互特性。 4. **组件** `...
5. **rich:modalPanel**:模态窗口组件,用于在当前页面上打开一个半透明的覆盖层,突出显示特定内容。 **三、RichFaces与JSF的集成** JSF是一个标准的MVC框架,而RichFaces作为JSF的扩展,可以无缝集成到JSF应用...
比如,我们可以在相册列表页面使用`<rich:datascroller>`组件实现分页加载,使用`<rich:fileUpload>`组件让用户无需刷新页面即可上传图片,使用`<rich:modalPanel>`展示预览图片的弹窗。 在视图层,我们需要创建JSF...
3. **对话框组件**:`<rich:popupPanel>`允许弹出窗口,`<rich:modalPanel>`则提供了模态对话框功能。 4. **效果组件**:如`<rich:effect>`,使用JavaScript库(如jQuery)实现动画和特效。 五、源码学习与调试 ...