Ryan Buening
Ryan Buening

Reputation: 1660

Combo Box "showReadonlyAsDisabled" Property Not Working

I have a combo box on my XPage with showReadonlyAsDisabled marked true:

<xp:comboBox
    id="ComboTest"
    defaultValue="One"
    showReadonlyAsDisabled="true"
    readonly="true">
    <xp:selectItem
        itemLabel="One"
        itemValue="One">
    </xp:selectItem>
</xp:comboBox>

However, the combo box still displays as read-only (text) and not as the disabled control. Is this a bug? The showReadonlyAsDisabled property appears to work on other controls (input, radio, etc.). I'm using Designer 9.0.1FP4 and the Domino server is on 9.0.1FP5.

EDIT (showing combo box with data binding):

Comobo box in custom control

<xp:comboBox
    id="Address"
    value="#{Location.AddressType}"
    defaultValue="Street Address"
    showReadonlyAsDisabled="true"
    readonly="true">
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:keywords.getSelectItem("Address Type", true);}]]></xp:this.value>
    </xp:selectItems>
</xp:comboBox>

Data binding on parent XPage

    <xp:dominoDocument
        var="Location"
        formName="Location"
        action="editDocument"
        documentId="#{javascript:param.location}">
    </xp:dominoDocument>

Upvotes: 0

Views: 318

Answers (2)

Adrian
Adrian

Reputation: 173

You can add the following XML part to the faces-config.xml of your application.

With this, the renderer for the ComboBox will be set to the default, not read-only renderer. Then, your ComboBox should appear as you want.

<renderer>
    <component-family>javax.faces.SelectOne</component-family>
    <renderer-type>javax.faces.Menu.ReadOnly</renderer-type>
    <renderer-class>com.ibm.xsp.renderkit.html_basic.MenuRenderer</renderer-class>
</renderer>

Upvotes: 0

Lothar Mueller
Lothar Mueller

Reputation: 2538

Seems to be a problem with all kinds of selection controls that are rendered as html tables in read mode (which in my opinion is even more annoying than just this "show disabled in read mode" bug as it makes styling unnecessarily complicated). This however is only happening if the control is bound to a document datasource.

So what you can try is create a second combo box on you page and bind it to a viewScope variable, then make sure the correct value is copied over from the Notes field upon page load, then make sure only one insstance of tyour control is visible in read / edit mode:

For a datasource named Location, and a Notes field AddressType this would be in beforePageLoad:

if(!doc1.isNewNote()){
    viewScope.comboField=Location.getItemValueString("AddressType");
}

This would be the markup for your original / editable comboBox control:

<xp:comboBox id="comboBox1" value="#{Location.AddressType}" rendered="#{javascript:doc1.isEditable()}" defaultValue="Street Address">
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:keywords.getSelectItem("Address Type", true);}]]></xp:this.value>
    </xp:selectItems>
</xp:comboBox>

This would be the markup for your additional / disabled comboBox control:

<xp:comboBox id="comboBox2" value="#{viewScope.AddressType}" disabled="true" rendered="#{javascript:!doc1.isEditable()}">
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:keywords.getSelectItem("Address Type", true);}]]></xp:this.value>
    </xp:selectItems>
</xp:comboBox>

Upvotes: 1

Related Questions