learner420
learner420

Reputation: 182

Managed Property is not getting updated in Primefaces

I am using an ajax box which will fetch the list of object based the string provided in the box as follows:

<p:inputText id="zid" placeholder="Search" value="#{resourceListView.wanted}">
                    <p:ajax event="keyup" update=":form:abc"
                        listener="#{resourceListView.SearchResources}" />
                </p:inputText>

SearchResources will fetch the objects based on the value of input box as follows:

public void SearchResources(String wanted) {
        this.resources=resourceServiceImpl.listResources(wanted);
    }

I was running the query in the DAO which was meant to return the object based on the search. But it didn't return anything. So I sysout the query and the query comes out as follows:

SELECT * FROM test.resourcemaster where Resource_ZID like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText@79d635]%' OR Employee_ID like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText@79d635]%' OR First_Name like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText@79d635]%' OR Last_Name like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText@79d635]%'

the query was supposed to be searching on the 'wanted'

Could anyone explain what is the problem.

Upvotes: 0

Views: 160

Answers (1)

Predrag Maric
Predrag Maric

Reputation: 24423

Your SearchResources() method accepts one parameter, which you don't supply from page. That's why AjaxBehaviorEvent is passed to it (event.toString(), to be more precise), which is the default if you don't specify parameters in method call.

Try changing the ajax listener to listener="#{resourceListView.SearchResources(resourceListView.wanted)}"

Or, simply remove the parameter from the method, and use bean wariable wanted

public void SearchResources() {
    this.resources = resourceServiceImpl.listResources(this.getWanted());
}

Upvotes: 2

Related Questions