I have a working datatable that can list out restaurant objects. I want to delete/edite the selected ones but when I select one the following exception shows up:
org.springframework.dao.InvalidDataAccessApiUsageException: The given id must not be null!
Here is the table:
<h:form id="restaurantForm">
<p:dataTable var="restaurant"
value="#{restaurantLazyBean.lazyDataModel}" paginator="true"
rows="10" rowsPerPageTemplate="5,10,50" id="carTable" lazy="true"
selectionMode="single" selection="#{RestaurantEditBean.selected}"
rowKey="#{restaurant.id}"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">
<p:ajax event="rowSelect"
listener="#{RestaurantEditBean.onRowSelect()}"/>
<p:column headerText="ID">
<h:outputText value="#{restaurant.id}" />
</p:column>
</p:dataTable>
</h:form>
Now all ids appear in the table but on selection the exception shows up. I tried to do everything according to the primefaces example. But they didn't even have the rowKey attribute.
Heres the bean if thats relevant.
@Named("RestaurantEditBean")
@ViewScoped
@EJB(name = "ejb.RestaurantService", beanInterface = RestaurantService.class)
public class RestaurantEditBean {
@EJB
private RestaurantService restaurantService;
private RestaurantDTO selected;
public void onRowSelect(SelectEvent event) {
selected = ((RestaurantDTO) event.getObject());
}
public RestaurantService getRestaurantService() {
return restaurantService;
}
public void setRestaurantService(RestaurantService restaurantService) {
this.restaurantService = restaurantService;
}
public RestaurantDTO getSelected() {
return selected;
}
public void setSelected(RestaurantDTO selected) {
this.selected = selected;
}
}
Primefaces: 5.3 JSF: 2.2
@EJBpositioning over the managed beanRestaurantEditBean? What magic is being played by it? How is the exception coming fromorg.springframeworkwhile using EJBs? - Tiny