Jsf 自定义组件id部分处理的奇怪行为
我想扩展Jsf 自定义组件id部分处理的奇怪行为,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我想扩展p:inputExtArea的功能。新组件很简单,看起来像: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:p="http://primefaces.org/ui" xmlns:h = "http://java.sun.com/jsf/html"> <composite:interface>
p:inputExtArea
的功能。新组件很简单,看起来像:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
xmlns:h = "http://java.sun.com/jsf/html">
<composite:interface>
...
<composite:attribute name="maxlength" required="false" default="0"/>
<composite:attribute name="value" required="true"/>
...
</composite:interface>
<composite:implementation>
<p:inputTextarea id="#{cc.clientId}"
value="#{cc.attrs.value}"
onkeyup="callJS('#{cc.clientId}', '#{cc.attrs.maxlength}')"/> <!-- This is why i extend p:inputTextarea -->
</composite:implementation>
</html>
testBean
isPOJO
@ManagedBean(name = "testBean")
@ViewScoped
public class TestBean implements Serializable {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
当我单击p:commandButton[id=button]
时,我希望具有[id=textarea]
的组件将从具有[id=text]
的组件获得值但我得到了服务器的响应
<update id="tabs:textarea"><![CDATA[<label id="tabs:textarea"></label>]]></update>
]>
如果不使用实践:inputExtArea
编写p:inputExtArea
所有操作均按预期进行。如果放置
实践:inputTextarea
从p:tabView
中取出,也可以按预期工作
当自定义组件位于
p:tabView
中时,practice:InputExtArea
的值为何未被处理?我将复合组件包装到div
中。现在一切都好了
复合组件现在看起来像
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
xmlns:h = "http://java.sun.com/jsf/html">
<composite:interface>
...
<composite:attribute name="maxlength" required="false" default="0"/>
<composite:attribute name="value" required="true"/>
...
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<p:inputTextarea id="innerId"
value="#{cc.attrs.value}"
onkeyup="callJS('#{cc.clientId}:innerId', '#{cc.attrs.maxlength}')"/>
</div>
</composite:implementation>
</html>
...
...
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
xmlns:h = "http://java.sun.com/jsf/html">
<composite:interface>
...
<composite:attribute name="maxlength" required="false" default="0"/>
<composite:attribute name="value" required="true"/>
...
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<p:inputTextarea id="innerId"
value="#{cc.attrs.value}"
onkeyup="callJS('#{cc.clientId}:innerId', '#{cc.attrs.maxlength}')"/>
</div>
</composite:implementation>
</html>