2013-10-07 1 views
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에서이 구성 요소를 사용합니다 : 같은 새로운 구성 요소를 간단하고 보이는 내가 p:commandButton [id=button]을 클릭하면 내가 기대

<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> 

testBeanPOJO

@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; 
    } 
} 

입니다 [id = textarea]와 어떤 구성 요소 [id = text]으로 구성 요소로부터 가치를 얻습니다.
그러나 대신 practice:inputTextarea 예상대로 작동 p:inputTextarea을 모두 작성하는 경우 난 서버

에서 응답
<update id="tabs:textarea"><![CDATA[<label id="tabs:textarea"></label>]]></update> 

를 받고.
practice:inputTextarea의 위치가 p:tabView 인 경우 예상대로 작동합니다.

practice:inputTextarea의 값이 사용자 정의 구성 요소가 p:tabView에있을 때 왜 처리되지 않습니까?

답변

0

복합 컴포넌트를 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> 
처럼 지금 보이는
관련 문제