[jboss-user] [JBoss Seam] - Re: DataModel sincronization issue...

angelogalvao do-not-reply at jboss.com
Mon Aug 7 08:23:22 EDT 2006


public class SystemRoleGroupManagerBean implements SystemRoleGroupManager, Serializable{	
  | 	
  | 	@PersistenceContext(type=PersistenceContextType.EXTENDED)
  | 	private EntityManager entityManager;
  | 	
  |        ......	
  | 
  | 	// inject by Seam	
  | 	
  | 	@In(required=false)
  | 	@Out(required=false)
  | 	private RoleGroup roleGroup;
  | 
  | 	@DataModelSelection(value="rolesFromRoleGroup")
  | 	private Role role;
  | 	
  | 	// data models
  | 
  | 	@DataModel
  | 	private Set<Role> rolesFromRoleGroup;
  | 	
  | 	@SelectItems(labelMethod="getNome")	
  | 	private List<Role> roless; // lista de permissões	
  | 	
  | 	// factory methods
  | 	
  | 	@Factory("rolesFromRoleGroup")
  | 	@Observer("rolesFromRoleGroupChange")
  | 	public void listRolesFromRoleGroup(){
  | 		if(this.roleGroup!=null){
  | 			rolesFromRoleGroup =  roleGroup.getRoles();
  | 		}
  | 	}
  | 	
  | 	@Factory("roless")
  | 	public void listRoles() {
  | 		roless = entityManager.createQuery("from Role order by :nome").setParameter("nome", "nome").getResultList();		
  | 	}	
  | 	
  | 	// metodos de negocio
  | 	
  | 	@End
  | 	public void addRoleGroup() {
  | 		if(roleGroup.getId()!=null)
  | 			updateUsuariosWithRoleGroup(roleGroup);
  | 		roleGroup = entityManager.merge(roleGroup);	// save or updates
  | 	}	
  | 	
  | 	/**
  | 	 * Sincronizar os papeis dos usuarios com o grupo. 
  | 	 * @param roleGroup grupo de permissões
  | 	 */
  | 	private void updateUsuariosWithRoleGroup(RoleGroup roleGroup){
  | 	}
  | 
  | 	@Begin(join=true)
  | 	public void addRoleToRoleGroup() {		
  | 		// o index é o index da listagem. 
  | 		// TODO para @Selectable ou @SelectItemsSelection quando implementarem essa solução.				
  | 		Role _role = roless.get(index);
  | 		roleGroup.addRole(_role);		
  | 		Events.instance().raiseEvent("rolesFromRoleGroupChange");
  | 	}
  | 	
  | 	@Begin(join=true)	
  | 	public void removeRoleFromRoleGroup() {		
  | 		 roleGroup.removeRole(role);
  | 		 Events.instance().raiseEvent("rolesFromRoleGroupChange");
  | 	}
  | 	
  | 	// destroy method
  | 	
  | 	@Remove @Destroy
  | 	public void destroy(){}	
  | }

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

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




More information about the jboss-user mailing list