[JBoss Seam] - Re: Writing SeamTests with Seam 2.0.0. CR2 - What's Changed?
by bsmithjj
WEB-INF/components.xml? no - I'm trying to boot the embedded jboss ONLY from an ejb module that's part of a larger ear project. This all worked nicely in Seam 1.2.1. I say that because (as you probably know quite well by now ;-)) that I am immensely frustrated at things like <core:ejb> disappearing. I can't understand why you wouldn't think about supporting that IN ADDITION TO whatever new form of the JBoss container you want people to be able to boot and test with. As it stands now, in order to migrate our development process from Seam 1.2.1 to Seam 2.0.0, I have to figure out how to get a working jboss embedded (in addition to other things). Although traditionally, the focus of a framework evolution is to fix problems in the current version of the framework and add in new features, this current 'style of evolution' I see in Seam is one in which I am forced to move all dimensions of my development work forward simultaneously.
On the subject of maven and transitive dependencies, please do not deploy the Seam 2.0 releases to your public repository with poms that contain transitive dependencies - that's already tripped me up once because Seam 2.0.0.CR3 transitively stuck el-api.jar into my war and that already existed in the server. Transitive dependencies buy you nothing when they cause unexpected problems that take longer to fix (due to the surprise nature) than simply adding the dependencies you know you need due to good documentation. Knowing version dependencies (to me) is a good thing. Hiding versions and/or dependencies is bad.
BTW, Pete, I appreciate your discussions / interactions and patience with me ;-). In all my rants on the forum here, my frustrations tend to stem from no smooth transition being available for Seam 1.2.1 -> Seam 2.0.0 (on the issues I've posted about). I believe Seam could be a little kinder to its early adopters than it has been. Instead, I have several areas now where I need to 'start from scratch' (e.g. <core:ejb/> gone but actually worked fine ... hence this particular thread).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100794#4100794
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100794
17Â years, 2Â months
[JBoss Seam] - Re: Pageflow problems with back button
by jbeaken
Trying to use a ui:include but I need to generate dynamic s:links, not even sure it's possible, something like this:
Page that has the ui:include
| <ui:include src="/include/pagination.xhtml">
| <ui:param name="next" value="#{listCompaniesService.next}"/>
| <ui:param name="itemCount" value="#{listCompaniesService.itemCount}"/>
| <ui:param name="batchSize" value="#{listCompaniesService.batchSize}"/> <ui:param name="firstItem" value="#{listCompaniesService.firstItem}"/> </ui:include>
|
with include :
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html">
| <!-- FIRST -->
| <s:div id="tabcontainer" rendered="#{firstItem < batchSize}">
| <s:div styleClass="pageresults" rendered="#{itemCount > 0}">
| <div class="middle_highlight">
| <h:outputText value="#{firstItem + 1} ... #{itemCount < firstItem + batchSize ? itemCount : firstItem + batchSize}"/>
| </div>
| </s:div>
| <s:div styleClass="pageresults" rendered="#{itemCount > batchSize}">
| <s:link styleClass="middle" action="#{next}" value="#{firstItem + batchSize + 1} ... #{itemCount <= firstItem + (batchSize * 2) ? itemCount : firstItem + (batchSize * 2)}"></s:link>
| </s:div>
| <s:div styleClass="pageresults" rendered="#{itemCount > (batchSize * 2)}">
| <s:link styleClass="middle" action="#{next}" value="#{firstItem + 21} ... #{itemCount <= firstItem + 30 ? itemCount : firstItem + batchSize + (batchSize * 2)}"></s:link>
| </s:div>
| </s:div>
| ....
|
the dynamic s:link is found at :
<s:link styleClass="middle" action="#{next}" ...
In my head I think it won't be possible, unless maybe constructing a <a href manually, but anyone done it?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100792#4100792
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100792
17Â years, 2Â months
[JBoss Seam] - Re: More configuration issues getting starged with seam...
by mickknutson
I removed those 2 items you said, then I get this error:
| [2007-10-31 09:54:02,602] Facet JavaEE: Module is deployed successfully
| 09:54:03,868 INFO [Contexts] starting up: org.jboss.seam.security.identity
| 09:54:04,540 INFO [RuleBase] parsing rules: security-rules.drl
| 09:54:06,196 INFO [Contexts] starting up: org.jboss.seam.web.session
| 09:54:06,306 ERROR [SeamPhaseListener] uncaught exception
| java.lang.IllegalStateException: Could not start transaction
| at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:571)
| at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:307)
| at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142)
| at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
| 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:83)
| at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
| at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:273)
| at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
| 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:595)
| Caused by: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/entityManager
| at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:247)
| at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:79)
| at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:108)
| 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:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
| at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
| at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
| at org.jboss.seam.Component.unwrap(Component.java:2100)
| at org.jboss.seam.Component.getInstance(Component.java:1879)
| at org.jboss.seam.Component.getInstance(Component.java:1832)
| 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 org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
| at org.jboss.seam.transaction.EntityTransaction.initEntityManager(EntityTransaction.java:66)
| at org.jboss.seam.transaction.EntityTransaction.begin(EntityTransaction.java:78)
| at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:566)
| ... 43 more
| Caused by: javax.naming.NameNotFoundException: entityManager not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:243)
| ... 67 more
| 09:54:06,368 INFO [MyfacesConfig] No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
| 09:54:06,368 INFO [MyfacesConfig] No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
|
I have tried 2 different ways:
<persistence:managed-persistence-context name="entityManager"
auto-create="true" entity-manager-factory="java:/yourSOSEntityManagerFactory"/>
as well as:
<persistence:managed-persistence-context name="entityManager"
auto-create="true" entity-manager-factory="#{yourSOSEntityManagerFactory}"/>
When I try the second version with the #{..}
I get this error:
| 10:13:48,086 ERROR [[/yoursos]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
| java.lang.RuntimeException: Could not create Component: entityManager
| at org.jboss.seam.init.Initialization.addComponent(Initialization.java:976)
| at org.jboss.seam.init.Initialization.installComponents(Initialization.java:903)
| at org.jboss.seam.init.Initialization.init(Initialization.java:548)
| at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
| at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
| at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
| at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
| 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:585)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.apache.catalina.core.StandardContext.init(StandardContext.java:5310)
| 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:585)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
| at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
| at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
| at org.jboss.web.WebModule.startModule(WebModule.java:83)
| at org.jboss.web.WebModule.startService(WebModule.java:61)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy45.start(Unknown Source)
| at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
| 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:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
| at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
| at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
| at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
| at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy46.start(Unknown Source)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
| at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| 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:585)
| at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:266)
| 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:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.jmx.connector.invoker.SerializableInterceptor.invoke(SerializableInterceptor.java:74)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179)
| 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:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:818)
| at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:419)
| 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:585)
| at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
| at sun.rmi.transport.Transport$1.run(Transport.java:153)
| at java.security.AccessController.doPrivileged(Native Method)
| at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
| at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
| at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: java.lang.IllegalArgumentException: No converter for type: org.jboss.seam.core.Expressions$ValueExpression
| at org.jboss.seam.util.Conversions.getConverter(Conversions.java:55)
| at org.jboss.seam.Component$ConstantInitialValue.<init>(Component.java:2302)
| at org.jboss.seam.Component.getInitialValue(Component.java:514)
| at org.jboss.seam.Component.getTopInitialValue(Component.java:494)
| at org.jboss.seam.Component.initInitializers(Component.java:472)
| at org.jboss.seam.Component.<init>(Component.java:263)
| at org.jboss.seam.Component.<init>(Component.java:216)
| at org.jboss.seam.init.Initialization.addComponent(Initialization.java:961)
| ... 127 more
| 10:13:48,102 ERROR [StandardContext] Error listenerStart
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100787#4100787
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100787
17Â years, 2Â months
[JBoss Seam] - Custom ObjectConverter for selectItems - howto El in convert
by gonzalad
Hello,
I'm coding a generic object converter which will work for non jpa backends (i.e. jca, jdbc, ...) - similar to the one in http://www.jboss.com/index.html?module=bb&op=viewtopic&t=122149&postdays=....
But stateless.
The converter is used for selectItems - Here is a sample jsf code to display a country selectBox (sx:convertObject) :
<h:selectOneMenu id="country"
| value="#{client.adress.country}" styleClass="selectBox">
| <sx:convertObject var="value" asStringEl="value.id"/>
| <s:selectItems value="#{countryManager.allCountries}"
| var="country" label="#{country.libelle}"
| noSelectionLabel="Please Select..." />
| </h:selectOneMenu>
How does it work ?
On render, it applies the el #{value.id} on every object of selectItems (so call country.getId for every country).
On submit, it applies once more this el on all selectItems objects until retrieving the selected string value.
Here's my questions :
1. I would lik to use a real EL in asStringEl attribute.
How can I achieve it in a converter ?
I've tried setting asStringEl="#{value.id}", but facelets interprets it *before* my converter - and I retrieve value "" in my converter.
2. Does this approach appears fine or is there a better one (it's my first Jsf converter - so quite a newbie...).
Sorry for this long mail and thank you very much for you help.
Here's my converter code :
@Name("com.natixis.sphinx.jsf.component.objectConverter")
| @org.jboss.seam.annotations.jsf.Converter
| @Scope(ScopeType.STATELESS)
| @Install(precedence=Install.FRAMEWORK)
| public class ObjectConverter implements Converter, Serializable {
|
| /** Champ serialVersionUID. */
| private static final long serialVersionUID = -8229857238533003490L;
| private String asStringEl;
| private String var;
|
| public Object getAsObject(FacesContext aFacesContext, UIComponent aComponent, String aValueAsString) {
| if (aValueAsString == null) {
| return null;
| }
|
| //1. récupération valeurs selectItems
| SelectItemsIterator lIterator = new SelectItemsIterator(aComponent);
|
| //2. recherche du SelectItem correspondant à aValueAsString
| while (lIterator.hasNext()) {
| Object lItem = lIterator.next().getValue();
| String lAsString = convertToString (lItem, aFacesContext);
| if (aValueAsString.equals (lAsString)) {
| return lItem;
| }
| }
| //TODO : should never happen or illegal data.... ou aucune valeur sélectionnée
| return null;
| }
|
| @SuppressWarnings("unchecked")
| private void restoreInRequest(Object aOld, FacesContext aFacesContext) {
| Map lRequestMap = aFacesContext.getExternalContext().getRequestMap();
| if (aOld == null) {
| lRequestMap.remove(getVar());
| } else {
| lRequestMap.put(getVar(), aOld);
| }
| }
|
| @SuppressWarnings("unchecked")
| private Object storeInRequest(Object aItem, FacesContext aFacesContext) {
| Map lRequestMap = aFacesContext.getExternalContext().getRequestMap();
| return lRequestMap.put(getVar(), aItem);
| }
|
| public String getVar() {
| //valeur attribut var
| return var;
| }
|
| public void setVar (String aVar) {
| var = aVar;
| }
|
| public String getAsStringEl() {
| return "#{"+asStringEl+"}";
| }
|
| public void setAsStringEl(String aValue) {
| asStringEl = aValue;
| }
|
| public String getAsString(FacesContext aFacesContext, UIComponent aComponent, Object aValue) {
| if (aValue == null) {
| return null;
| }
| return convertToString(aValue, aFacesContext);
| }
|
| private String convertToString (Object aObject, FacesContext aFacesContext) {
| Object lOld = storeInRequest (aObject, aFacesContext);
| try {
| return Interpolator.instance().interpolate(getAsStringEl());
| } finally {
| restoreInRequest (lOld, aFacesContext);
| }
| }
| }
|
Here's the taglib.xml file :
| <?xml version="1.0"?>
| <!DOCTYPE facelet-taglib PUBLIC
| "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
| "facelet-taglib_1_0.dtd">
|
| <facelet-taglib>
| <namespace>http://test.com/sphinx-jsf/taglib</namespace>
| <tag>
| <tag-name>convertObject</tag-name>
| <converter>
| <converter-id>com.natixis.sphinx.jsf.component.objectConverter</converter-id>
| </converter>
| </tag>
| </facelet-taglib>
|
An utility file (from myfaces 1.1.5) :
| package com.natixis.sphinx.jsf.component;
|
| import java.util.*;
|
| import javax.faces.component.UIComponent;
| import javax.faces.component.UISelectItem;
| import javax.faces.component.UISelectItems;
| import javax.faces.component.UIViewRoot;
| import javax.faces.el.ValueBinding;
| import javax.faces.model.SelectItem;
|
|
| /**
| * <p>Cette classe est issue de MyFaces 1.1.5.</p>
| *
| * <p>Elle nous permet de récupérer simplement les valeur d'un composant selectItems
| * Ã partir du composant parent (i.e. selectOneMenu par exemple).</p>
| */
| class SelectItemsIterator implements Iterator<SelectItem>
| {
| private final Iterator _childs;
| private Iterator _nestedItems;
| private Object _nextItem;
| private String _collectionLabel;
| private UISelectItems _currentUISelectItems;
|
| public SelectItemsIterator(UIComponent selectItemsParent)
| {
| _childs = selectItemsParent.getChildren().iterator();
| }
|
| @SuppressWarnings("unchecked")
| public boolean hasNext()
| {
| if(_nextItem != null)
| {
| return true;
| }
| if(_nestedItems != null)
| {
| if(_nestedItems.hasNext())
| {
| return true;
| }
| _nestedItems = null;
| }
| if (_childs.hasNext())
| {
| UIComponent child = (UIComponent) _childs.next();
| if (child instanceof UISelectItem)
| {
| UISelectItem uiSelectItem = (UISelectItem) child;
| Object item = uiSelectItem.getValue();
| if (item == null)
| {
| Object itemValue = ((UISelectItem) child).getItemValue();
| String label = ((UISelectItem) child).getItemLabel();
| String description = ((UISelectItem) child)
| .getItemDescription();
| boolean disabled = ((UISelectItem) child).isItemDisabled();
| if (label == null)
| {
| label = itemValue.toString();
| }
| item = new SelectItem(itemValue, label, description,
| disabled);
| }
| else if (!(item instanceof SelectItem))
| {
| ValueBinding binding = ((UISelectItem) child)
| .getValueBinding("value");
| throw new IllegalArgumentException(
| "Value binding '"
| + (binding == null ? null : binding.getExpressionString())
| + "' of UISelectItem : "
| + getPathToComponent(child)
| + " does not reference an Object of type SelectItem");
| }
| _nextItem = item;
| return true;
| }
| else if (child instanceof UISelectItems)
| {
| _currentUISelectItems = ((UISelectItems) child);
| Object value = _currentUISelectItems.getValue();
|
| if (value instanceof SelectItem)
| {
| _nextItem = value;
| return true;
| }
| else if (value instanceof SelectItem[])
| {
| _nestedItems = Arrays.asList((SelectItem[]) value)
| .iterator();
| _collectionLabel = "Array";
| return hasNext();
| }
| else if (value instanceof Collection)
| {
| _nestedItems = ((Collection)value).iterator();
| _collectionLabel = "Collection";
| return hasNext();
| }
| else if (value instanceof Map)
| {
| Map map = ((Map) value);
| Collection items = new ArrayList(map.size());
| for (Iterator it = map.entrySet().iterator(); it
| .hasNext();)
| {
| Map.Entry entry = (Map.Entry) it.next();
| items.add(new SelectItem(entry.getValue(), entry
| .getKey().toString()));
| }
| _nestedItems = items.iterator();
| _collectionLabel = "Map";
| return hasNext();
| }
| else
| {
| ValueBinding binding = _currentUISelectItems.getValueBinding("value");
|
| throw new IllegalArgumentException(
| "Value binding '"
| + (binding == null ? null : binding
| .getExpressionString())
| + "'of UISelectItems with component-path "
| + getPathToComponent(child)
| + " does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : "
| + ((value == null) ? null : value
| .getClass()
| .getName()));
| }
| }
| else
| {
| //todo: may other objects than selectItems be nested or not?
| //log.error("Invalid component : " + getPathToComponent(child) + " : must be UISelectItem or UISelectItems, is of type : "+((child==null)?"null":child.getClass().getName()));
| }
| }
| return false;
| }
|
| public SelectItem next()
| {
| if (!hasNext())
| {
| throw new NoSuchElementException();
| }
| if(_nextItem != null)
| {
| Object value = _nextItem;
| _nextItem = null;
| return (SelectItem) value;
| }
| if (_nestedItems != null)
| {
| Object item = _nestedItems.next();
| if (!(item instanceof SelectItem))
| {
| ValueBinding binding = _currentUISelectItems
| .getValueBinding("value");
| throw new IllegalArgumentException(
| _collectionLabel + " referenced by UISelectItems with binding '"
| + (binding == null ? null : binding
| .getExpressionString())
| + "' and Component-Path : " + getPathToComponent(_currentUISelectItems)
| + " does not contain Objects of type SelectItem");
| }
| return (SelectItem) item;
| }
| throw new NoSuchElementException();
| }
|
| public void remove()
| {
| throw new UnsupportedOperationException();
| }
|
|
| private String getPathToComponent(UIComponent component)
| {
| StringBuffer buf = new StringBuffer();
|
| if(component == null)
| {
| buf.append("{Component-Path : ");
| buf.append("[null]}");
| return buf.toString();
| }
|
| getPathToComponent(component,buf);
|
| buf.insert(0,"{Component-Path : ");
| buf.append("}");
|
| return buf.toString();
| }
|
| private void getPathToComponent(UIComponent component, StringBuffer buf)
| {
| if(component == null)
| return;
|
| StringBuffer intBuf = new StringBuffer();
|
| intBuf.append("[Class: ");
| intBuf.append(component.getClass().getName());
| if(component instanceof UIViewRoot)
| {
| intBuf.append(",ViewId: ");
| intBuf.append(((UIViewRoot) component).getViewId());
| }
| else
| {
| intBuf.append(",Id: ");
| intBuf.append(component.getId());
| }
| intBuf.append("]");
|
| buf.insert(0,intBuf);
|
| if(component!=null)
| {
| getPathToComponent(component.getParent(),buf);
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100785#4100785
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100785
17Â years, 2Â months