[jboss-user] [JBoss Seam] - Enum as a Seam component

ellenzhao do-not-reply at jboss.com
Mon Aug 6 08:06:59 EDT 2007


My user is supposed to specify importances of something from the UI. The importance are interpreted as Shorts. Here is my Enum:


  | @Name("importance")
  | @Scope(APPLICATION)
  | public enum Importance{
  |   DONT_CARE((short) 0, "I don't care"), NOT_VERY((short) 1,
  |       "Not very important"), DONT_KNOW((short) 2, "I don't know"), IMPORTANT(
  |       (short) 3, "Important"), VERY((short) 4, "Very important");
  |   
  |   private final Short weight;
  |   private final String label;
  |   
  |   Importance(Short weight, String label){
  |     this.weight = weight;
  |     this.label = label;
  |   }
  |   
  |   public Short getWeight(){
  |     return this.weight;
  |   }
  |   
  |   public String toString(){
  |     return this.label;
  |   }
  | }
  | 

I put it into the entity package since semantically it's closer to entities. The client code in the controller package is:

  |     short impor = Importance.DONT_KNOW.getWeight();
  |     this.foo.setDistanceImportance(impor);
  |     this.foo.setFondnessImportance(impor);
  |     ...
  | 

However I got this exception:

  | 13:29:37,778 ERROR [STDERR] Aug 6, 2007 1:29:37 PM com.sun.facelets.FaceletViewHandler handleRenderException
  | SEVERE: Error Rendering View[/weekly-planner.xhtml]
  | org.jboss.seam.InstantiationException: Could not instantiate Seam component: importance
  |         at org.jboss.seam.Component.newInstance(Component.java:1955)
  |         at org.jboss.seam.Component.getInstance(Component.java:1858)
  |         at org.jboss.seam.Component.getInstance(Component.java:1825)
  |         at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
  |         at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
  |         at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
  |         at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
  |         at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
  |         at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
  |         at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
  |         at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
  |         at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
  |         at javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
  |         at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:96)
  |         at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
  |         at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
  |         at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
  |         at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
  |         at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
  |         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
  |         at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
  |         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
  |         at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
  |         at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
  |         at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
  |         at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
  |         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
  |         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
  |         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
  |         at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
  |         at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
  |         at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
  |         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
  |         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  |         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
  |         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:82)
  |         at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
  |         at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
  |         at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  |         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
  |         at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:149)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  |         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  |         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
  |         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
  |         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
  |         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  |         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
  |         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  |         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
  |         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  |         at java.lang.Thread.run(Thread.java:619)
  | Caused by: java.lang.InstantiationException: org.ningning.eatsmart.entity.Importance
  |         at java.lang.Class.newInstance0(Class.java:340)
  |         at java.lang.Class.newInstance(Class.java:308)
  |         at org.jboss.seam.Component.instantiateJavaBean(Component.java:1300)
  |         at org.jboss.seam.Component.instantiate(Component.java:1256)
  |         at org.jboss.seam.Component.newInstance(Component.java:1951)
  |         ... 72 more
  | 

How to fix this? Thanks in advance for any help!


Regards,
Ellen

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

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



More information about the jboss-user mailing list