[jboss-user] [JBoss Seam] - Re: DataModelSelection Problem

recycle_bin do-not-reply at jboss.com
Sat Aug 5 03:23:34 EDT 2006


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<SysConfig> entityList;
  | 
  | 	@DataModelSelection
  | 	private SysConfig selectedEntity;
  | 	
  | 	public SysConfig getSelectedEntity(){
  | 		return em.merge(selectedEntity);
  | 	}
  | 	
  | 	public List<SysConfig> getEntityList() {
  | 		entityList = query();
  | 		return entityList;
  | 	}
  | 
  | 	public void setEntityList(List<SysConfig> entityList) {
  | 		this.entityList = entityList;
  | 	}
  | 	
  | 	private List<SysConfig> 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" %>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  | <head>
  | 	<title>Testing</title>
  | 	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |  
  | 	<meta http-equiv="Pragma" content="no-cache">
  | 	<meta http-equiv="expires" content="0" >
  | 	<style type="text/css" media="all">
  | 		@import "/jsp/css/default.css";
  | 	</style>
  | </head>
  | <f:view>
  | <f:loadBundle basename="lookup" var="lookupMsg"/>
  | <body>
  | 	<table width="100%" height="100%">
  | 		<tr>
  | 			<td>
  | 				<!-- Content Start Here -->
  | 				<div class="rvgResults">
  | 					<h:form id="sysConfigForm">
  | 						<h:dataTable value="#{com$abc$test$session$sysConfig2FinderBean.entityList}" var="sysConfig"
  | 						rowClasses="rvgRowOne,rvgRowTwo" headerClass="rvgOrder" width="100%">
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Section" />
  | 								</f:facet>
  | 								<h:outputText value="#{sysConfig.section}"/>
  | 							</h:column>
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Name" />
  | 								</f:facet>
  | 								<h:outputText value="#{sysConfig.name}"/>
  | 							</h:column>
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Config Group" />
  | 								</f:facet>
  | 								<h:outputText value="#{sysConfig.configGroup}"/>
  | 							</h:column>
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Value" />
  | 								</f:facet>
  | 								<h:outputText value="#{sysConfig.value}"/>
  | 							</h:column>
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Remarks" />
  | 								</f:facet>
  | 								<h:outputText value="#{sysConfig.remarks}"/>
  | 							</h:column>
  | 							<h:column>
  | 								<f:facet name="header">
  | 									<h:outputText value="Edit" />
  | 								</f:facet>
  | 								<h:commandButton value="Edit" action="#{com$abc$test$session$sysConfig2SelectorBean.select}">
  | 								</h:commandButton>
  | 							</h:column>
  | 						</h:dataTable>
  | 					</h:form>
  | 				</div>
  | 				<!-- Content End Here -->
  | 			</td>
  | 		</tr>
  | 	</table>
  | 
  | </body>
  | </f:view>
  | </html>
  | 
  | 

sysConfigEdit.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" %>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  | <head>
  | 	<title>Testing</title>
  | 	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  |  
  | 	<meta http-equiv="Pragma" content="no-cache">
  | 	<meta http-equiv="expires" content="0" >
  | 	<style type="text/css" media="all">
  | 		@import "/jsp/css/default.css";
  | 	</style>
  | </head>
  | <f:view>
  | <f:loadBundle basename="sysconfig" var="sysconfigMsg"/>
  | <body>
  | <table width="100%" height="100%">
  | 	<tr>
  | 		<td>
  | 			<h:form id="sysConfigForm">
  | 			<div class="rvgFind">
  | 				<fieldset class="rvgFieldSet">
  | 					<legend>
  | 						<h:outputText value="#{sysconfigMsg.sysconfig_add}" rendered="#{com$abc$test$session$sysConfig2Bean.new}" />
  | 						<h:outputText value="#{sysconfigMsg.sysconfig_update}" rendered="#{!com$abc$test$session$sysConfig2Bean.new}" />
  | 					</legend>
  | 				
  | 					<span class="rvgInputs">
  | 						<span class="rvgMessage"><h:messages globalOnly="true"/></span>
  | 						<h:outputLabel value="#{sysconfigMsg.sysconfig_section}" for="section">
  | 							<h:inputText value="#{com$abc$test$session$sysConfig2Bean.instance.section}" id="section"/>
  | 							<span class="rvgMessage"><h:message for="section"/></span>
  | 						</h:outputLabel>
  | 						<h:outputLabel value="#{sysconfigMsg.sysconfig_name}" for="name">
  | 							<h:inputText value="#{com$abc$test$session$sysConfig2Bean.instance.name}" id="name"/>
  | 							<span class="rvgMessage"><h:message for="name"/></span>
  | 						</h:outputLabel>
  | 						<h:outputLabel value="#{sysconfigMsg.sysconfig_value}" for="value">
  | 							<h:inputText value="#{com$abc$test$session$sysConfig2Bean.instance.value}" id="value"/>
  | 							<span class="rvgMessage"><h:message for="value"/></span>
  | 						</h:outputLabel>
  | 						<h:outputLabel value="#{sysconfigMsg.sysconfig_configGroup}" for="configGroup">
  | 							<h:inputText value="#{com$abc$test$session$sysConfig2Bean.instance.configGroup}" id="configGroup"/>
  | 							<span class="rvgMessage"><h:message for="configGroup"/></span>
  | 						</h:outputLabel>
  | 						<h:outputLabel value="#{sysconfigMsg.sysconfig_remarks}" for="remarks">
  | 							<h:inputText value="#{com$abc$test$session$sysConfig2Bean.instance.remarks}" id="remarks"/>
  | 							<span class="rvgMessage"><h:message for="remarks"/></span>
  | 						</h:outputLabel>
  | 					</span>
  | 					
  | 					<span class="rvgActions">
  | 						<h:commandButton type="submit" value="#{sysconfigMsg.sysconfig_add}" action="#{com$abc$test$session$sysConfig2Bean.create}" rendered="#{com$abc$test$session$sysConfig2Bean.new}"/>
  | 						<h:commandButton type="submit" value="#{sysconfigMsg.sysconfig_update}" action="#{com$abc$test$session$sysConfig2Bean.update}" rendered="#{!com$abc$test$session$sysConfig2Bean.new}"/>
  | 					</span>
  | 				
  | 				</fieldset>
  | 			</div>				
  | 			</h:form>
  | 		</td>
  | 	</tr>
  | </table>
  | </body>
  | </f:view>
  | </html>
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963363#3963363

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963363



More information about the jboss-user mailing list