个性化阅读
专注于IT技术分析

RichFaces a4j:outputPanel组件示例

点击下载

该组件用于将组件分组在一起以整体进行更新, 而不是单独指定组件。

使用复杂的Ajax渲染时, 我们可以使用<a4j:outputPanel>组件包装行为。它已正确编码, 以确保正确呈现包装的组件。


例子

在下面的示例中, 我们正在实现<a4j:outputPanel>组件。本示例包含以下文件。

JSF文件

// ajax-output-panel.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<f:view>
<h:head>
<title>Output Panel</title>
</h:head>
<h:body>
<h:form>
<h:outputText style="font-weight: bold;" value="Enter Text: "/>
<h:inputText label="text2" value="#{user.name}">
<a4j:ajax event="keyup" render="user-name"/>
</h:inputText>
</h:form><br/>
<a4j:outputPanel layout="block" id="user-name">
<h:outputText  value=" #{user.name}"></h:outputText>
</a4j:outputPanel>
</h:body>
</f:view>
</ui:composition>

托管豆

// User.java

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

输出

RichFaces A4j outputPanel1

赞(0)
未经允许不得转载:srcmini » RichFaces a4j:outputPanel组件示例

评论 抢沙发

评论前必须登录!