Bruce Stemplewski
Bruce Stemplewski

Reputation: 1343

Passing a value of a component from one custom control to the other

I have two custom controls, CustomControlBody and CustomControlTitle.

CustomControlBody has a radio button. CustomControlTitle has a computed field based off of the value of the radio button in CustomControlBody.

If CustomControlTitle is placed within CustomControlBody then the computed field in CustomControlTitle can see the value of the radio button on CustomControlBody just fine.

But for flexibility of design, I want to be able to place CustomControlTitle and CustomControlBody separately on the xPage. But when I do this, CustomControlTitle does not seem to be able to see the radio button in CustomControlBody.

How can I pass the value of the radio button in CustomControlBody to the computed filed in CustomControlTitle?

Upvotes: 1

Views: 1671

Answers (1)

jjtbsomhorst
jjtbsomhorst

Reputation: 1667

You can use the viewscope to set the parameter and on refresh you can read this var. another way would be to create a custom control title and body with a facet (editable area. The you create a third control where you place these controls into and fill the facets with the radiobutton and the text field. Something like (this is not production ready ofcourse it is just to illustrate the above..)

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

Upvotes: 4

Related Questions