我使用的複合材料部件在我的JSF 2.0的項目,我想我的複合材料部件,像這樣結合:複合材料部件
<ex:mycompositecomponent>
<f:ajax event="change" render="anotherComponent" />
</ex:mycompositecomponent>
有沒有辦法做到這一點?
我使用的複合材料部件在我的JSF 2.0的項目,我想我的複合材料部件,像這樣結合:複合材料部件
<ex:mycompositecomponent>
<f:ajax event="change" render="anotherComponent" />
</ex:mycompositecomponent>
有沒有辦法做到這一點?
應該的。
下面的代碼是值得嘗試:
<!-- mycompositecomponent.xhtml -->
...
<composite:implementation>
<h:inputText ...>
<composite:insertChildren /> <!-- contents within <ex:mycompositecomponent>...</ex:mycom....> goes here -->
</h:inputText>
</composite:implementation>
...
現在你mycompositecomponent.xhtml的使用應該工作。
舊線,我知道,但你可以用無證clientBehavior 屬性做到這一點。這個代碼從h的keyup事件映射:inputText的爲邏輯 事件「myevent」。希望這是合理的不言自明的。
的index.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">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:sqcc="http://java.sun.com/jsf/composite/sqcc"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form id="mainform" prependId="false">
<sqcc:testcomp value="#{indexBean.inputText1}">
<f:ajax render=":mainform:echo1"/>
</sqcc:testcomp>
<h:outputText id="echo1" value="a:#{indexBean.inputText1}"/>
<br/>
</h:form>
</h:body>
</html>
testcomp.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:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<cc:interface>
<cc:attribute name="value"/>
<cc:clientBehavior name="myevent" default="true" event="keyup" targets="#{cc.clientId}:ccinput"/>
</cc:interface>
<cc:implementation>
<h:outputLabel for="#{cc.clientId}:ccinput" value="Input: "/>
<h:inputText id="ccinput" value="#{cc.attrs.value}"
autocomplete="off">
<f:ajax event="keyup" render="#{cc.clientId}:ccoutput"/>
</h:inputText>
<h:outputText id="ccoutput" value="cc:#{cc.attrs.value}"/>
</cc:implementation>
</ui:component>
IndexBean.java
package testAjaxCC;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class IndexBean implements Serializable {
private String inputText1;
private String inputText2;
public IndexBean() {
}
public String getInputText1() {
return inputText1;
}
public void setInputText1(String inputText1) {
this.inputText1 = inputText1;
}
public String getInputText2() {
return inputText2;
}
public void setInputText2(String inputText2) {
this.inputText2 = inputText2;
}
}
如果他想多AJAX的處理程序添加到多個地方的複合材料部件內? – 2010-08-18 09:40:19