[JBoss Seam] - Re: Object level validation
by norman.richards@jboss.com
You can easily add extra conditions:
| @AssertTrue(message="second number must be larger than the first")
| public boolean checkNumbers() {
| System.out.println("number1=" + number1 + " number2=" + number2);
| return number2 > number1;
| }
|
Hibernate will check the condition at persist() time. Unfortunately, it doesn't handle it a way that is very friendly to your application. (from the perspective of being transparent) You'll have to add a bit of code to the application for that. Here's an overridden persist on EntityHome:
| @Transactional
| @Override
| public String persist()
| {
| ClassValidator validator = Validators.instance().getValidator(YourEntity.class, "yourEntity");
| InvalidValue[] ivs = validator.getInvalidValues(getInstance());
| if (ivs.length>0) {
| facesMessages.add(ivs);
| return null;
| }
|
| return super.persist();
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996766#3996766
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996766
17 years, 8 months
[JBoss Seam] - Re: Road Map
by perwik
I just took a look at Seam in the CVS and after going through the seamspace example I can't say anything else than:
I love you guys! :-)
I've been putting off this project for a long time in lack of a good security implementation and now you've solved a lot of my problems.
I know you've planned to work on the security release for at least three more weeks (according to http://jira.jboss.com/jira/browse/JBSEAM?report=com.atlassian.jira.plugin...) but I've got something that you might not have thought of:
In security-config.xml you specify roles and assign permissions to them. What I would like is to specify somewhere which permissions exists and what actions they can have. Something like:
| <permissionDefinition>
| <name>user</name>
|
| <action>create</action>
| <action>modify</action>
| <action>delete</action>
| </permissionDefinition>
|
| <permissionDefinition>
| <name>account</name>
|
| <action>create</action>
| <action>delete</action>
| </permissionDefinition>
|
and then I could assign them to roles in the security-config OR I could create roles on the fly from the application and pick permissions from some sort of gui based on the initial permissions definition. Perhaps this sound totally crazy, or you've already done it, what do I know :-)
An other thing that I came to think of:
Now the permissions store their name and action as strings. Wouldn't the use of enums or something else that is typesafe make life easier for us? I'd hate to have a bug where I misspelled one of the strings somewhere. Or did I miss something?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996763#3996763
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996763
17 years, 8 months
[JBoss Seam] - messages example: import.sql is faulty
by Eekboom
Seam 1.1.0.GA, JBoss 4.0.5.GA
Currently deployment fails with this exception:
Caused by: java.sql.SQLException: Wrong data type: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
| at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
| at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
| at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source)
| at org.jboss.resource.adapter.jdbc.WrappedStatement.execute(WrappedStatement.java:84)
| at org.hibernate.tool.hbm2ddl.SchemaExport.importScript(SchemaExport.java:254)
The import.sql reads:
insert into Message (title, text, read, datetime) values ('Hello World', 'This is an example of a message.', 0, '2006-1-1 11:12')
| insert into Message (title, text, read, datetime) values ('Greetings Earthling', 'This is another example of a message.', 0, '2006-2-4 03:04')
It works after changing it to
insert into Message (title, text, read, datetime) values ('Hello World', 'This is an example of a message.', 0, '2006-01-01 11:12:00')
| insert into Message (title, text, read, datetime) values ('Greetings Earthling', 'This is another example of a message.', 0, '2006-02-04 03:04:00')
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996761#3996761
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996761
17 years, 8 months
[JBoss Seam] - Validation fails in registration example
by Eekboom
Seam 1.1.0 GA
Built registration example with ant, deployed to JBoss AS 4.0.5.
When I leave the password field empty I get a message "Validation Error" as expected.
However if I enter one to four characters, I get a nasty exception:
01:48:04,593 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
| javax.faces.FacesException: Error calling action method of component with id _idJsp0:_idJsp5
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
| at javax.faces.component.UICommand.broadcast(UICommand.java:106)
| at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
| at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
| at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:619)
| Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{register.register}
| at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:59)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
| ... 25 more
| Caused by: java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DG7F132J/19, BranchQual=, localId=19
| ] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.ex
| ample.registration.User)
| at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
| at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
| at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
| at $Proxy87.register(Unknown Source)
| at org.jboss.seam.example.registration.Register$$FastClassByCGLIB$$46e07125.invoke(<generated>)
| at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
| at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:73)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
| at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
| at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
| at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:82)
| at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:51)
| at org.jboss.seam.example.registration.Register$$EnhancerByCGLIB$$8aa421a0.register(<generated>)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
| ... 28 more
| Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=DG7F132J/19, BranchQual=, localId=19] status=STATUS_NO_TRANSACTI
| ON; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User)
| at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
| at org.jboss.tm.TxManager.commit(TxManager.java:240)
| at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
| ... 69 more
| Caused by: javax.persistence.PersistenceException: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User
| at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:527)
| at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
| at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
| at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
| ... 71 more
| Caused by: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.User
| at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:132)
| at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:156)
| at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:139)
| at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:44)
| at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
| at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
| at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
| at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
| ... 74 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996758#3996758
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996758
17 years, 8 months