I suspect this is a silly question, but here goes...

I have two fields on a custom control, both are bound to managed bean properties (as opposed to document fields). The second field is only rendered when a specific value is chosen in the first field.

What I am seeing is that the setter for the second field is not firing after it has been rendered (the getter is firing just fine).

I have worked around the problem by computing the CSS display property on the second field to be block or none depending on the value in the first field. Everything works fine in this situation, it seems to be specifically related to whether the second field is rendered when the page is first loaded.

***Edit Here's the sample code block:

    <div class="control-group">
    <xp:label value="Party Type:" id="partytypelabel" for="party_typetv">
    </xp:label>
    <div class="controls">
        <xp:comboBox id="party_typetv" value="#{InvolvedRecord.partytypetv}"
            required="true" defaultValue=""
            readonly="#{javascript:!InvolvedManager.isInEditMode()}">
            <xp:selectItem itemLabel="&lt;select&gt;" itemValue="">
            </xp:selectItem>
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:InvolvedManager.getPartyTypes()}]]></xp:this.value>
            </xp:selectItems>
            <xp:eventHandler event="onchange" submit="true"
                refreshMode="partial" disableValidators="true" refreshId="partyfields">
            </xp:eventHandler>
        </xp:comboBox>
    </div>
</div>
<xp:panel id="partyfields" tagName="fieldset">
    <xp:this.rendered><![CDATA[#{javascript:InvolvedManager.hasPartyType()}]]></xp:this.rendered>
    <xp:div styleClass="control-group">
        <xp:label for="Adverse_Party_TypeTL" value="Type:" id="adversepartytypelabel">
        </xp:label>
        <div class="controls">
            <span>
                <xp:comboBox id="Adverse_Party_TypeTL"
                    value="#{InvolvedRecord.adversepartytypetl}" readonly="#{javascript:!InvolvedManager.isInEditMode()}">
                    <xp:selectItem itemLabel="&lt;select&gt;"
                        itemValue="">
                    </xp:selectItem>
                    <xp:selectItem itemLabel="Company" itemValue="Company">
                    </xp:selectItem>
                    <xp:selectItem itemLabel="Individual" itemValue="Individual">
                    </xp:selectItem>
                    <xp:eventHandler event="onchange" submit="true"
                        refreshMode="partial" disableValidators="true" refreshId="adversepartyfields">
                    </xp:eventHandler>
                </xp:comboBox>
            </span>
        </div>
    </xp:div>
</xp:panel>

***End Edit

This is running on an 8.5.3 server.

Has anyone seen anything like this or maybe offer an explanation as I am confused!

有帮助吗?

解决方案

You could render the component in all phases except the renderphase. This would allow to set the value during update phase, but would hide it to the client.

Here is an example: Conditionally hidden edit box in a partially refreshed panel

EDIT:

<xp:this.rendered>
   <![CDATA[#{javascript:
      if( view.isRenderingPhase() ){
         return InvolvedManager.hasPartyType();
      }else{
         return true;
      }
   }]]>
</xp:this.rendered>

其他提示

Are you actually entering data into these fields after they have been rendered? I have found on many occasions that a field specifically bound to a managed bean does not actually even do anything unless some data has been entered into it. For instance, I have seen this: render the field dynamically, don't do anything to it, save the data source, no field whatsoever on the document. If I do that same activity but add data to the field, then it all works. Not an answer. Just some info.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top