DunDmy
DunDmy

Reputation: 275

Removing trailing spaces inside <af:inputListOfValue>

I am looking for a way to trim my leading and trailing spaces inside my af:inputListOfValues components. I can access the View Criteria programmatically, and trim all my values from VOImpl custom class, but I am not sure how to expose it to the actual component. Is the a way to expose my custom methods to the LOV component? Thank you in advance!

Upvotes: 0

Views: 165

Answers (1)

DunDmy
DunDmy

Reputation: 275

In order to trim the values inside my LOV component I had to override executeQueryForCollection. This way I was be able to access my parameters and trim them.

@Override
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
    ArrayList<Object[]> alParams = new ArrayList<Object[]>();

    //Pass along any explicit (user entered) parameters for the query. Also some implicit parameters.
    if(params != null && params.length > 0){
        for (Object o : params) {
            alParams.add((Object[])o);
        }
        //Access the value of each object and trim it
        for (Object[] p: alParams){
            if(p.length > 1){
                p[1] = trimCriteria(p[1]);  
            }  
        }
        Object[] trimParams = alParams.toArray();
        super.executeQueryForCollection(qc, trimParams, noUserParams);
    } else {
        super.executeQueryForCollection(qc, params, noUserParams);
    }

}


public Object trimCriteria (Object searchCriteria){
    if(searchCriteria instanceof String)
    if(searchCriteria != null){
        searchCriteria = ((String)searchCriteria).trim();
    }
    return searchCriteria;
}`

Upvotes: 1

Related Questions