I currently have a wrapper list containing custom sObjects and checkboxes. I also have a inputText field on a Visualforce page and would like to filter the wrapper list by License_Voucher__c which is a field in my custom SObject contained within my wrapper.
I would like for the search to contain all variances of the string such as if the user typed in 'john' , the search would return 'john', 'johnson', 'johnny'. Basically john* or a sql equivalent of 'LIKE'.
To make life simpler I added a string voucherNumber to my wrapper and tried to iterate through the list with the .contains() to see if each element met the inputText requirements.
Unfortunately whether I try searching with the entire correct string or part of the correct string I seem to get no results. Would there be a better approach to this? thanks!
Wrapper Class
public class wrapper_OlympusLR{
public License_Request__c lrObj {get;set;}
public String macAddress {get;set;}
public String serverName {get;set;}
public String serialNumber {get;set;}
public String serverModel {get;set;}
public Boolean selected {get;set;}
public String voucherNumber {get;set;}
public wrapper_OlympusLR(License_Request__c lrq)
{
this.lrObj = lrq;
this.selected = false;
this.macAddress = null;
this.serverName = null;
this.serialNumber = null;
this.serverModel = null;
this.voucherNumber = lrq.License_Voucher__c;
}
Controller Search Method
public PageReference runSearch()
{
String voucherNumber = inputVoucherNumber+'.*';
if(voucherNumber.equals(''))
{
//DO NOTHING OR USE ORIGINAL LIST
wrapDynLRList = wrapLRListOriginal;
}
else
{
wrapDynLRList.clear();
for(wrapper_OlympusLR lrList : wrapLRListOriginal)
{
if(lrList.voucherNumber.contains(voucherNumber))
{
wrapDynLRList.add(lrList);
}
}
}
return null;
}