Robert
Robert

Reputation: 123

Whats Wrong With My @DbColumn?

For some reason, I can't get my code to pull up the view I'm calling. Even worse, I'm not getting any type of error message on my XPage, the combo box is just blank when I click on it.

I'm trying to pull a list of departments. The View named (DepartmentLookup) actually contains about 135 entries. I want the second column, which contains the department name. Here is my computed values code: @DbColumn(["DomApps01/Hendricks", "aApplications/HCHPhoneBk.nsf"], "(DepartmentLookup)", 2)

My xsp source code for the combo box is here:

<xp:comboBox
    id="department"
    value="#{document1.department}"
    style="width:180px"
    rendered="#{javascript:document1.isEditable()}">
    <xp:this.validators>
        <xp:validateExpression
            message="You must select a Department">
            <xp:this.expression><![CDATA[#{javascript:value != "Select One"}]]></xp:this.expression>
        </xp:validateExpression>
    </xp:this.validators>
    <xp:selectItem
        itemLabel="Select One"
        itemValue="Select One"
        id="selectItem1">
    </xp:selectItem>
    <xp:selectItems
        id="selectItems1">
        <xp:this.value><![CDATA[#{javascript:
            @DbColumn(["DomApps01/Hendricks", "aApplications/HCHPhoneBk.nsf"], "(DepartmentLookup)", 2)
            }]]></xp:this.value>
    </xp:selectItems>
</xp:comboBox>

Upvotes: 1

Views: 469

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

Use this code to get an error string result if database or view isn't available:

    <xp:selectItems
        id="selectItems1">
        <xp:this.value><![CDATA[#{javascript:
                var db = session.getDatabase("DomApps01/Hendricks", "aApplications/HCHPhoneBk.nsf");
                if (!db.isOpen()) {
                    return "Error reading database";
                }
                var result = @DbColumn(db, "(DepartmentLookup)", 2);
                if (typeof result === 'undefined') {
                    return "Error reading view";
                }
                result
            }]]></xp:this.value>
    </xp:selectItems>

In my tests @DbColumn returns nothing if it fails - no Exception gets thrown (so, try-catch-block doesn't help). That's why you don't get an error message.

As an alternative you could use a Java version of DbLookup & DbColumn, with cache, sort and unique and without 64K limit.

Upvotes: 1

Related Questions