[JBoss Seam] - Unique validation?
by andrew.rw.robinson
I would like to have unique validation for a user object's username in a JSF page. Ideally, it will create a faces message and mark the UI input component as not valid when not unique. It should allow the value if the object is the same and the property hasn't changed (the user found in the database is the current user)
The EBQL:
select u from User u where u.username = :username
I tried to create a validation method on my session bean, but Seam's exception filter caught my ValidationException and threw up an error page instead of letting the validation error pass through.
I also though of creating a JSF validator or a hibernate validator, but neither let me access the object, only the value (so I can't check if the username already belongs to the current user).
I don't want to put this code in my action method if I can help it as that would cause the error to only appear after all validations pass and I don't want the user to enter everything, clear all validation messages then get one more.
Has anyone done this, or does anyone have a good way of implementing this?
Here is the code I started for the hibernate validator, but got stuck at the "TODO":
@ValidatorClass(CompareToValidator.class)
| @Target({ElementType.METHOD, ElementType.FIELD})
| @Retention(RetentionPolicy.RUNTIME)
| @Documented
| public @interface Unique
| {
| String ebql();
| String paramName() default "value";
| String message() default "{valid.unique}";
| }
|
public class UniqueValidator
| implements Serializable, Validator<Unique>
| {
| private String ebql;
| private String paramName;
|
| /**
| * @see org.hibernate.validator.Validator#initialize(A)
| */
| public void initialize(Unique parameters)
| {
| ebql = parameters.ebql();
| paramName = parameters.paramName();
| }
|
| /**
| * @see org.hibernate.validator.Validator#isValid(java.lang.Object)
| */
| public boolean isValid(Object value)
| {
| UserTransaction utx = null;
| try { utx = Transactions.getUserTransaction(); } catch (NamingException ex) { return false; }
|
| try
| {
| utx.begin();
| utx.setRollbackOnly();
| EntityManager entityManager = null;
|
| entityManager = (EntityManager)
| Naming.getInitialContext().lookup("java:/entityManager");
| Query query = entityManager.createQuery(ebql).setParameter(paramName, value);
|
| List<?> list = query.getResultList();
| if (list.isEmpty()) return true;
|
| // TODO: validate the user is not the same
|
| return false;
| }
| catch (Exception ex)
| {
| try { utx.rollback(); } catch (Exception ex2) {}
| }
| return false;
| }
| }
@AccessType("field")
| @Entity
| @Table(name="site_user")
| @Name("user")
| @Scope(ScopeType.SESSION)
| @SequenceGenerator(name="seq", sequenceName="site_user_seq")
| public class User
| implements Serializable, Comparable<User>
| {
| // Fields
| @Id
| @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
| private Integer id;
|
| @Basic
| @NotNull(message="{valid.user.username.notnull}")
| @Length(max=25,min=4,message="{valid.user.username.length}")
| @Unique(ebql="select u from User where u.username = :value")
| private String username;
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962357#3962357
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962357
18 years, 5 months
[JBoss jBPM] - Re: clean handoff
by genman
I have a general sense of agreement with what you wrote, since I've worked with process editors at m-Qube and we've taken a similar approach. See http://m-qube.com/html/prodServ/studio.html
One interesting thing is the editor tool is a Java applet and the process logic is stored on the server. Having the tool done as an applet means the business users always can access tools. Hosting the code on the server also means the user has the latest version of the tool.
Also, as a business tool, controlled content management of the "flow" is important. There are ways to schedule deployment and test new process flows with the tool. This can only really done by using a centralized server.
As an aside, I see a bit of long-term synergy with rules engines and process management. I wonder if you can explain what is being done to integrate Drools and jBPM at the tool level?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962356#3962356
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962356
18 years, 5 months
[JBossCache] - Eviction Policy and configuration issues
by Spievak
Hi, i´m having some problems with cache eviction. I have used the TreeCache implementation with the following configuration:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <server>
|
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
|
| <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
|
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
|
| <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
| <attribute name="CacheMode">LOCAL</attribute>
|
| <!-- Name of the eviction policy class. -->
| <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
| <!-- Specific eviction policy configurations. This is LRU -->
| <attribute name="EvictionPolicyConfig">
| <config>
| <attribute name="wakeUpIntervalSeconds">5</attribute>
| <!-- Cache wide default -->
| <region name="/_default_">
| <attribute name="maxNodes">1000</attribute>
| <attribute name="timeToLiveSeconds">10</attribute>
| </region>
| <region name="/teste">
| <attribute name="maxNodes">1000</attribute>
| <attribute name="timeToLiveSeconds">10</attribute>
| </region>
| </config>
| </attribute>
| </mbean>
| </server>
|
I was expecting that with this config nodes with live greater than 10 seconds be collected by LRU policy and the be throwed away since there is not CacheLoader assigned.
But the node remains in cache after the assigned time.
the code used for testing:
| cache.put(new Fqn(new Object[] { "/test", 1 }), "item", "1");
| Thread.currentThread().sleep(30000);
| System.out.println(cache.get(new Fqn(new Object[] { "/test", 1}), "item"));
|
Since the node was not removed i try removing it in code, as:
cache.put(new Fqn(new Object[] { "/test", 1 }), "item", "1");
| cache.remove(new Fqn(new Object[] { "/teste", 1 }));
| Thread.currentThread().sleep(30000);
| System.out.println(cache.get(new Fqn(new Object[] { "/test", 1}), "item"));
And again the node remains in cache.
Any suggestions ???
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962354#3962354
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962354
18 years, 5 months
[JBossWS] - Incomplete Deployment when EJB turn into webservices
by gurjeetjsr@jboss.com
i converted EJB to webservices when i am runing jboss-4.0.2, at the time of deployment jboss successfully deploy all EJBs except that EJB, which i converted into webservices. it shows in log
16:15:54,421 INFO [EjbModule] Deploying ITransferMgr
16:15:54,437 INFO [EjbModule] Deploying IMMaintMgr
16:16:01,796 ERROR [StatelessSessionContainer] Initialization failed jboss.j2ee:
jndiName=WireCtlr,service=EJB
java.lang.NoSuchMethodException: Not found in bean class: public abstract void j
avax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.RemoveExce
ption
at org.jboss.ejb.SessionContainer.setUpBeanMappingImpl(SessionContainer.
--------------------------------------------------------------------
but my WSDL published successfully, it shows in log
---------------------------------------------------------------------
16:16:32,125 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.0.2/server/default/d
eploy/datamate.jar
16:16:36,156 INFO [WSDLFilePublisher] WSDL published to: file:/D:/jboss-4.0.2/s
erver/default/data/wsdl/datamate.jar/WireCtlr.wsdl
16:16:37,125 INFO [AxisService] WSDD published to: D:\jboss-4.0.2\server\defaul
t\data\wsdl\datamate.jar\WireCtlr.wsdd
16:16:39,484 INFO [AxisService] Web Service deployed: http://datav1:8080/datama
te/WireCtlr
---------------------------------------------------
and at last server is showing
---------------------------------------------------
16:17:23,359 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:jndiName=WireCtlr,service=EJB
State: FAILED
Reason: java.lang.NoSuchMethodException: Not found in bean class: public abstr
act void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.
RemoveException
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:jndiName=WireCtlr,service=EJB
State: FAILED
Reason: java.lang.NoSuchMethodException: Not found in bean class: public abstr
act void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.
RemoveException
16:17:28,437 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-808
0
16:17:30,984 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
16:17:31,046 INFO [JkMain] Jk running ID=0 time=0/203 config=null
16:17:31,109 INFO [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4
_0_2 date=200505022023)] Started in 3m:5s:0ms
----------------------------------------------------------------------
i have given
<service-endpoint>dm.ejb.common.WireCtlr</service-endpoint> in ejb-jar.xml for that EJB.
anybody can tell me why i am getting that error, why my ejb get failed to deploy.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962353#3962353
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962353
18 years, 5 months
[JBossWS] - Incomplete Deployment when EJB turn into webservices
by gurjeetjsr@jboss.com
i converted EJB to webservices when i am runing jboss-4.0.2, at the time of deployment jboss successfully deploy all EJBs except that EJB, which i converted into webservices. it shows in log
16:15:54,421 INFO [EjbModule] Deploying ITransferMgr
16:15:54,437 INFO [EjbModule] Deploying IMMaintMgr
16:16:01,796 ERROR [StatelessSessionContainer] Initialization failed jboss.j2ee:
jndiName=WireCtlr,service=EJB
java.lang.NoSuchMethodException: Not found in bean class: public abstract void j
avax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.RemoveExce
ption
at org.jboss.ejb.SessionContainer.setUpBeanMappingImpl(SessionContainer.
--------------------------------------------------------------------
but my WSDL published successfully, it shows in log
---------------------------------------------------------------------
16:16:32,125 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.0.2/server/default/d
eploy/datamate.jar
16:16:36,156 INFO [WSDLFilePublisher] WSDL published to: file:/D:/jboss-4.0.2/s
erver/default/data/wsdl/datamate.jar/WireCtlr.wsdl
16:16:37,125 INFO [AxisService] WSDD published to: D:\jboss-4.0.2\server\defaul
t\data\wsdl\datamate.jar\WireCtlr.wsdd
16:16:39,484 INFO [AxisService] Web Service deployed: http://datav1:8080/datama
te/WireCtlr
---------------------------------------------------
and at last server is showing
---------------------------------------------------
16:17:23,359 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:jndiName=WireCtlr,service=EJB
State: FAILED
Reason: java.lang.NoSuchMethodException: Not found in bean class: public abstr
act void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.
RemoveException
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:jndiName=WireCtlr,service=EJB
State: FAILED
Reason: java.lang.NoSuchMethodException: Not found in bean class: public abstr
act void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.
RemoveException
16:17:28,437 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-808
0
16:17:30,984 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
16:17:31,046 INFO [JkMain] Jk running ID=0 time=0/203 config=null
16:17:31,109 INFO [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4
_0_2 date=200505022023)] Started in 3m:5s:0ms
----------------------------------------------------------------------
i have given
<service-endpoint>dm.ejb.common.WireCtlr</service-endpoint> in ejb-jar.xml for that EJB.
anybody can tell me why i am getting that error, why my ejb get failed to deploy.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962352#3962352
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962352
18 years, 5 months