Skip to content

Commit

Permalink
add support for plain arrays to AjaxAutoComplete
Browse files Browse the repository at this point in the history
Add support of Object[] besides NSArray and List. Output warning if we get an unsupported class type for list binding.
  • Loading branch information
darkv committed Jun 17, 2016
1 parent db4a5d0 commit be7b7ca
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxAutoComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import java.util.Iterator;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOContext;
import com.webobjects.appserver.WOElement;
Expand Down Expand Up @@ -93,6 +96,8 @@
* @author ak
*/
public class AjaxAutoComplete extends AjaxComponent {
private static final Logger log = LoggerFactory.getLogger(AjaxAutoComplete.class);

/**
* Do I need to update serialVersionUID?
* See section 5.6 <cite>Type Changes Affecting Serialization</cite> on page 51 of the
Expand Down Expand Up @@ -353,6 +358,15 @@ else if (values instanceof List) {
appendItemToResponse(iter.next(), child, hasItem, response, context);
}
}
else if (values instanceof Object[]) {
Object[] array = (Object[]) values;
for (int i = 0; i < array.length && i < maxItems; i++) {
appendItemToResponse(array[i], child, hasItem, response, context);
}
}
else if (values != null) {
log.warn("Unsupported class type for list: {}", values.getClass().getCanonicalName());
}
response.appendContentString("</ul>");
return response;
}
Expand Down

0 comments on commit be7b7ca

Please sign in to comment.