Thanks. Below is my source code:
SysConfig2Bean:
| package com.abc.test.session;
|
| import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.ejb.TransactionAttribute;
| import javax.interceptor.Interceptors;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.ejb.SeamInterceptor;
|
| import com.abc.core.entity.SysConfig;
|
| @Stateful
| @Name("com.abc.test.session.sysConfig2Bean")
| @Interceptors(SeamInterceptor.class)
| public class SysConfig2Bean implements SysConfig2Local {
| @PersistenceContext
| EntityManager em;
|
| private SysConfig instance;
| private boolean isNew=true;
|
| @TransactionAttribute(NOT_SUPPORTED)
| public SysConfig getInstance() {
| return instance;
| }
|
| public void setInstance(SysConfig instance) {
| this.instance = instance;
| }
|
| @TransactionAttribute(NOT_SUPPORTED)
| public boolean isNew() {
| return isNew;
| }
|
| public void setNew(boolean isNew) {
| this.isNew = isNew;
| }
|
| @Remove
| @Destroy
| public void remove(){
|
| }
| }
|
SysConfig2FinderBean
| package com.abc.test.session;
|
| import java.util.List;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.interceptor.Interceptors;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
| import org.jboss.seam.ejb.SeamInterceptor;
|
| import com.abc.core.entity.SysConfig;
|
| @Stateful
| @Name("com.abc.test.session.sysConfig2FinderBean")
| @Scope(ScopeType.SESSION)
| @Interceptors(SeamInterceptor.class)
| public class SysConfig2FinderBean implements SysConfig2FinderLocal {
| @PersistenceContext
| private EntityManager em;
|
| @DataModel
| private List entityList;
|
| @DataModelSelection
| private SysConfig selectedEntity;
|
| public SysConfig getSelectedEntity(){
| return em.merge(selectedEntity);
| }
|
| public List getEntityList() {
| entityList = query();
| return entityList;
| }
|
| public void setEntityList(List entityList) {
| this.entityList = entityList;
| }
|
| private List query(){
| return em.createQuery("from SysConfig").getResultList();
| }
|
| @Destroy
| @Remove
| public void remove(){
|
| }
| }
|
|
SysConfig2SelectorBean
| package com.abc.test.session;
|
| import javax.ejb.Stateless;
| import javax.interceptor.Interceptors;
|
| import org.jboss.seam.annotations.Begin;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.ejb.SeamInterceptor;
|
| @Stateless
| @Name("com.abc.test.session.sysConfig2SelectorBean")
| @Interceptors(SeamInterceptor.class)
| public class SysConfig2SelectorBean implements SysConfig2SelectorLocal {
| @In(create = true, value="com.abc.test.session.sysConfig2Bean")
| private transient SysConfig2Local sysConfig2Bean;
|
| @In(create = true, value="com.abc.test.session.sysConfig2FinderBean")
| private transient SysConfig2FinderLocal sysConfig2Finder;
|
| @Begin
| public String select() {
|
sysConfig2Bean.setInstance(sysConfig2Finder.getSelectedEntity());
| sysConfig2Bean.setNew(false);
| return "sysConfigEdit";
| }
| }
|
|
sysConfigList.jsf
| <%@ page contentType="text/html; charset=UTF-8" %>
| <%@ page pageEncoding="UTF-8" %>
| <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h" %>
| <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>
| http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
| http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
|
| Testing
|
|
|
|
|
| @import "/jsp/css/default.css";
|
|
|
|
|
|
|
|
|
|
|