0

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;
Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29

2 Answers2

1

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

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • so appreciate for your suggestion – user1533484 Jul 18 '12 at 06:41
  • now I change my code as follow, but still work good on local but return nothing on server Keep trying now~ thank you !! :) var fd_AppChoice:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("fd_AppChoice"); var appChoice = @Trim(fd_AppChoice.getValue()); var server = @DbName(); var result = @DbLookup(server,"(A)",appChoice,2); return result – user1533484 Jul 18 '12 at 06:45
  • I had no idea you could do this -- return result || ["Sorry nothing here"] – RoyRumaner Jul 18 '12 at 13:20
  • @rrumaner Listen to the "Don't be afraid of curly brackets" recording :-) #TLCC – stwissel Jul 18 '12 at 17:25
  • @stwissel sorry~those solution still can't work, any further suggestion? thank you :) – user1533484 Jul 19 '12 at 04:00
  • Check your code carefully and check your logs. @DbLookup is reliable. Use Print to print all variables to the log. Make sure that the server name resolves properly. – stwissel Jul 19 '12 at 12:16
1

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>
Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29
  • local side good~but bad on web server combobox B keep show nothing~ – user1533484 Jul 18 '12 at 10:51
  • value="#{document1.fd_AppChoice}" style="margin-left:0.0%" disableClientSideValidation="true"> <![CDATA[pls enter apply job[applied job]]]> <![CDATA[#{javascript: @Trim(@Unique(@DbColumn("","(A)",1)))}]]> – user1533484 Jul 18 '12 at 10:52
  • <![CDATA[pls enter[work site]]]> <![CDATA[#{javascript: var appChoice = @Trim(getComponent("fd_AppChoice").getValue()); var server = @DbName(); var result = @DbLookup(server,"(A)",appChoice ,2); return result }]]> – user1533484 Jul 18 '12 at 10:53
  • plus~ even though I put the exist value in the @Dblookup like: var server = @DbName(); // if different server or nsf have = ["myserver","mydb.nsf"] or [@DbName()[0],"my.nsf"] var result = @DbLookup(server,"(A)","programmer",2); return result }]]> it's can't return anything on web server either, but still good on localside – user1533484 Jul 18 '12 at 10:59