[jboss-user] [JBoss Seam] - Update Data Model from another Bean

indyJones do-not-reply at jboss.com
Wed Dec 12 09:41:36 EST 2007


I have a Data Model and some input boxes on a page.

Select a record from the Data Model and the input boxes is populated with the records information.

Change the data in the input boxes and hit a "Update" button.

Update the record in the database and then reload the Data Model.

All this works great except the reloading of the Data Model...

Here is the code...

Bean Responsible for the Data Model


  | 
  | @Name("getusers")
  | @Scope(PAGE)
  | @Restrict("#{identity.loggedIn}")
  | public class GetUsersAction {
  | 
  | 
  | 	@DataModel
  | 	private List<User> users2;
  | 
  | 	@Factory("users2") 
  | 	public List<User> getUsers2() { ... }
  | 
  | 
  | }
  | 
  | 

Bean Responsible for updating the record...


  | 
  | @Name("updateuser")
  | @Stateful
  | @Scope(EVENT)
  | @Restrict("#{identity.loggedIn}")
  | public class UpdateUserAction implements UpdateUserActionInterface {
  | 
  | 	
  | 	public void updateUser() { ... }
  | 
  | }
  | 
  | 

And the web page...


  | 
  | <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | 
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:s="http://jboss.com/products/seam/taglib"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:f="http://java.sun.com/jsf/core"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |  				xmlns:a4j="http://richfaces.org/a4j"
  | 				xmlns:rich="http://richfaces.org/rich"
  |                 template="layout/template.xhtml">
  | 
  | 	<ui:define name="body">
  | 
  | 		<h:form>
  | 			
  | 			<a4j:region>
  | 			
  | 				<rich:dataTable id="tblUsers" var="varUser" value="#{users2}" >
  | 
  | 					....
  | 
  | 				</rich:dataTable>
  | 
  | 			</a4j:region>
  | 			
  | 			<a4j:commandButton value="Update" action="#{updateuser.updateUser()}" ></a4j:commandButton>
  | 			
  | 			<h:inputText value="#{currentUser.firstname}"></h:inputText>	
  | 			
  | 		</h:form>
  | 		
  | 	</ui:define>
  | 	
  | </ui:cocmposition>
  | 
  | 

The question is, how do I update the Data Model (users2) from the updateuser Bean after the updateUser method has completed?

I don't want to Inject and Outject it....

Thanks

indy

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

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



More information about the jboss-user mailing list