This is the parent code:

@Stateful
@Name("eventTypeUpdate")
@Conversational(ifNotBegunOutcome = "eventtypefind")
@LoggedIn
public class EventTypeUpdateAction implements EventTypeUpdate {

        @PersistenceContext
        private EntityManager em;

        @In(required = false)
        @Out
        private EventType eventType;

        @In(create = true)
        private transient FacesMessages facesMessages;

        @In(create = true)
        private transient Events events;

        @In
        private EventTypeFind eventTypeFind = null;

        @Begin
        public String selectEventType() {
                this.eventType = this.eventTypeFind.getSelectedEventType();
                return "eventtypeupdate";
        }

        @End
        public String cancel() {
                return "eventtypefind";
        }

        @End
        public String update() {
                List existing = em.createQuery(
                                "select name from EventType where name=:name 
and id <> :id")
                                .setParameter("name", 
eventType.getName()).setParameter("id",
                                                
eventType.getId()).getResultList();
                if (existing.size() == 0) {
                        em.merge(this.eventType);
                        Events.instance().raiseEvent("eventTypeUpdate");
                        return "eventtypefind";
                } else {
                        facesMessages.add("An Event Type already exists with 
name #{eventtype.name}");
                        return null;
                }
        }

        public String newEventTypeRole() {
                EventTypeRole etr = new EventTypeRole();
                this.eventType.getEventTypeRoles().add(etr);
                etr.setEventType(this.eventType);
                return "eventtypeupdate";
        }

        public int getEventTypeRolesNo() {
                return this.eventType.getEventTypeRoles().size();
        }

        @DataModel
        public List getEventTypeRoles() {
                if (this.eventType == null || 
this.eventType.getEventTypeRoles() == null)
                        return new ArrayList();
                return this.eventType.getEventTypeRoles();
        }

        @DataModelSelection
        private EventTypeRole selectedEventTypeRole;

        public EventTypeRole getSelectedEventTypeRole() {
                return this.selectedEventTypeRole;
        }

        public String deleteEventTypeRole() {
                if 
(this.eventType.getEventTypeRoles().contains(this.getSelectedEventTypeRole())) {
                        EventTypeRole etr = this.getSelectedEventTypeRole();
                        if (etr.getId() != null && etr.getId() > 0)
                                em.remove(etr);
                        this.eventType.getEventTypeRoles().remove(etr);
                        em.merge(this.eventType);
                }
                return "eventtypeupdate";
        }       
        
        @Destroy
        @Remove
        public void destroy() {
        }
}


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

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


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to