HTML and CSS Reference
In-Depth Information
<f:ajax render="@form" />
</h:commandLink>
</h:column>
</h:dataTable>
</h:panelGroup>
<h:messages id="messages" class="errorMessage"/>
</h:form>
</ui:define>
</ui:composition>
</html>
In the
preRenderView
event, the users list is retrieved using
#{userSearchBacking.retrieveUserList}
expression.
When the users list is retrieved, the
<h:dataTable>
component is populated with the users list; every row in
the data table renders a user information with the ability to remove any user using the
"Delete"
command link. The
"Delete"
command link sets the
#{userSearchBacking.selectedUser}
property with the current selected user
(
#{megaUser}
) using a property action listener and then calls the
#{userSearchBacking.deleteUser}
action method
in order to perform the delete user operation.
Listing 13-33 shows
UserSearchBacking
CDI bean.
Listing 13-33.
UserSearchBacking CDI Bean
package com.jsfprohtml5.megaapp.backing;
import com.jsfprohtml5.megaapp.model.MegaUser;
import com.jsfprohtml5.megaapp.service.MegaUserManagerLocal;
import com.jsfprohtml5.megaapp.service.exception.UserNotFound;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
@Named
@ViewScoped
public class UserSearchBacking extends BaseBacking implements Serializable {
@EJB
private MegaUserManagerLocal userManager;
private List<MegaUser> userList;
private String infoMessage;
private MegaUser selectedUser;