I have a jsp page with a dijit.form.ComboBox which is populated by a dojo.data.ItemFileReadStore connecting to a back end java server. It works almost as expected, the combobox shows the results correectly. Problem is that I receive a 'dojo.data.ItemFileReadStore: Invalid item argument.' when scrolling in a results list with the keyboard arrow keys. Selecting with the mous开发者_JAVA百科e however works fine.
Dojo version is 1.2.3
This is how I've put it in place on my jsp:
<input type="text" id="value"
dojoType="dijit.form.ComboBox"
autoComplete="false"
searchAttr="name"
forceValidOption="true"
hasDownArrow="false"
onKeyUp="populateValue"
/>
<script type="text/javascript">
function populateValue() {
valueWidget = dijit.byId("value");
var selectedValue = valueWidget.getValue();
var url = "${contextPath}/someUrl?selectedValue=" + selectedValue + "%";
store = new dojo.data.ItemFileReadStore({url:url});
valueWidget.store = store;
return;
}
</script>
Here is the JSON I receive from the server:
{"items":[
{"name":"My string 1","label":"My string 1"},
{"name":"My string 2","label":"My string 2"},
{"name":"Mev.","label":"Mev."}],
"identifier":"name"}
Any idea what's going wrong here?
Solved it. Problem seemed to be the onKeyUp event on the combobox. When I changed this to onKeyPress, arrowing down the list gives no more errors.
Compared to onKeyUp, onKeyPress gives me in fact a delay of one character because the event is triggered when the character is not actually typed already. Any idea how I could overcome this?
精彩评论