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

jkrupka do-not-reply at jboss.com
Wed Dec 13 15:29:37 EST 2006


Certainly...  Here's the two most relevant snippets, let me know if there's something else that would be helpful...


  | 
  | @Name("eTDocumentEditor")
  | @Stateful
  | @SerializedConcurrentAccess
  | @Interceptors(SeamInterceptor.class)
  | public class ETDocumentEditorBean implements ETDocumentEditor {
  | 
  | 	@In(create = true)
  | 	private EntityManager entityManager;
  | 
  | 	@Valid
  | 	private ETDocument instance = new ETDocument();
  | 
  | 	private boolean startConv = true;
  | 	
  | 	@DataModel
  | 	private List<ETContact> contactList;
  | 
  | 	@DataModelSelection
  | 	private ETContact selectedETContact;
  | 
  | 	@In(create = true)
  | 	private ETContactEditor eTContactEditor;
  | 	
  | 	@In(create = false, required = false) 
  | 	private ETContactFinder eTContactFinder;
  | 	
  | 	private boolean isNew = true;
  | 	
  | 	private boolean isChild = true;
  | 	
  | 	private String doneOutcome = "find";
  | 
  | 	private String doneChildOutcome = "doneChild";
  | 		
  | 	@In(required = false)
  | 	private transient ETDocumentFinder eTDocumentFinder;
  | 	
  | 	@In(create = true)
  | 	private transient ResourceBundle resourceBundle;
  | 		
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public ETDocument getInstance() {
  | 		return instance;
  | 	}
  | 	
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public void setInstance(ETDocument instance) {
  | 		this.instance = instance;
  | 
  | 	}
  | 	
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public boolean isNew() {
  | 		return isNew;
  | 	}
  | 
  | 	public void setNew(boolean isNew) {
  | 		this.isNew = isNew;
  | 	}
  | 
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public boolean isChild() {
  | 		return isChild;
  | 	}
  | 
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public void setChild(boolean isChild) {
  | 		this.isChild = isChild;
  | 	}
  | 	
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public void setDoneOutcome(String outcome) {
  | 		doneOutcome = outcome;
  | 	}
  | 
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public void setDoneChildOutcome(String outcome) {
  | 		doneChildOutcome = outcome;
  | 	}	
  | 
  | 	public String create() {
  | 		if (entityManager.find(ETMaster.class, instance.getPartkey()) == null ) {
  | 			FacesContext.getCurrentInstance().addMessage(
  | 					null,
  | 					new FacesMessage("This violates a constraint!"));
  | 			FacesContext.getCurrentInstance().addMessage(
  | 					null,
  | 					new FacesMessage("There is no EiTradeMaster record with a primary key of " + 
  | 							instance.getPartkey()));
  | 			return null;
  | 		}
  | 		
  | 		entityManager.persist(instance);
  | 		isNew = false;
  | 		refreshFinder();
  | 		return null;
  | 	}
  | 
  | 	@End(ifOutcome = {"find", "doneChild"})
  | 	public String update() {
  | 		refreshFinder();
  | 		return isChild ? doneChildOutcome : doneOutcome;
  | 	}
  | 
  | 	@End(ifOutcome = {"find", "doneChild"})
  | 	public String delete() {
  | 		entityManager.remove(instance);
  | 		entityManager.flush();
  | 		refreshFinder();
  | 		return isChild ? doneChildOutcome : doneOutcome;
  | 	}
  | 
  | 	@Begin(nested=true)
  | 	public String updateAndCreateChild() {
  | 		eTContactEditor.setInstance(new ETContact());
  | 		eTContactEditor.setDocConInstance(new ETDocContact(
  | 				new ETDocContactId(instance.getDocId(), null)));
  | 		eTContactEditor.setNew(true);
  | 		eTContactEditor.setChild(true);
  | 		refreshFinder();
  | 		return "child";
  | 	}
  | 	
  | 	@End(ifOutcome = {"find", "doneChild"})
  | 	public String done() {
  | 		
  | 		if (!isNew)
  | 			entityManager.refresh(instance);
  | 		return isChild ? doneChildOutcome : doneOutcome;
  | 	}
  | 
  | 	@Begin(nested=true)
  | 	public String selectContact() {
  | 		eTContactEditor.setInstance(selectedETContact);
  | 		eTContactEditor.setDocConInstance(entityManager.find(ETDocContact.class, 
  | 				new ETDocContactId(instance.getDocId(), selectedETContact.getContactkey())));
  | 		eTContactEditor.setNew(false);
  | 		eTContactEditor.setChild(true);
  | 		
  | 		return "editEiTradeContact";
  | 	}
  | 
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public String reorderChildren() {
  | 		eTContactFinder.setDocumentKey(instance.getDocId());
  | 		eTDocumentFinder.reorder();
  | 		return null;
  | 	}
  | 	
  | 	@TransactionAttribute(NOT_SUPPORTED)
  | 	public String findChildren() {
  | 		contactList = instance.getContacts();
  | 		return null;
  | 	}
  | 	
  | 	public List<ETContact> getContactList() {
  | 		return contactList;
  | 	}
  | 	
  | 	private void refreshFinder() {
  | 		if (eTDocumentFinder != null) {
  | 			eTDocumentFinder.refresh();
  | 		}
  | 	}
  | 
  | 	@Destroy
  | 	@Remove
  | 	public void destroy() {
  | 	}
  | 
  | 	public ETContactFinder getETContactFinder() {
  | 		return eTContactFinder;
  | 	}
  | 
  | 	public void setETContactFinder(ETContactFinder contactFinder) {
  | 		eTContactFinder = contactFinder;
  | 	}
  | 
  | 	public void setContactList(List<ETContact> contactList) {
  | 		this.contactList = contactList;
  | 	}
  | 
  | }
  | ...
  | 
  | 
  | 
  | editEiTradeDocument:
  | 
  | <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@ taglib uri="http://javascript4jsf.dev.java.net/" prefix="j4j" %>
  | <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
  | <!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">
  |  <f:view>
  |  <f:loadBundle basename="messages" var="msg"/>
  |   <head>
  |    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  |    <meta http-equiv="Content-Script-Type" content="text/javascript" />
  |    <title>
  |      <h:outputText value="#{msg.Create} #{msg.EiTradeDocument}" rendered="#{eTDocumentEditor.new}"/>
  |      <h:outputText value="#{msg.Update}/#{msg.Delete} #{msg.EiTradeDocument}" rendered="#{!eTDocumentEditor.new}"/>
  |    </title>
  |    <style type="text/css" media="all">
  |     @import "style/default/screen.css";
  |    </style>
  |   </head>
  |   <body>
  |    <h:form>
  |    
  |      <h1>
  |          <h:outputText value="#{msg.Create} #{msg.EiTradeDocument}" rendered="#{eTDocumentEditor.new}"/>
  |          <h:outputText value="#{msg.Update}/#{msg.Delete} #{msg.EiTradeDocument}" rendered="#{!eTDocumentEditor.new}"/>
  |      </h1>
  |      
  |      <div class="rvgSwitch">
  |        <h:selectOneMenu value="#{switcher.conversationIdOrOutcome}">
  | 		 <f:selectItem itemLabel="Create EiTradeDocument" itemValue="editEiTradeDocument"/>
  |          <f:selectItem itemLabel="Create EiTradeContact" itemValue="editEiTradeContact"/>
  |          <f:selectItem itemLabel="Create EiTradeMaster" itemValue="editEiTradeMaster"/>
  |          <f:selectItem itemLabel="Create EiTradeUomXref" itemValue="editEiTradeUomXref"/>
  |          <f:selectItem itemLabel="Find EiTradeDocument" itemValue="findEiTradeDocument"/>
  |          <f:selectItem itemLabel="Find EiTradeContact" itemValue="findEiTradeContact"/>
  |          <f:selectItem itemLabel="Find EiTradeMaster" itemValue="findEiTradeMaster"/>
  |          <f:selectItem itemLabel="Find EiTradeUomXref" itemValue="findEiTradeUomXref"/>
  |          <f:selectItems value="#{switcher.selectItems}"/>
  |        </h:selectOneMenu>
  |        <h:commandButton action="#{switcher.select}" value="Switch"/>
  |      </div>
  | 
  | 	<div class="rvgChildren">
  |      <fieldset class="rvgFieldSet">
  |        <legend><h:outputText value="#{msg.EiTradeDocument} #{msg.Attributes}"/></legend>
  |        
  |        <span class="rvgInputs">
  |          <span class="rvgMessage"><h:messages globalOnly="true"/></span>
  |        <s:validateAll>
  | 	<h:panelGrid columns="4" headerClass="rvgInputs">
  |          <h:outputLabel value="#{msg.EiTradeDocument_documentkey}" for="docId">
  |            <h:inputText value="#{eTDocumentEditor.instance.docId}" id="docId" disabled="true"/>
  |            <span class="rvgMessage"><h:message for="docId"/></span>
  |          </h:outputLabel>			
  |          <h:outputLabel value="#{msg.EiTradeDocument_isaidkey}" for="isaidkey">
  |            <h:inputText value="#{eTDocumentEditor.instance.isaidkey}" id="isaidkey" disabled="#{eTDocumentEditor.child}" required="true"/>
  |            <span class="rvgMessage"><h:message for="isaidkey"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_partkey}" for="partkey">
  |            <h:inputText value="#{eTDocumentEditor.instance.partkey}" id="partkey" disabled="#{eTDocumentEditor.child}" required="true"/>
  |            <span class="rvgMessage"><h:message for="partkey"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_tsetid}" for="tsetid">
  |            <h:inputText value="#{eTDocumentEditor.instance.tsetid}" id="tsetid" required="true"/>
  |            <span class="rvgMessage"><h:message for="tsetid"/></span>
  |          </h:outputLabel>         
  |          <h:outputLabel value="#{msg.EiTradeDocument_direction}" for="direction">
  |            <h:inputText value="#{eTDocumentEditor.instance.direction}" id="direction" required="true"/>
  |            <span class="rvgMessage"><h:message for="direction"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_partnerGsId}" for="partnerGsId">
  |            <h:inputText value="#{eTDocumentEditor.instance.partnerGsId}" id="partnerGsId"/>
  |            <span class="rvgMessage"><h:message for="partnerGsId"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_burrisGsId}" for="burrisGsId">
  |            <h:inputText value="#{eTDocumentEditor.instance.burrisGsId}" id="burrisGsId"/>
  |            <span class="rvgMessage"><h:message for="burrisGsId"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_loc}" for="loc">
  |            <h:inputText value="#{eTDocumentEditor.instance.loc}" id="loc" required="true"/>
  |            <span class="rvgMessage"><h:message for="loc"/></span>
  |          </h:outputLabel>                  
  |          <h:outputLabel value="#{msg.EiTradeDocument_ediset}" for="ediset">
  |            <h:inputText value="#{eTDocumentEditor.instance.ediset}" id="ediset" required="true"/>
  |            <span class="rvgMessage"><h:message for="ediset"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_rptid}" for="rptid">
  |            <h:inputText value="#{eTDocumentEditor.instance.rptid}" id="rptid"/>
  |            <span class="rvgMessage"><h:message for="rptid"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_tstprod}" for="tstprod">
  |            <h:inputText value="#{eTDocumentEditor.instance.tstprod}" id="tstprod" required="true"/>
  |            <span class="rvgMessage"><h:message for="tstprod"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_billto}" for="billto">
  |            <h:inputText value="#{eTDocumentEditor.instance.billto}" id="billto"/>
  |            <span class="rvgMessage"><h:message for="billto"/></span>
  |          </h:outputLabel>
  |          <h:outputLabel value="#{msg.EiTradeDocument_chrgcode}" for="chrgcode">
  |            <h:inputText value="#{eTDocumentEditor.instance.chrgcode}" id="chrgcode"/>
  |            <span class="rvgMessage"><h:message for="chrgcode"/></span>
  |          </h:outputLabel>
  |          </h:panelGrid>
  |          </s:validateAll>
  |        </span>
  | 
  |        <span class="rvgActions">
  |          <h:commandButton type="submit" value="#{msg.Create}" action="#{eTDocumentEditor.create}" rendered="#{eTDocumentEditor.new}" accesskey="c"><j4j:defaultAction/> </h:commandButton>
  |          <h:commandButton type="submit" value="#{msg.Update}" action="#{eTDocumentEditor.update}" rendered="#{!eTDocumentEditor.new}" accesskey="u"><j4j:defaultAction/> </h:commandButton>
  |          <h:commandButton type="submit" value="#{msg.Delete}" action="#{eTDocumentEditor.delete}" rendered="#{!eTDocumentEditor.new}" accesskey="d"/>
  |          <h:commandButton type="submit" value="#{msg.Done}" action="#{eTDocumentEditor.done}" immediate="true" accesskey="e"/>
  |          <h:commandButton type="submit" value="#{msg.SaveAndCreate} #{msg.EiTradeContact}" action="#{eTDocumentEditor.updateAndCreateChild}" accesskey="s" rendered="#{!eTDocumentEditor.new}"/>
  | 
  |        </span>
  |      
  |      </fieldset>
  |      </div>
  |      
  |     <div class="rvgChildren">
  | 
  | 	 <h2>
  | 	          <h:outputText value="Associated Contacts" rendered="true"/>
  | 	 </h2>
  | 
  | 	 <div class="rvgChildren">
  | 	 <h:outputText value="#{msg.No} #{msg.EiTradeContact} #{msg.MatchedSearchCriteria}" rendered="#{!eTDocumentEditor.hasContacts"/>
  | 
  |    	 <h:dataTable value="#{eTDocumentEditor.contactList}" var="eTContact" rendered="true" 
  | 	       rowClasses="rvgRowOne,rvgRowTwo" headerClass="rvgOrder">
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_contactkey}">
  | 			       <f:param name="orderBy" value="contactkey"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.contactkey}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_name}">
  | 			       <f:param name="orderBy" value="name"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.name}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_atten}">
  | 			       <f:param name="orderBy" value="atten"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.atten}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_addr1}">
  | 			       <f:param name="orderBy" value="addr1"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.addr1}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_addr2}">
  | 			       <f:param name="orderBy" value="addr2"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.addr2}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_addr3}">
  | 			       <f:param name="orderBy" value="addr3"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.addr3}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_city}" >
  | 			       <f:param name="orderBy" value="city"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.city}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_state}" >
  | 			       <f:param name="orderBy" value="state"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.state}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_zip}" >
  | 			       <f:param name="orderBy" value="zip"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.zip}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_phone}" >
  | 			       <f:param name="orderBy" value="phone"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.phone}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_cell}" >
  | 			       <f:param name="orderBy" value="cell"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.cell}"/>
  | 		</h:column>
  | 		<h:column>
  | 			<f:facet name="header">
  | 			    <h:commandLink value="#{msg.EiTradeContact_email}" >
  | 			       <f:param name="orderBy" value="email"/>
  | 			    </h:commandLink>
  | 			</f:facet>
  | 			<h:outputText value="#{eTContact.email}"/>
  | 		</h:column>
  | 
  | 		<h:column>
  | 			<f:facet name="header"><h:outputText value="#{msg.Action}"/></f:facet>
  | 			<h:commandButton action="#{eTDocumentEditor.selectContact}" value="#{eTContactSelector.buttonLabel}"/>
  | 		</h:column>
  | 	 </h:dataTable>
  | 	</div>
  |      </div>	 
  | 
  |     
  |    </h:form>
  | 
  |   </body>
  |  </f:view>
  | </html>
  | 
  | 

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

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



More information about the jboss-user mailing list