2012-03-14 3 views
1

두 개의 사용자 지정 컨트롤, CustomControlBody 및 CustomControlTitle이 있습니다.한 사용자 지정 컨트롤에서 다른 사용자 지정 컨트롤로 값 전달

CustomControlBody에는 라디오 버튼이 있습니다. CustomControlTitle에는 CustomControlBody의 라디오 버튼 값을 기반으로 계산 된 필드가 있습니다.

CustomControlTitle이 CustomControlBody 내에 있으면 CustomControlTitle의 계산 된 필드에서 CustomControlBody의 라디오 버튼 값을 확인할 수 있습니다.

하지만 디자인의 유연성을 위해 CustomControlTitle과 CustomControlBody를 xPage에 별도로 배치 할 수 있기를 원합니다. 하지만 이렇게하면 CustomControlTitle이 CustomControlBody의 라디오 버튼을 볼 수없는 것 같습니다.

어떻게 CustomControlBody의 라디오 버튼 값을 CustomControlTitle의 계산 된 값으로 전달할 수 있습니까?

답변

4

뷰포트를 사용하여 매개 변수를 설정할 수 있으며 새로 고침하면이 var를 읽을 수 있습니다. 또 다른 방법은 패싯 (편집 가능한 영역)이있는 사용자 정의 컨트롤 제목과 본문을 만드는 것입니다.이 컨트롤을 배치하고 라디오 버튼과 텍스트 필드를 사용하여 패싯을 채우는 세 번째 컨트롤을 만듭니다. (this is is 그것은 당연히 준비가되지 않은 제품은 위의 설명입니다 ..)

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" 
    xmlns:xc="http://www.ibm.com/xsp/custom" 
    xmlns:xe="http://www.ibm.com/xsp/coreex"> 

    <xp:this.data> 
     <xp:dominoDocument var="yourdocument" action="editDocument" 
      documentId="#{javascript:return compositeData.DocumentUniqueID;}" 
      computeWithForm="save" formName="yourdocument"> 
     </xp:dominoDocument> 
    </xp:this.data> 


    <xp:panel> 

    <xc:Title> 
     <xp:textxp:key="field" value="#{javascript: rb = getComponent("radiobutton"); return cb.getValue();}"/> 
    </xc:Title> 
    <xc:Body> 

    <xp:radioGroup id="radioGroup1" xp:key="fields"> 
     <xp:eventHandler event="onchange" submit="true" 
      refreshMode="partial" refreshId="titleControl"> 
      <xp:this.action><![CDATA[#{javascript:viewScope.value = this.getValue();}]]></xp:this.action> 
     </xp:eventHandler></xp:radioGroup> 
    </xc:Body> 

</xp:panel> 

</xp:view> 
+0

이 감사합니다. viewScope 갈 방법이처럼 내가 그 생각하지 않았는지. 내가 모르는 소리. :) 당신이 할 수있는 사용자 지정 컨트롤의 속성을 설정합니다. 동적으로 값을 가져올 수 있으면 좋을 것입니다. –

+7

브루스, 사용자 지정 컨트롤에 전달 된 속성은 속성 맵에 저장됩니다. CC에 ID가있는 한 전달 된 모든 속성에 액세스 할 수 있어야합니다. getComponent ("customControlId"). getPropertyMap(). get ("propertyName") –

+5

속성 값의 toString이 올 경우 다시 ValueBindingImpl (예 : [email protected])에 대한 참조로, 속성이 동적으로 결정된다는 것을 의미하므로 값을 얻으려면 약간 더 복잡한 표현식이 필요합니다. getComponent ("customControlId"). getPropertyMap(). get ("propertyName"). getValue (facesContext) –

관련 문제