Hi,
I am testing the new xPages and they are great 
However I can!t get a simple combobox with “Refresh choices on document refresh” to work.
On my form (xPage with a data source “Document” called “Doc1”) i have two comboboxes.
The first one (“ProjectName”) gets its values from the following formula “@DbColumn(”“,“Projects”,1);”. And this works !
The second on should offer different values based on the selection of the previous combobox.
It has this formula: “@DbLookup(”“,“Projects”,Doc1.getItemValueString(“ProjectName”),2);”
The first combobox has the onChange-Event set to perform a “Partial Update” on the second combobox. (I also tried a full update with same result.)
But my second combobox is always empty. 
If I do the Lookup with a hard-coded key value, then it works. So its not a problem with the view or the Lookup syntax. Rather the code “Doc1.getItemValueString(“ProjectName”)” seems not to return the current value from the first field.
Is this approach wrong ?
If I try to put the code “Doc1.getItemValueString(“ProjectName”)” into a computed field, it does not display the value correctly. Do i have to save the document first ?
I am using only server-side scripts, does this have to be done with “client side” code ?
Thank you for any help.
Or could you point me to a working example somewhere ?
Bye Lars
Subject: Designer bug (PHAN7QWBL8) logged, though there is a workaround…
The script editor dialog doesn’t allow you to computed the formula dynamically but only on page load
This is not correct
You should be allow to set the condition yourself as in…
WORKAROUND
Go to the Source pane for this control and replace in the source the ‘$’ with ‘#’
<xp:comboBox id="comboBox1" value="#{document1.City}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var key = document1.getItemValueString("Country")
@DbLookup(“”,“ByCountry”,key,2)}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Subject: It works !! But more info…
Hi,
thank you Paul for examining my code and finding the problem. It is working now !
However i found some more problems which might be of use for someone else:
- the OnChange-Event of the first combobox triggers a “Full Update” which refreshes the values in the second combobox.
But if “No data validation” is checked, then this does not work!(The page refreshes, but the second combobox is empty.)
If only works if this this checkbox is unchecked.
-If i set a “Partial Update” for the second combobox on the same event, then i get the following error message:
"Problem submitting an area of the page.
Unable to load http://server/Projects/Project.nsf/Ticket.xsp?$$ajaxmode=axfull&$$ajaxid=view:_id1:_id2:Component status:500
Submit the entire page?"
If i submit the page, then it starts working and every time i change the value in the first combobox the partial update works and updates only the second item.
! If i do a partial update it still works only if the “No data validation” box is unchecked.
If anyone finds a solution please respond.
Otherwise I can live with the current state 
(event the best way would be a Partial-Update without “data validation”)
Lars
Subject: Here how to work with this…
With 'No Data Validation' set your effectively turning the action into a cancel action and you can no longer submit data.
When you want to use no data validation and change combo boxes dynamically we go to use the submitted values rather than the values already there in the data as these get disregarded when a cancel action happens. So we might use something like the following...
<xp:this.data>
<xp:dominoDocument var="document1" formName="formSelectCity"></xp:dominoDocument>
</xp:this.data>
<xp:table>
<xp:tr>
<xp:td valign="top" id="docCell1">
<xp:button value="Submit" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="false" save="true">
</xp:eventHandler>
</xp:button>
<xp:button value="Cancel" id="button3">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="true" save="false">
</xp:eventHandler>
</xp:button>
<xp:button value="Edit" id="button4"
rendered="#{javascript:!document1.isEditable()}">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:changeDocumentMode mode="edit"></xp:changeDocumentMode>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:text escape="true" id="computedField1" value="#{javascript:@Unique()}"
style="color:rgb(0,128,0);font-weight:bold"></xp:text>
<xp:br></xp:br>
<xp:label id="label1" value="Subject: "></xp:label>
<xp:inputText id="inputText1" value="#{document1.Subject}"
required="true" style="width:200px">
</xp:inputText>
<xp:table id="refreshtable">
<xp:tr>
<xp:td>
<xp:label value="Select a Country: " id="label2">
</xp:label>
</xp:td>
<xp:td>
<xp:comboBox id="comboBox1" value="#{document1.selectCountry}">
<xp:selectItem itemValue="" itemLabel="Please select">
</xp:selectItem>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="refreshComboBox" immediate="true">
</xp:eventHandler>
<xp:selectItems>
<xp:this.value><![CDATA[${javascript:@Unique(@DbColumn(@DbName(),"viewList",1))}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:td>
</xp:tr>
<xp:tr id="refreshRow">
<xp:td valign="top">
<xp:label value="Select a City: " id="label3">
</xp:label>
<xp:br></xp:br>
<xp:text escape="true" id="computedField2" value="#{javascript:@Unique()}"
style="color:rgb(0,64,0);font-weight:bold">
</xp:text>
<xp:br></xp:br>
<xp:text escape="true" id="computedField3" style="color:rgb(64,128,128)">
<xp:this.value><![CDATA[#{javascript:document1.getItemValueString("selectCountry")}]]></xp:this.value>
</xp:text>
</xp:td>
<xp:td valign="top">
<xp:comboBox id="refreshComboBox" value="#{document1.selectCity}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var ctry = document1.getItemValueString("selectCountry");
var lst1 = @DbLookup(@DbName(),“viewList”,“ctry”,2);
//@Explode(lst1,“,”)
var combo1 = getComponent(‘comboBox1’);
// value submitted from the browser
var value = combo1.getSubmittedValue();
if( null == value ){
// else not yet submitted
value = combo1.getValue();
}
return @DbLookup(@DbName(),“viewList”,value,2)
}]]>
</xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:td>
</xp:tr>
</xp:table>
</xp:td>
</xp:tr>
</xp:table>
Hope this helps.
Subject: Thanks a lot. It works 
Hi,
thanks again for your example. It works and does exactly what i wanted.
But as always i encountered an other tiny problem:
I would like to do the “Partial refresh” not for one field, but for two. In the “Select Element To Update”-dialog is says “Select one or more elements from the page …”, but a multiple-selection is impossible.
So i looked at the code and the element id is written to the “refreshId”-Attribute. Then i tried to insert two elementIDs separated by comma, space, semicolon … but nothing worked.
Do you know if it is possible to select multiple elements for a partial update ?
Bye
Lars
PS: I found out that i could update a whole panel with all the fields in it, but unfortunatelly my two fields are not even near each other.
Subject: Found the answer to he last question …
Hi,
just for your information i found the answer that a partial update can be done only on one element:
http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/7A295C44E1FD181985257583006B4A6B?opendocument&login

Bye
Lars
Subject: Sounds like you’re doing alot of things right
Though you might be missing a small part so try things again 1. without partial refresh - make sure that app works that you can do a full update in the first place;
-
use a var for ‘Doc1.getItemValueString(“ProjectName”)’ and use that var in the lookup - @DbLookup(“”,“Projects”,varName,2);
-
have a look over this wiki article - http://www-10.lotus.com/ldd/ddwiki.nsf/dx/02102008091536PHABPL.htm - and see if you can pick up something else you might be missing.
Subject: Still no progress
Hi,
thank you for your response.
I have tried the following with not much success:
-
I changed the script in my second combobox to:
var key = Doc1.getItemValueString(“ProjectName”)
@DbLookup(“”,“Projects”,key,2)
-
I have added a “computed field” with this formula:
var key = Doc1.getItemValueString(“ProjectName”)
return key
- I added a second “computed field” with the same formula as the second combobox:
var key = Doc1.getItemValueString(“ProjectName”)
@DbLookup(“”,“Projects”,key,2)
-
I added a link with a “Full refresh” event
and a link with “Save document”-action
Now the behaviour is like this:
-if i “preview” the xPage then all fields except the first combobox are empty
-if i hit the “Full refresh” button after changing the value in the first combobox, no change.
- if i hit the “Save” button, then the two computed fiedls get the correct values. The second combobox is still empty.
-if i open an already existing document from a view, then the comuted fields and also the second combobox have the proper values !
- However if i change the value in the firt combobox no update happens. If i do an full update → no change. Only if i do a save then at least the two computed fields get updated.
Any idea what i am doing wrong ?
Thank you in advance.
Bye
Lars
Subject: Could you send me the sample app?
Hi Lars,Could you send me the sample app (ACL wide open and non-encrypted) for me to take a closer look?
Regards,
Paul.
paul_hannan@ie.ibm.com