[jboss-user] [JBoss Seam] - Re: Merging objects problems.
sjmenden
do-not-reply at jboss.com
Mon Aug 28 10:28:04 EDT 2006
I will post my code to satisfy curiosity although there is not much to look at.
Using Conversation scope seems very strange to me in this instance. I guess SEAM caters to a whole new realm of patterns that don't exist in the other MVC world.
Registering a Group SHOULD be stateless, at least I thought so, but in this case you are saying it should be Conversational. I really don't want any other functionality in this bean at the moment except registering groups. A completely different bean will handle viewing and editing the Group.
RegisterGroupAction.java:
| @Stateless
| @Name("registerGroup")
| public class RegisterGroupAction implements RegisterGroup {
|
| @In(create=true) @Out @Valid
| private Group group;
|
| @PersistenceContext
| private EntityManager em;
|
| @Logger
| private Log log;
|
| public String register() {
| List existing = em.createQuery("select name from Group where name = :name")
| .setParameter("name", group.getName())
| .getResultList();
| if (existing.size()==0) {
| //group = em.merge(group);
| em.persist(group);
|
|
|
| FacesMessages.instance().add("Group successfully created");
| log.info("Registered new Group #{group.name} with id: " + group.getGroupId());
| return "/showGroup.jsp";
| } else {
| FacesMessages.instance().add("Group name already exists, please choose another");
| return null;
| }
| }
| }
|
registerGroup.jsp - the commandButton is only relevant I think
| ...
| ...
| ...
| <h:commandButton type="submit" value="Greate Group" action="#{registerGroup.register}"/>
| ...
| ...
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967830#3967830
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967830
More information about the jboss-user
mailing list