0
我想擴展p:inputTextArea
的功能。新組件簡單的,看起來像:部分處理自定義組件ID的奇怪行爲
<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>
我用在p:TabView
這個組件:
<h:form prependId="false">
<p:tabView id="tabs">
<p:tab id="tab1" title="text1">
<h:outputLabel disabled="true" id="textarea" value="#{testBean.text}"/>
</p:tab>
<p:tab title="text2">
<p:commandLink value="Show dialog" onclick="inputDilog.show();"/>
<p:dialog widgetVar="inputDilog" id="dialog">
<!-- custom component -->
<practice:inputTextarea id="text" value="#{testBean.text}" maxlength="100"/>
<f:facet name="footer">
<p:commandButton id="button" title="Save text"
update="textarea"
process="text"
oncomplete="inputDilog.hide();"/>
</f:facet>
</p:dialog>
</p:tab>
</p:tabView>
</h:form>
testBean
是POJO
@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>
如果不是practice:inputTextarea
寫p:inputTextarea
所有工作的期望。
如果practice:inputTextarea
從p:tabView
出來也按預期工作。
當自定義組件位於p:tabView
時,爲什麼practice:inputTextarea
的值不被處理?