Skip to content

Commit 73aaf9b

Browse files
Copilotrvosa
andcommitted
Add DWR error handlers to prevent autocomplete alerts on empty database
Co-authored-by: rvosa <106490+rvosa@users.noreply.github.com>
1 parent 2a3384d commit 73aaf9b

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

treebase-web/src/main/webapp/decorators/defaultTemplate.jsp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,46 @@
4444
<script type="text/javascript" src="<c:url value='/scripts/autocomplete.js'/>"></script>
4545
<script type="text/javascript" src="<c:url value='/scripts/ajaxProgress.js'/>"></script>
4646
<script language="Javascript" type="text/javascript">
47+
// Configure DWR to suppress default error alerts for autocomplete
48+
if (typeof dwr !== 'undefined' && dwr.engine) {
49+
dwr.engine.setErrorHandler(function(message, ex) {
50+
// Silently handle DWR errors for autocomplete (e.g., empty database)
51+
if (typeof console !== 'undefined' && console.log) {
52+
console.log('DWR error (suppressed): ' + message);
53+
}
54+
});
55+
}
4756
4857
function updateList(autocompleter, token) {
49-
RemotePersonService.findCompleteEmailAddress(token, function(data) { autocompleter.setChoices(data) });
58+
RemotePersonService.findCompleteEmailAddress(token, {
59+
callback: function(data) { autocompleter.setChoices(data || []); },
60+
errorHandler: function(message, ex) { autocompleter.setChoices([]); }
61+
});
5062
}
5163
function nameValueSelector(tag){
5264
return tag;
5365
}
5466
// nameValueSelctor(tag) method is used by all the four methods related to Auto Suggestion Box
5567
5668
function updateSoftwareNameList(autocompleter, token) {
57-
RemoteSoftwareNameService.findCompleteSoftwareName(token, function(data) { autocompleter.setChoices(data) });
69+
RemoteSoftwareNameService.findCompleteSoftwareName(token, {
70+
callback: function(data) { autocompleter.setChoices(data || []); },
71+
errorHandler: function(message, ex) { autocompleter.setChoices([]); }
72+
});
5873
}
5974
6075
function updateJournalNameList(autocompleter, token) {
61-
RemoteJournalNameService.findCompleteJournalName(token, function(data) { autocompleter.setChoices(data) });
76+
RemoteJournalNameService.findCompleteJournalName(token, {
77+
callback: function(data) { autocompleter.setChoices(data || []); },
78+
errorHandler: function(message, ex) { autocompleter.setChoices([]); }
79+
});
6280
}
6381
6482
function updateUniqueOtherAlgorithmList(autocompleter, token) {
65-
RemoteUniqueOtherAlgorithmService.findAllUniqueOtherAlgorithmDescriptions(token, function(data) { autocompleter.setChoices(data) });
83+
RemoteUniqueOtherAlgorithmService.findAllUniqueOtherAlgorithmDescriptions(token, {
84+
callback: function(data) { autocompleter.setChoices(data || []); },
85+
errorHandler: function(message, ex) { autocompleter.setChoices([]); }
86+
});
6687
}
6788
6889
</script>

0 commit comments

Comments
 (0)