我使用的复合材料部件在我的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