我有以下 Java Server Faces 2.0 复合组件。注意我正在逐字使用
resources/customer/customer.xhtml
<composite:interface>
<composite:attribute name="id" required="false"/>
<composite:attribute name="firstName" required="false"/>
<composite:attribute name="lastName" required="false"/>
<composite:attribute name="age" required="false"/>
<composite:attribute name="rendered" required="false"/>
</composite:interface>
<composite:implementation>
<f:verbatim id="#{cc.attrs.id}" rendered="#{cc.attrs.rendered}">
<div>
<div>
<p>First name</p>
<h:outputText value="#{cc.attrs.firstName}"/>
</div>
<div>
<p>Last name</p>
<h:outputText value="#{cc.attrs.lastName}"/>
</div>
<div>
<p>Age</p>
<h:outputText value="#{cc.attrs.age}"/>
</div>
</div>
</f:verbatim>
</composite:implementation>
为了使用ajax,我已经完成了(注意渲染属性)
<h:form id="search">
<div>
<h:commandButton value="Search" action="#{customerSearchController.search}">
<f:ajax execute="@form" render="search:result"/>
</h:commandButton>
</div>
<customer:customer id="result"
rendered="#{customerSearchController.customer != null}"
firstName="#{customerSearchController.customer.firstName}"
lastName="#{customerSearchController.customer.lastName}"
age="#{customerSearchController.customer.age}"/>
</h:form>
我的 CustomerSearchController 如下所示
private Customer customer;
// getter's and setter's
public void search() {
customer = new Customer();
customer.setFirstName("First");
customer.setLastName("Last");
customer.setAge(30);
}
CustomerSearchController 和 Customer 都是托管 bean。但是当我调用 ajax 请求时,它会抱怨:search:result not found
我应该怎么做才能解决这个问题???