[jboss-cvs] jboss-seam/src/main/org/jboss/seam/framework ...
Gavin King
gavin.king at jboss.com
Mon Oct 30 23:38:38 EST 2006
User: gavin
Date: 06/10/30 23:38:38
Modified: src/main/org/jboss/seam/framework EntityHome.java
HibernateEntityHome.java Home.java
Log:
fix page bundle stuff
use resource bundle messages in fwk
Revision Changes Path
1.8 +3 -8 jboss-seam/src/main/org/jboss/seam/framework/EntityHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EntityHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/EntityHome.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- EntityHome.java 15 Oct 2006 21:54:49 -0000 1.7
+++ EntityHome.java 31 Oct 2006 04:38:38 -0000 1.8
@@ -3,9 +3,7 @@
import javax.persistence.EntityManager;
import org.jboss.seam.Component;
-import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Transactional;
-import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.persistence.PersistenceProvider;
public class EntityHome<E> extends Home<E>
@@ -22,9 +20,6 @@
}
}
- @In(create=true)
- private FacesMessages facesMessages;
-
@Transactional
public boolean isManaged()
{
@@ -37,7 +32,7 @@
{
getEntityManager().joinTransaction();
getEntityManager().flush();
- facesMessages.add( getUpdatedMessage() );
+ updatedMessage();
return "updated";
}
@@ -48,7 +43,7 @@
getEntityManager().persist( getInstance() );
getEntityManager().flush();
setId( PersistenceProvider.instance().getId( getInstance(), getEntityManager() ) );
- facesMessages.add( getCreatedMessage() );
+ createdMessage();
return "persisted";
}
@@ -58,7 +53,7 @@
getEntityManager().joinTransaction();
getEntityManager().remove( getInstance() );
getEntityManager().flush();
- facesMessages.add( getDeletedMessage() );
+ deletedMessage();
return "removed";
}
1.5 +5 -10 jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityHome.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HibernateEntityHome.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/HibernateEntityHome.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- HibernateEntityHome.java 25 Oct 2006 15:14:35 -0000 1.4
+++ HibernateEntityHome.java 31 Oct 2006 04:38:38 -0000 1.5
@@ -4,17 +4,12 @@
import org.hibernate.Session;
import org.jboss.seam.Component;
-import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Transactional;
-import org.jboss.seam.core.FacesMessages;
public class HibernateEntityHome<E> extends Home<E>
{
private Session session;
- @In(create=true)
- private FacesMessages facesMessages;
-
@Override
public void validate()
{
@@ -36,7 +31,7 @@
public String update()
{
getSession().flush();
- facesMessages.add( getUpdatedMessage() );
+ updatedMessage();
return "updated";
}
@@ -46,7 +41,7 @@
getSession().persist( getInstance() );
getSession().flush();
setId( getSession().getIdentifier( getInstance() ) );
- facesMessages.add( getCreatedMessage() );
+ createdMessage();
return "persisted";
}
@@ -55,7 +50,7 @@
{
getSession().delete( getInstance() );
getSession().flush();
- facesMessages.add( getDeletedMessage() );
+ deletedMessage();
return "removed";
}
1.7 +44 -1 jboss-seam/src/main/org/jboss/seam/framework/Home.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Home.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Home.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Home.java 20 Oct 2006 00:35:34 -0000 1.6
+++ Home.java 31 Oct 2006 04:38:38 -0000 1.7
@@ -1,5 +1,7 @@
package org.jboss.seam.framework;
+import static javax.faces.application.FacesMessage.SEVERITY_INFO;
+
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -7,9 +9,11 @@
import javax.annotation.PostConstruct;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.core.AbstractMutable;
+import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.core.Expressions.ValueBinding;
/**
@@ -30,6 +34,24 @@
private String createdMessage = "Successfully created";
private String updatedMessage = "Successfully updated";
+ @In(create=true)
+ private FacesMessages facesMessages;
+
+ protected void updatedMessage()
+ {
+ facesMessages.addFromResourceBundle( SEVERITY_INFO, getUpdatedMessageKey(), getUpdatedMessage() );
+ }
+
+ protected void deletedMessage()
+ {
+ facesMessages.addFromResourceBundle( SEVERITY_INFO, getDeletedMessageKey(), getDeletedMessage() );
+ }
+
+ protected void createdMessage()
+ {
+ facesMessages.addFromResourceBundle( SEVERITY_INFO, getCreatedMessageKey(), getCreatedMessage() );
+ }
+
@PostConstruct
public void validate()
{
@@ -182,4 +204,25 @@
this.updatedMessage = updatedMessage;
}
+ protected String getMessageKeyPrefix()
+ {
+ String className = getEntityClass().getName();
+ return className.substring( className.lastIndexOf('.') + 1 ) + '_';
+ }
+
+ protected String getCreatedMessageKey()
+ {
+ return getMessageKeyPrefix() + "created";
+ }
+
+ protected String getUpdatedMessageKey()
+ {
+ return getMessageKeyPrefix() + "updated";
+ }
+
+ protected String getDeletedMessageKey()
+ {
+ return getMessageKeyPrefix() + "deleted";
+ }
+
}
More information about the jboss-cvs-commits
mailing list