in my application I’m trying to extract the values from a filter list (auto-complete field).
In that field I have [ID, Name] ex [j342234, A,S]. I was able to retrieve the whole criteria by
doing this
Object Filterlistresult = fliterList.getCriteria();
but now I want to get extract ID part only from that field. Any Ideas?
Thank you in advance.
// here I get the values from a web server and insert them to the work Vector
public void parseJSONResponceInWB(String jsonInStrFormat) {
try {
JSONObject json = new JSONObject(jsonInStrFormat);
JSONArray jArray = json.getJSONArray("transport");
for (int i = 1; i < jArray.length(); i++) {
JSONObject j = jArray.getJSONObject(i);
ID = j.getString("ID");
Name = j.getString("Name");
WBenchVector.addElement(ID + " " + Name);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
// adding the values to the filter list
private void RequestAutoComplete() {
String[] returnValues = new String[WBenchVector.size()];
System.out.print(returnValues);
for (int i = 0; i < WBenchVector.size(); i++) {
returnValues[i] = (String) WBenchVector.elementAt(i);
}
autoCompleteField(returnValues);
}
// creating the filter list field
private void autoCompleteField(String[] returnValues) {
filterLst = new BasicFilteredList();
filterLst.addDataSet(ID, returnValues, "",
BasicFilteredList.COMPARISON_IGNORE_CASE);
autoFld.setFilteredList(filterLst);
}
Finally i’m getting what the user select using this
AutoFieldCriteria = filterLst.getCriteria();
Thank you Nate. I actually fixed the problem.
I converted the filterField Object to String and then I looked for the index of the first space, and substring the first word
Thanks again.