user1533484
user1533484

Reputation: 9

Xpages @Dblookup does not work on server

I write a xpages.

detail: There are two combobox A,B. I use @Dbcolumn on combobox A to get option data from notesview and I will throw the choice I get from A to get second data for B.

the problem is: it work well on my localserver, but get no result on the server.

I'll be very appreciate for any suggestion, thanks you!!

code is on server side as follow:

var fd_AppChoice:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("fd_AppChoice");
var AppChoice=@Trim(fd_AppChoice.getValue());
var temp=new Array();
temp=@DbLookup("","(A)",AppChoice,2);

return temp;

Upvotes: 0

Views: 1618

Answers (2)

Lothar Mueller
Lothar Mueller

Reputation: 2528

I can't quite confirm this: in my case it works like a charm on my test server (didn't even try locally). Here's my code:

comboBox #1 reads its values from a categorized view of the same database:

<xp:comboBox id="comboBox1" value="#{viewScope.combo1}">
    <xp:selectItems>
        <xp:this.value>
<![CDATA[#{javascript:@DbColumn(@DbName(), "myView", 1);}]]>
        </xp:this.value>
    </xp:selectItems>
    <xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="panelC2">
    </xp:eventHandler>
</xp:comboBox>

Observe that the combo's onchange event performs a partial update on a panel which is a container for comboBox #2 (could it be that this is missing in your case?)

To get through with this, here's the remainder: combo#2 gets its values array using a @DbLookup which is filtered by the value selected in combo#1, which now is stored in a viewScope variable (how couldn't I agree with Stephan here: using a scope-var make things much easier!):

<xp:panel id="panelC2">
    <xp:comboBox id="comboBox2" value="#{viewScope.combo2}">
        <xp:selectItems>
            <xp:this.value>
<![CDATA[#{javascript:@DbLookup(@DbName(), "myView", viewScope.combo1, 5);}]]>
            </xp:this.value>
        </xp:selectItems>
    </xp:comboBox>
</xp:panel>

Upvotes: 1

stwissel
stwissel

Reputation: 20384

That code doesn't look right - you don't have the server. And defining a variable doesn't fix its data type, so var temp=new Array(); is irrelevant. I also would rather bind the fd_AppChoice to a scope variable e.g. viewScope.appChoice, then your code get easier. Try this:

 var appChoice = @Trim(viewScope.appChoice); // Use getComponent.getValue if you have to
 var server = @DbName();
 // if different server or nsf have = ["myserver","mydb.nsf"] or [@DbName()[0],"my.nsf"]
 var result = @DbLookup(server,"(A)",appChoice,2);

 return result || ["Sorry nothing here"]

That should work

Upvotes: 1

Related Questions