6 Replies Latest reply on Jan 26, 2009 11:38 AM by Mark Diskin

    a4j:mediaOutput and Spring beans

    Oliver Libutzki Newbie

      Hi everyone,

      as I use Spring Webflow I defeined Spring beans instead of managed-beans. This works great, but I think I came across a bug.

      The attribute createContent of the tag a4j:mediaOutput doesn't except a getter of my bean. I get a PropertyNotfoundException.

      Does anyone have a solution for this problem?

      Thanks and kind regards
      Lobster

        • 1. Re: a4j:mediaOutput and Spring beans
          Nick Belaevski Master

          Lobster,

          createContent is not a property that can have getter but method that accepts two parameters: OutputStream and Object. Can you please post page/bean code?

          • 2. Re: a4j:mediaOutput and Spring beans
            Oliver Libutzki Newbie

             

            "nbelaevski" wrote:
            Lobster,

            createContent is not a property that can have getter but method that accepts two parameters: OutputStream and Object. Can you please post page/bean code?


            Yes, I can:

            Bean definition:
            <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
             http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
             <bean id="PaintBean" class="com.package.PaintBean"/>
            </beans>
            


            The bean itself:
            public class PaintBean {
             private int tileWidth;
             private int tileHeight;
             private ImageData[] imageData;
            
             public void paint(OutputStream out, Object data) throws IOException {
             // ...
             }
            
             // getters and setters
            }
            


            Usage in jspx-File
            <a4j:repeat value="#{paintBean.imageData}" var="imageTile">
            
             <a4j:outputPanel layout="block" style="left: #{imageTile.left}px; top: #{imageTile.top}px; width: #{paintBean.tileWidth}px; height: #{paintBean.tileHeight}px">
            
             <a4j:mediaOutput createContent="#{paintBean.paint}" element="img" mimeType="image/png" shape="rect" standby="loading..." value="#{imageTile}" />
            
             </a4j:outputPanel>
            
            </a4j:repeat>
            


            It results in this stacktrace:
            javax.faces.el.EvaluationException: /pages/views/main/richgraph.jspx @54,223 createContent="#{paintBean.paint}": Target Unreachable, identifier 'paintBean' resolved to null
             at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
             at org.ajax4jsf.resource.UserResource.send(UserResource.java:111)
             at org.ajax4jsf.resource.ResourceLifecycle.sendResource(ResourceLifecycle.java:223)
             at org.ajax4jsf.resource.ResourceLifecycle.send(ResourceLifecycle.java:148)
             at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:227)
             at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
             at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:265)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at de.bmiag.gear.frontend.FrontendFilter.doFilter(FrontendFilter.java:291)
             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:233)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
             at java.lang.Thread.run(Thread.java:595)
            


            If I use managed-beans, everything works fine.

            Thanks for your help!

            • 3. Re: a4j:mediaOutput and Spring beans
              Nick Belaevski Master

              Please describe how do you wire Spring with JSF.

              • 4. Re: a4j:mediaOutput and Spring beans
                Oliver Libutzki Newbie

                 

                "nbelaevski" wrote:
                Please describe how do you wire Spring with JSF.


                Spring (web flow) is integrated in web.xml and faces-config.xml

                web.xml
                <listener>
                 <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
                 </listener>
                
                 <listener>
                 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
                 </listener>


                faces-config.xml
                 <application>
                 <navigation-handler>org.springframework.webflow.executor.jsf.FlowNavigationHandler</navigation-handler>
                 <variable-resolver>org.springframework.webflow.executor.jsf.DelegatingFlowVariableResolver</variable-resolver>
                 <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
                 </application>
                 <lifecycle>
                 <phase-listener>org.springframework.webflow.executor.jsf.FlowPhaseListener</phase-listener>
                 </lifecycle>


                • 5. Re: a4j:mediaOutput and Spring beans
                  Oliver Libutzki Newbie

                  I forgot the reference to te Spring beans in web.xml

                  <context-param>
                   <param-name>contextConfigLocation</param-name>
                   <param-value>
                   /WEB-INF/webflow-config.xml
                   /WEB-INF/beans/*.xml
                   </param-value>
                   </context-param>


                  and the myfaces listener:
                  <listener>
                   <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
                   </listener>


                  • 6. Re: a4j:mediaOutput and Spring beans
                    Mark Diskin Newbie

                    Did anyone find a way around this issue? I tried to use a standard managedbean for the paintBean (content) and pass the Spring bean as the value but this does not work.

                    Any alternatives?

                    Thanks in advance for any assistance.
                    Mark