[jboss-user] [JBoss Seam] - Update transactions occurring prematurely in Seam app

asookazian do-not-reply at jboss.com
Tue Dec 18 12:09:43 EST 2007


This may be a EntityManager flush issue but not sure...

I have the following xhtml for a Seam2.0.0.GA web app backed by 2 SFSB's (one conversation scoped and the other session scoped).  The problem is when user clicks 'yes' for any radio button in any row of the form/dataTable, an update transaction is persisted to the database for that row/column.  The update should only happen when user clicks submit in one of the rich:modalPanel forms.

I've ran this test case thru the debugger several times and the submit method is not being called.  I'm thinking the EntityManager/PersistenceContext is being automatically flushed somehow but not sure if or when this is happening.  I did remove the a4j:support tag for one of the columns and moved the js function call to onclick event handler.  The table did not get updated like before.  So somehow the a4j:support is causing this to happen I think...

Any hints?  thx.

<h:form id="mainForm">
  | 	    		     	    		 
  | 	    		<h:outputText value="No Direct Reports" rendered="#{myAuditList != null and myAuditList.rowCount==0}"/>
  | 			 	<h:dataTable id="dataTable1" value="#{myAuditList}" var="myRow" rendered="#{myAuditList != null and myAuditList.rowCount > 0}"
  | 			 				 styleClass="dataTable" rowClasses="oddRow, evenRow" frame="hsides">
  | 			 		<h:column>
  | 			 			<f:facet name="header">Status</f:facet>
  | 			 			
  | 			 			<h:graphicImage id="statusImage" value="#{securityAuditAction.processGraphicImage(myRow[1].auditProgress)}"/>		    							
  | 			 		</h:column>
  | 		    		<h:column>
  | 			    		<f:facet name="header">Employee Name</f:facet>	    		
  | 			    		
  | 			    		<!-- siteId and employeeNumber hidden fields are used for all radio buttons -->
  | 			    		<h:outputText id="employeeName" value="#{myRow[0].id.employeeName}"/>		 
  | 			    		<h:inputHidden id="employeeNameHidden" value="#{myRow[0].id.employeeName}"/>  		    		
  | 			    		<h:inputHidden id="siteId" value="#{myRow[0].id.siteId}"/> 		
  | 			    		<h:inputHidden id="employeeNumber" value="#{myRow[0].id.employeeNumber}"/>
  | 		    		</h:column>
  | 		    		
  | 		    		<h:column>
  | 			    		<f:facet name="header">SiteId</f:facet>	    		
  | 			    		
  | 			    		<h:outputText value="#{myRow[0].id.siteId}"/>		   		    		
  | 		    		</h:column>
  | 		    		
  | 		    		<h:column>
  | 			    		<f:facet name="header">EmployeeNumber</f:facet>	    		
  | 			    		
  | 			    		<h:outputText value="#{myRow[0].id.employeeNumber}"/>		   		    		
  | 		    		</h:column>
  | 		    		
  | 		    		<h:column>
  | 			    		<f:facet name="header">Adjustment Limit</f:facet>	    		
  | 			    		
  | 			    		<h:outputText value="#{myRow[0].id.employeeNumber}"/>		   		    		
  | 		    		</h:column>
  | 		    				    
  | 		    		 		
  | 	    		    	<h:column>
  | 			    			<f:facet name="header">Account Approved?</f:facet>		    					    	
  | 		    					
  | 		    					<h:panelGrid columns="2">
  | 					    			<h:selectOneRadio id="accountApprovedRB" value="#{myRow[1].icomsAccountApproved}">		
  | 					    			     							  
  | 					    				<a4j:support event="onclick" 
  | 					    						     oncomplete="processNote(#{myAuditList.getRowIndex()}, 'accountApproved')"
  | 					    						     action="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'accountApproved', myAuditList)}"
  | 					    						     ajaxSingle="true"
  | 					    						     reRender="mainForm"/>
  | 					    			      
  | 										<f:selectItems value="#{securityAuditAction.securityAuditRadioButtons}" />
  | 									</h:selectOneRadio>
  | 									
  | 									<h:graphicImage  id="acctGraphic" value="/img/icon_edit.gif"
  | 					    							 rendered="#{noteAction.getRenderNoteGraphic(myAuditList.getRowIndex(), 'accountApproved') || 
  | 					    						     			securityAuditAction.getLoadedNote(myAuditList.getRowIndex(), 'accountApproved')}">
  | 					    				<a4j:support event="onclick"
  | 					    							 onclick="editNote(#{myAuditList.getRowIndex()}, 'accountApproved')"  
  | 					    							 actionListener="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'accountApproved', myAuditList)}"/>
  | 					    			</h:graphicImage>  
  | 					    		</h:panelGrid>
  | 			    		</h:column>
  | 			    		
  | 			    		
  | 			    		<h:column>
  | 			    			<f:facet name="header">Security Level Approved?</f:facet>
  | 			    			
  | 			    			<h:panelGrid columns="2">
  | 				    			<h:selectOneRadio id="securityLevelApprovedRB" value="#{myRow[1].securityLevelApproved}"			    							  	    							  
  | 				    							  rendered="#{noteAction.getRenderRadioButtons(myAuditList.getRowIndex())}">
  | 				    					<a4j:support event="onclick" 
  | 					    						     oncomplete="processNote(#{myAuditList.getRowIndex()}, 'secLevelApproved')"
  | 					    						     action="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'secLevelApproved', myAuditList)}"/>     		    						
  | 									<f:selectItems value="#{securityAuditAction.securityAuditRadioButtons}" />
  | 								</h:selectOneRadio>									 
  | 								<h:graphicImage id="securityLevelGraphic" value="/img/icon_edit.gif"												
  | 												rendered="#{noteAction.getRenderNoteGraphic(myAuditList.getRowIndex(), 'secLevelApproved') || 
  | 				    						     			securityAuditAction.getLoadedNote(myAuditList.getRowIndex(), 'secLevelApproved')}"> 
  | 				    				<a4j:support event="onclick"		
  | 				    							 onclick="editNote(#{myAuditList.getRowIndex()}, 'secLevelApproved')"	
  | 				    							 action="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'secLevelApproved', myAuditList)}"				    							
  | 				    							 reRender="out3"
  | 				    							 />
  | 				    			</h:graphicImage>								    	
  | 							</h:panelGrid>   			
  | 			    		</h:column>
  | 			    		
  | 			    		
  | 			    		<h:column>
  | 			    			<f:facet name="header">Adjustment Limit Approved?</f:facet>
  | 			    			
  | 			    			<!-- <h:panelGrid columns="2">  -->
  | 			    			<h:panelGrid columns="3">
  | 				    			<h:selectOneRadio id="adjustmentLimitApprovedRB" value="#{myRow[1].adjustmentLimitApproved}"
  | 				    							  rendered="#{noteAction.getRenderRadioButtons(myAuditList.getRowIndex())}">  
  | 										<a4j:support event="onclick" 
  | 					    						     oncomplete="processNote(#{myAuditList.getRowIndex()}, 'adjLimitApproved')"
  | 					    						     action="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'adjLimitApproved', myAuditList)}"/>        
  | 									<f:selectItems value="#{securityAuditAction.securityAuditRadioButtons}" />
  | 								</h:selectOneRadio>	  
  | 								<h:graphicImage id="adjLimitGraphic" value="/img/icon_edit.gif"
  | 												rendered="#{noteAction.getRenderNoteGraphic(myAuditList.getRowIndex(), 'adjLimitApproved') || 
  | 					    						     			securityAuditAction.getLoadedNote(myAuditList.getRowIndex(), 'adjLimitApproved')}">
  | 					    						<a4j:support event="onclick"		
  | 					    							 oncomplete="editNote(#{myAuditList.getRowIndex()}, 'adjLimitApproved')"	
  | 					    							 actionListener="#{noteAction.setCurrentData(myAuditList.getRowIndex(), 'adjLimitApproved', myAuditList)}"
  | 					    							 reRender="mpNoteAndEmployeeSubmit"/>
  | 					    		</h:graphicImage>     			  	
  | 					    		<h:commandButton id="submitEmployee" value="Submit" actionListener="#{securityAuditAction.submit}" style="visibility:hidden"/>
  | 							</h:panelGrid>
  | 			    		</h:column>
  | 		    					    
  | 		    	</h:dataTable>
  | 		    			    		    	
  | 		</h:form>

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

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



More information about the jboss-user mailing list