Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.s2tech.jsfapp.controllers;
- import javax.faces.bean.ManagedBean;
- import javax.faces.bean.ViewScoped;
- import com.s2tech.jsfapp.helper.SearchHelper;
- import com.s2tech.jsfapp.managedbean.SearchManagedBean;
- @ManagedBean(name ="searchController")
- @ViewScoped
- public class SearchController implements Serializable{
- public SearchController(){
- private static final long serialVersionUID = 1L;
- SearchHelper searchHelper;
- private List<SearchManagedBean> employeeList=new ArrayList<SearchManagedBean>();
- public List<SearchManagedBean> getEmployeeList() {
- return employeeList;
- }
- public void setEmployeeList(List<SearchManagedBean> employeeList) {
- this.employeeList = employeeList;
- }
- public void getEmployee(SearchManagedBean searchManagedBean) {
- searchHelper=new SearchHelper();
- employeeList = searchHelper.getEmployee(searchManagedBean);
- //return "search.xhtml";
- //return Constants.searchPage;
- // return null;
- }
- <h:body style="background-color:skyblue;">
- <ui:include src="mainMenu.xhtml"></ui:include>
- <h:form prependId="false">
- <table>
- <tr style="display:block;margin-top:10px;width:100%;margin-left:40%">
- <td style="width:40%">
- <p:outputLabel for="firstName" value="First Name:" style="font-weight:bold" />
- <p:inputText id="firstName" value="#{searchManagedBean.firstName}" required="true" requiredMessage="please enter First Name"> </p:inputText>
- <p:message id="firstNameMsg" for="firstName" showDetail="true" ></p:message>
- </td>
- <td style="width: 20%"></td>
- <td style="width:40%;">
- <p:outputLabel for="lastName" value="Last Name:" style="font-weight:bold"/>
- <p:inputText id="lastName" value="#{searchManagedBean.lastName}" required="true" requiredMessage="please enter Last Name" />
- <p:message id="lastNameMsg" for="lastName" showDetail="true" ></p:message>
- </td>
- </tr>
- <tr style="display:block;margin-top:10px;width:100%;margin-left:78%">
- <td style="width:40%"> <p:commandButton value="Search" action="#{searchController.getEmployee(searchManagedBean)}" update="firstNameMsg lastNameMsg emailMsg phoneMsg dataTable"/></td>
- </tr>
- </table>
- </h:form>
- <p:dataTable id="dataTable" var="emp" rendered="#{not empty searchController.employeeList}" value="#{searchController.employeeList}" rowStyleClass="table table-striped table-hover table-bordered" resizableColumns="true" resizeMode="expand" scrollWidth="50%" scrollHeight="150" >
- <p:column headerText="First Name">
- <h:outputText value="#{emp.firstName}"/>
- </p:column>
- <p:column headerText="Last Name">
- <h:outputText value="#{emp.lastName}"/>
- </p:column>
- <p:column headerText="Email">
- <h:outputText value="#{emp.email}"/>
- </p:column>
- <p:column headerText="Phone">
- <h:outputText value="#{emp.phone}"/>
- </p:column>
- <p:column headerText="Edit">
- <p:commandLink value="Edit" action="#{searchController.getEditForm(emp)}" style="margin-left:40px;color:blue;"></p:commandLink>
- </p:column>
- </p:dataTable>
- </h:body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement