user1358852
user1358852

Reputation:

XPages - use a variable in a lookup for an xe:simpleValuePicker

I am using two fields associated with xe:simplevaluePicker on an XPage and would like the @DbLookup formula for the second field to incorporate the value of the first field as a key. How can I best do this? At the moment, the xe:simpleValuePicker gives an "Type:Error: resp is null"

My code at the moment is:

<xp:inputText id="Function" value="#{document1.Function}"     styleClass="EditBoxWidth"     required="true">

<xp:eventHandler event="onchange" submit="false" refreshMode="partial"    refreshId="valuePickerMT"></xp:eventHandler>
</xp:inputText>

<xe:valuePicker id="valuePicker" for="Function" dialogTitle="SELECT">
<xe:this.dataProvider>
<xe:dominoViewValuePicker databaseName="#{javascript:@Subset(@DbName(),-1)}"    labelColumn="FunctionName">
<xe:this.viewName><![CDATA[#{javascript:var viewname = "$L-Function-WEB"; viewname}]]>     </xe:this.viewName>
</xe:dominoViewValuePicker>
</xe:this.dataProvider>
</xe:valuePicker>           

<xp:inputText id="MainTasks" value="#{document1.MainTasks}"
required="true" styleClass="EditBoxWidth">
</xp:inputText>

<xe:valuePicker id="valuePickerMT" for="MainTasks" dialogTitle="SELECT">

<xe:this.dataProvider>
<xe:simpleValuePicker>

<xe:this.valueList><![CDATA[#{javascript:var viewname = "$L-Function-WEB";
var key = getComponent("Function").getValue();
var results = @DbLookup(@DbName(),viewname,key,3);
results}]]></xe:this.valueList>
</xe:simpleValuePicker>
</xe:this.dataProvider>
xe:valuePicker>
</xp:span>

Upvotes: 0

Views: 393

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15729

document1.getItemValueString("MyFieldName") will get the value, if document1 is the name of the relevant datasource. Of course, if you're wanting to refresh the (server-side generated) values based upon a value from the first field that the user has entered in the (client-side) browser, you'll need to trigger a partial refresh after the first field is updated.

Upvotes: 3

Related Questions