如何在jsf1.2中实现BookMark?

时间:2013-02-25 06:15:10

标签: bookmarks jsf-1.2

在我使用JSF1.2的应用程序中,我有两个jsp页面,其中一个allemployee.jsp,其中<h:dataTable>放置了100 rows。每个人都包含员工namephone Noexperience等等......第二页是 detail.jsp我在哪里展示单个员工的详细信息。在allemployee.jsp的每一行中,<h:commandLink>的值为employee's name。点击此<h:commandLink>后,它会显示相应的内容 员工在detail.jsp中的详细信息。现在detail.jsp我有一个名为<h:commandButton>的{​​{1}}。点击此Go Back用户后,我想要从他/她进入button的上一个位置 跳到allemployee.jsp

我的detail.jsp看起来像是:

allemployee.jsp

我的<h:form> <h:dataTable id="employeeList" value="#{employeelist.employees}" var="employee" cellspacing="60"> <f:facet name="header"><h:outputText value="#{msg.list}" /></f:facet> <h:column> <f:facet name="header"><h:outputText value="#{msg.name}"/></f:facet> <h:commandLink value="#{employee.name}" action="#{employeelist.getaction}" actionListener="#{employeelist.sendToDetail}"> <f:param id="NamE" value="#{employee.name}" name="NamE"/> </h:commandLink> </h:column> <h:column> <f:facet name="header"><h:outputText value="#{msg.phn}" /></f:facet> <h:outputText value="#{employee.phNo}" /> </h:column> <h:column> <f:facet name="header"><h:outputText value="#{msg.experience}" /></f:facet> <h:outputText value="#{employee.experiance}" /> </h:column> </h:dataTable> </h:form> 看起来像是:

detail.jsp

<h:form> <h:panelGrid columns="2"> <h:outputLabel value="#{msg.name}" /> <h:outputText value="#{detail.employee.name}" /> <h:outputLabel value="#{msg.phn}" /> <h:outputText value="#{detail.employee.phNo}" /> <h:outputLabel value="#{msg.experience}" /> <h:outputText value="#{detail.employee.experiance}" /> </h:panelGrid> <h:outputLink value="/allemployee.jsp#paramName"> <f:param name="paramName" value="#{detail.employee.name}"/> <h:outputText value="Go Back" /> </h:outputLink> Bean看起来像:

employeelist

} 在课程public class EmployeeListController implements Serializable { private static final long serialVersionUID = 6930161072142091260L; private List<EmployeeModel> employees; @PostConstruct public void init() { Service service = new Service(); this.employees = service.getAll(); } public void sendToDetail(ActionEvent ev) { String name = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("NamE"); for (EmployeeModel employee : employees) { if (employee.getName().equals(name)) { HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); req.setAttribute("employe", employee); } } } public String goback(){ return "allemployee"; } public String getaction() { return "detail"; } //getter & setter of employees. 中,有变量EmployeeModelnamephNo和getters&amp; setter方法。 在课程experience中,我设置了所有员工的详细信息。

我的Service Bean看起来像:

detail

}

public class DetailController implements Serializable { private static final long serialVersionUID = 8632585974603579268L; private EmployeeModel employee = new EmployeeModel(); private String paramName; public DetailController() { } @PostConstruct public void init() { HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); this.employee = (EmployeeModel) req.getAttribute("employe"); this.paramName = employee.getName(); } // getter & setter employee and paramName. 就像:

faces-config

我如何满足我的要求?任何指针都对我很有帮助。谢谢,

0 个答案:

没有答案