[jboss-user] [JBoss Seam] - Re: PhaseListener in Seam 2.0

wachtda do-not-reply at jboss.com
Tue Jan 22 02:14:09 EST 2008


Thank you for the hint with the observer.
I'm created a Seam-Component with a observer for org.jboss.seam.beforePhase.

It works, but I get always an error:


  | 08:13:04,936 ERROR [STDERR] java.lang.NullPointerException
  | 08:13:04,937 ERROR [STDERR]     at com.solarmax.scratchbook.action.TrimUIInputStrings.beforePhase(TrimUIInputStrings.java:24 )
  | 08:13:04,937 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 08:13:04,937 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 08:13:04,938 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 08:13:04,938 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:585)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:4 2)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java :155)
  | 08:13:04,938 ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
  | 08:13:04,938 ERROR [STDERR]     at com.solarmax.scratchbook.action.TrimUIInputStrings_$$_javassist_2.beforePhase(TrimUIInput Strings_$$_javassist_2.java)
  | 08:13:04,938 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 08:13:04,938 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 08:13:04,939 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 08:13:04,939 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:585)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.Component.callComponentMethod(Component.java:2078)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.jsf.SeamPhaseListener.raiseEventsBeforePhase(SeamPhaseListener.java:381)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
  | 08:13:04,939 ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
  | 08:13:04,939 ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
  | 08:13:04,939 ERROR [STDERR]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
  | 08:13:04,939 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:290)
  | 08:13:04,939 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  | 08:13:04,939 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
  | 08:13:04,940 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,940 ERROR [STDERR]     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
  | 08:13:04,940 ERROR [STDERR]     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:235)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:235)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 08:13:04,941 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.ja va:179)
  | 08:13:04,941 ERROR [STDERR]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
  | 08:13:04,942 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  | 08:13:04,942 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java: 157)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProto col.java:566)
  | 08:13:04,942 ERROR [STDERR]     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
  | 08:13:04,942 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)
  | 


My Seam-Component:


  | @Name("trimUIINputStrings")
  | public class TrimUIInputStrings {
  |  
  |     @Observer("org.jboss.seam.beforePhase")
  |     public void beforePhase(PhaseEvent event) {
  |         try {
  | 			FacesContext context = event.getFacesContext();
  | 			HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
  |  
  | 			//Only handle POST
  | 			if ("POST".equalsIgnoreCase(request.getMethod())) {
  | 			    trimUIInputStrings(context.getViewRoot().getChildren());
  | 			}
  | 		} catch (Exception e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  |     }
  |  
  | 
  |     private void trimUIInputStrings(List<UIComponent> children) {
  |  
  |         for (UIComponent child : children) {
  |             //Only handle UIInput components
  |             if(child instanceof UIInput) {
  |                 UIInput input = (UIInput) child;
  |                 Object value = input.getValue();
  |                 
  |                 //Only handle Strings
  |                 if(value != null && value instanceof String) {
  |                     input.setValue(((String) value).trim());
  |                 }
  |             }
  |             
  |             if(child.getChildCount() > 0) {
  |  
  |                 //Loop through it's children
  |                 trimUIInputStrings(child.getChildren());
  |             }
  |         }
  |     }
  |  
  | }
  | 

Any hints for me?
Thank you

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

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



More information about the jboss-user mailing list