Vote count:
0
I am having trouble when trying to update my datatable using Ajax. I have an update attribute in my commandButton in which I select the table, but when I click the button the ajax does not work and the page is refreshed.
Here is the xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb"
xmlns:ui="http://ift.tt/KsEgXx"
xmlns:h="http://ift.tt/HjFrZb"
xmlns:f="http://ift.tt/HcrI1S"
xmlns:p="http://ift.tt/HjFrZc"
xmlns:pt="http://ift.tt/1fNVSr5">
<head></head>
<body>
<h:form id="search">
<p:inputText id="searchInput" value="#{matchBean.searchInput}"
required="true" requiredMessage="Please enter match id"
pt:placeholder="Enter player id"></p:inputText>
<p:commandButton ajax="true" value="Search" update=":#
{p:component('results')}"
actionListener="#{matchBean.searchForMatches()}">
</p:commandButton>
</h:form>
<h:form id="results">
<p:dataTable var="match" value="#{matchBean.matches}" id="resultsTable">
<p:column headerText="Id" id="idHeader">
<h:outputText id="idText" value="#{match.match_id}">
</h:outputText>
</p:column>
</p:dataTable>
</h:form>
</body>
</html>
And the backing bean:
@ManagedBean
@RequestScoped
public class MatchBean {
private Match match;
private List<MatchResponseDetails> matches;
private String searchInput;
public void searchForMatch() {
setMatch(new MatchRetriever().getMatchDetails(searchInput));
}
public void searchForMatches() {
setMatches(new MatchRetriever().getLightMatchData(searchInput));
}
public Match getMatch() {
return match;
}
public void setMatch(Match match) {
this.match = match;
}
public List<MatchResponseDetails> getMatches() {
return matches;
}
public void setMatches(List<MatchResponseDetails> matches) {
this.matches = matches;
}
public String getSearchInput() {
return searchInput;
}
public void setSearchInput(String searchInput) {
this.searchInput = searchInput;
System.out.println(searchInput);
}
asked 33 secs ago
Using Ajax to update Primefaces datatable
Aucun commentaire:
Enregistrer un commentaire