Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //XHTML Page
- <?xml version='1.0' encoding='UTF-8' ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets">
- <ui:composition template="/templates/masterLayout.xhtml">
- <ui:define name="content">
- <f:metadata>
- <f:viewParam name="lineid" value="#{lineViewBean.lineid}" required="true" requiredMessage="#{msgs.lblNoLineInfo}">
- <f:validateLongRange minimum="1"/>
- </f:viewParam>
- <f:event type="preRenderView" listener="#{lineViewBean.loadLine}"/>
- </f:metadata>
- <h3><h:outputText id="headerText" value="#{lineViewBean.line.name} Details"/></h3>
- <h:form id="lineDetails">
- <h:messages id="msgs"/>
- <h:inputText id="lineName" value="#{lineViewBean.line.name}">
- <f:ajax event="keyup" execute="btnSave" render="@this msgs" />
- </h:inputText>
- <h:message for="lineName" />
- <h:commandButton id="btnSave" action="#{lineViewBean.update}" value="#{msgs.btnSave}"/>
- <h:commandButton action="#{lineViewBean.delete}" value="#{msgs.btnDelete}" />
- </h:form>
- <h:link outcome="listLines" value="#{msgs.lnkBrowseCatalog}" />
- </ui:define>
- </ui:composition>
- </html>
- //backingbean
- package com.tf.web;
- import com.tf.facade.LineMaintainFacade;
- import com.tf.model.Line;
- import java.io.Serializable;
- import javax.ejb.EJB;
- import javax.faces.bean.ViewScoped;
- import javax.faces.bean.ManagedBean;
- @ManagedBean(name = "lineViewBean")
- @ViewScoped
- public class LineViewViewBackingBean implements Serializable {
- @EJB
- private LineMaintainFacade lineService;
- private Line line;
- private Long lineId;
- public Long getLineid() {
- return lineId;
- }
- public void setLineid(Long lineid) {
- this.lineId = lineid;
- }
- public void loadLine() {
- if (line == null) {
- line = lineService.getLine(lineId);
- }
- }
- public Line getLine() {
- return line;
- }
- public void setLine(Line line) {
- this.line = line;
- }
- public String update() {
- line = lineService.update(line);
- return "update";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement