2

I changed my <h:commandButton> tag to a PrimeFaces <p:commandButton> tag on a search page and my datatable stopped displaying the results. After adding an update attribute things worked again. I'm just trying to understand whether it is how I implemented the overall functionality (viewscope, action vs actionListener, etc) or is the update attribute really required?

<h:form id="search_form">
    <p:inputText id="search" value="#{searchBean.searchString}" />
    <p:commandButton update="search_form" value="Search" action="#{searchBean.searchByString}" >
    </p:commandButton>

<p:dataTable id="output" var="res" value="#{searchBean.results}" emptyMessage="No results found with given criteria">

etc...
@ViewScoped
@ManagedBean
public class SearchBean {

@Inject
private SearchRepository searchRepository;
private List<Results> res;
private String searchString; 

public SearchBean() {
        }

public String searchByString()
{
    this.setRes(searchRepository.searchBySingleString(searchString));
}
Aritz
  • 30,971
  • 16
  • 136
  • 217
jeff
  • 3,618
  • 9
  • 48
  • 101
  • The `update` attribute is required for the change to be visible by the client (UA). –  Jul 03 '14 at 20:49

1 Answers1

7

One of the differences between h:commandButton and p:commandButton is that the second one performs an ajax request by default, while the first executes a plain POST request.

In an ajax request, you must specify what you want to process when form is sent and what to update when response happens. The p:commandButton updates nothing by default, that's why your table is not being properly filled.

See also:

Community
  • 1
  • 1
Aritz
  • 30,971
  • 16
  • 136
  • 217