hello team,
this is my first post here in this forum. i am trying to implement javascript filter in <h:selectManyListbox>. selectmanylistbox takes the arraylist as its value type.
When i try to pass the #{bean.arraylist} from
jsf in javascript filter function it reads as object , not the list of
string value. how can i pass and convert this arraylist object (#{bean.arraylist}) into javascript array?. searched a lot in this topic but very less documentation in this topic. In
jsp it is easy but i find really unfriendly using javascript in jsf. i am nearly close to my filter :P.
thanks
the relevant code:
jsf code
<h:inputText value="#{addRelServiceBean.addRelDTO.filtervalue}" id="filter"
onkeyup="handleKeyUp('Form:filter','Form:availablelist','Form:selectedlist','#{addRelServiceBean.availablelist}','9999');"/>
javascript src code
function handleKeyUp(input,select,selected,userList,maxNumToShow)
{
var selectObj, textObj, functionListLength;
var i, searchPattern, numShown,addval;
textObj = $(input);
selectObj = $(select);
functionListLength = userList.length;
if(textObj.value=='Enter name to filter')
searchPattern="^";
else
searchPattern = "^"+textObj.value;
re = new RegExp(searchPattern,"gi");
selectObj.length = 0;
numShown = 0;
for(i = 0; i < functionListLength; i++)
{
if(userList[i].search(re) != -1)
{
selectObj[numShown] = new Option(userList[i],"");
numShown++;
}
if(numShown == maxNumToShow)
{
break;
}
}
if(selectObj.length == 1)
{
selectObj.options[0].selected = true;
}
}
function addSelectedValue(source,destination){
sourceObj = $(source);
destinationObj = $(destination);
if(sourceObj.selectedIndex>=0)
{
destinationObj[destinationObj.length]=new Option(sourceObj.options[sourceObj.selectedIndex].text,sourceObj.options[sourceObj.selectedIndex].value);
sourceObj.options[sourceObj.selectedIndex]=null;
}
}