7 Replies Latest reply on Jan 17, 2010 6:36 AM by nbelaevski

    Rerender component on load

    poschd

      Hi everyone,

       

      I'm trying to dynamically change the size of a <rich:paint2D>-tag. Its height depends on the (amount of) data that I get passed to my paint()-method, so resizing needs to be done after painting. (Does that even work?)

       

      My approach was to invoke a <rich:jsFunction> on load using jQuery:

      <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"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
      
          <ui:define name="body">
              <!-- illustration of circuit groups -->
              <rich:paint2D id="cgImage" paint="#{cgPainter.paint}"
                  format="png" data="#{cg.resultList}"
                  width="#{cgPainter.WIDTH}"
                  height="#{cgPainter.HEIGHT}" />
                  
              <!-- ... -->
      
              <a4j:form>
                  <a4j:jsFunction name="updateCgImageHeight" reRender="cgImage" />
                  <a4j:loadScript src="resource://jquery.js" />
                  <script type="text/javascript">//<![CDATA[
                  jQuery(document).ready(function() {
                      updateCgImageHeight();
                  });
              //]]></script>
                  <div onclick="updateCgImageHeight()">Update</div>
              </a4j:form>
              
          </ui:define>
      </ui:composition>
      

      The code executes fine, but the size of my image does not change. (I hardcoded a change of size within my paint()-method for debug purposes.)

       

      Can anyone explain to me why this is and/or how to get it to work?

       

      Regards, Daniel

       

      Slightly adapted code according to Nick Belaevski's suggestion.

        • 1. Re: Rerender component on load
          nbelaevski

          Hi Daniel,

           

          Please check if this works when you are calling updateCgImageHeight() explicitly from some event handler, e.g.:

          <div onclick="updateCgImageHeight()">Update</div>
          
          • 2. Re: Rerender component on load
            poschd

            Hi Nick,

             

            calling updateCgImageHeight() explicitly doesn't work either. What seems strange is that my getHEIGHT() and getWIDTH() methods are indeed called when I try to rerender the image, but nothing changes.

             

            Regards, Daniel

            • 3. Re: Rerender component on load
              nbelaevski

              Hi Daniel,

               

              Please try switching caching off to check if that's the cause.

              • 4. Re: Rerender component on load
                poschd

                So I found out that my problem is caused by a strange behaviour that I don't quite understand. In fact, there are three (!) instances of my painter bean. Here's what happens when I request the page:

                01 DEBUG [CgBean] Fetched 9 rows
                02 DEBUG [CgPainterBean] Instance[0]: Initializing...
                03 DEBUG [CgPainterBean] Instance[0]: getWIDTH() = 1000
                04 DEBUG [CgPainterBean] Instance[0]: getHEIGHT() = 440
                05 DEBUG [CgPainterBean] Instance[0]: getHEIGHT() = 440
                06 DEBUG [CgPainterBean] Instance[0]: getWIDTH() = 1000
                07 DEBUG [CgPainterBean] Instance[1]: Initializing...
                08 DEBUG [CgPainterBean] Instance[1]: Received result list with 9 elements
                09 DEBUG [CgPainterBean] Instance[1]: Updated HEIGHT to 800
                10 DEBUG [CgPainterBean] Instance[0]: getWIDTH() = 1000
                11 DEBUG [CgPainterBean] Instance[0]: getHEIGHT() = 440
                12 DEBUG [CgPainterBean] Instance[0]: getHEIGHT() = 440
                13 DEBUG [CgPainterBean] Instance[0]: getWIDTH() = 1000
                14 DEBUG [CgPainterBean] Instance[2]: Initializing...
                15 DEBUG [CgPainterBean] Instance[2]: Received result list with 9 elements
                16 DEBUG [CgPainterBean] Instance[2]: Updated HEIGHT to 800
                

                 

                I found out that lines 1 - 6 are caused by using respective getters to set height and width of the image: <rich:paint2D height="#{cgPainter.HEIGHT}" width="#{cgPainter.WIDTH}"/>

                 

                At lines 7 - 9 the actual painting happens. (As I mentioned before, I update the heigt there.)

                 

                Lines 10 - 16 show what happens when rerendering the image. Interestingly, height and width getters are called at the original instance while yet another (third) instance is created to repaint the image. This third instance is only used when rerendering the image for the first time. When rerendering for the second or third time and so on, RF only calls the height and width getters from Instance[0], both of them twice - another behavior I don't understand. Why are the getters always called twice?

                 

                By the way, the first instance also has another stacktrace than the other ones, but since I'm not an expert of RF's and Seam's inner life I can't read anything out.

                 

                First instance's stacktrace:

                ERROR [STDERR] java.lang.Exception: Stack trace
                ERROR [STDERR]     at java.lang.Thread.dumpStack(Unknown Source)
                ERROR [STDERR]     at XXXXXXXX.CgPainterBean.init(CgPainterBean.java:234)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at java.lang.reflect.Method.invoke(Unknown Source)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                ERROR [STDERR]     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                ERROR [STDERR]     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                ERROR [STDERR]     at at.tmobile.netview.session.CircuitgroupPainterBean_$$_javassist_seam_3.init(CircuitgroupPainterBean_$$_javassist_seam_3.java)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at java.lang.reflect.Method.invoke(Unknown Source)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                ERROR [STDERR]     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
                ERROR [STDERR]     at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
                ERROR [STDERR]     at org.jboss.seam.Component.newInstance(Component.java:2132)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:2021)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:1983)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:1977)
                ERROR [STDERR]     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
                ERROR [STDERR]     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
                ERROR [STDERR]     at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
                ERROR [STDERR]     at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
                ERROR [STDERR]     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
                ERROR [STDERR]     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
                ERROR [STDERR]     at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                ERROR [STDERR]     at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
                ERROR [STDERR]     at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                ERROR [STDERR]     at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                ERROR [STDERR]     at org.richfaces.component.html.HtmlPaint2D.getWidth(HtmlPaint2D.java:604)
                ERROR [STDERR]     at org.richfaces.renderkit.html.Paint2DResource.getDataToStore(Paint2DResource.java:105)
                ERROR [STDERR]     at org.ajax4jsf.resource.InternetResourceBase.getUri(InternetResourceBase.java:218)
                ERROR [STDERR]     at org.ajax4jsf.resource.BaseResourceRenderer.encodeBegin(BaseResourceRenderer.java:64)
                ERROR [STDERR]     at org.ajax4jsf.resource.InternetResourceBase.encodeBegin(InternetResourceBase.java:345)
                ERROR [STDERR]     at org.richfaces.renderkit.html.Paint2DRenderer.doEncodeEnd(Paint2DRenderer.java:49)
                ERROR [STDERR]     at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
                ERROR [STDERR]     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
                ERROR [STDERR]     at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)
                ERROR [STDERR]     at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
                ERROR [STDERR]     at org.richfaces.renderkit.html.PageRenderer.doEncodeChildren(PageRenderer.java:265)
                ERROR [STDERR]     at org.richfaces.renderkit.html.PageRenderer.doEncodeChildren(PageRenderer.java:254)
                ERROR [STDERR]     at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
                ERROR [STDERR]     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                ERROR [STDERR]     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
                ERROR [STDERR]     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
                ERROR [STDERR]     at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                ERROR [STDERR]     at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                ERROR [STDERR]     at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                ERROR [STDERR]     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
                ERROR [STDERR]     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                ERROR [STDERR]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                ERROR [STDERR]     at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                ERROR [STDERR]     at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                ERROR [STDERR]     at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                ERROR [STDERR]     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                ERROR [STDERR]     at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                ERROR [STDERR]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                ERROR [STDERR]     at java.lang.Thread.run(Unknown Source)
                

                 

                Second's and third's instances' stacktrace:

                ERROR [STDERR] java.lang.Exception: Stack trace
                ERROR [STDERR]     at java.lang.Thread.dumpStack(Unknown Source)
                ERROR [STDERR]     at XXXXXXXX.CgPainterBean.init(CgPainterBean.java:234)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at java.lang.reflect.Method.invoke(Unknown Source)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                ERROR [STDERR]     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                ERROR [STDERR]     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                ERROR [STDERR]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                ERROR [STDERR]     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                ERROR [STDERR]     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                ERROR [STDERR]     at at.tmobile.netview.session.CircuitgroupPainterBean_$$_javassist_seam_3.init(CircuitgroupPainterBean_$$_javassist_seam_3.java)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                ERROR [STDERR]     at java.lang.reflect.Method.invoke(Unknown Source)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                ERROR [STDERR]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                ERROR [STDERR]     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
                ERROR [STDERR]     at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
                ERROR [STDERR]     at org.jboss.seam.Component.newInstance(Component.java:2132)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:2021)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:1983)
                ERROR [STDERR]     at org.jboss.seam.Component.getInstance(Component.java:1977)
                ERROR [STDERR]     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
                ERROR [STDERR]     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
                ERROR [STDERR]     at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
                ERROR [STDERR]     at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
                ERROR [STDERR]     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
                ERROR [STDERR]     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
                ERROR [STDERR]     at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                ERROR [STDERR]     at org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
                ERROR [STDERR]     at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
                ERROR [STDERR]     at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                ERROR [STDERR]     at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                ERROR [STDERR]     at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
                ERROR [STDERR]     at org.richfaces.renderkit.html.Paint2DResource.send(Paint2DResource.java:187)
                ERROR [STDERR]     at org.ajax4jsf.resource.ResourceLifecycle.sendResource(ResourceLifecycle.java:219)
                ERROR [STDERR]     at org.ajax4jsf.resource.ResourceLifecycle.send(ResourceLifecycle.java:146)
                ERROR [STDERR]     at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:226)
                ERROR [STDERR]     at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
                ERROR [STDERR]     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:508)
                ERROR [STDERR]     at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                ERROR [STDERR]     at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                ERROR [STDERR]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                ERROR [STDERR]     at java.lang.Thread.run(Unknown Source)
                

                 

                Here's the code of my JavaBean:

                @Name("cgPainter")
                @Scope(ScopeType.PAGE)
                public class CircuitgroupPainterBean {
                    private static int noInstances = 0;
                    private int instanceId;
                    
                    /* boundaries of image */
                    private /*static*/ int HEIGHT = 430; // height depends on number of elements
                    private final int WIDTH = 1000;
                
                    @Logger("CgPainterBean")
                    private Log log;
                
                    public void paint(Graphics2D g, Object o) {
                        //...
                        log.debug("Instance[#1]: Received result list with #0 elements", resultList.size(), instanceId);
                        HEIGHT = 800;
                        log.debug("Instance[#1]: Updated HEIGHT to #0", HEIGHT, instanceId);
                        //...
                    }
                    
                    @Create
                    public void init() {
                        instanceId = noInstances;
                        noInstances += 1;
                        log.debug("Instance[#0]: Initializing...", instanceId);
                        //Thread.dumpStack();
                    }
                
                    public int getWIDTH() {
                        log.debug("Instance[#1]: getWIDTH() = #0", WIDTH, instanceId);
                        return WIDTH;
                    }
                
                    public int getHEIGHT() {        
                        log.debug("Instance[#1]: getHEIGHT() = #0", HEIGHT, instanceId);
                        return HEIGHT;
                    }
                }
                

                 

                Just in case someone has or will have a similar problem: I have managed to workaround the problem by declaring HEIGHT static. Not a perfect, yet a working solution.

                 

                Still I don't understand why my painter class is instantiated more than once and my getters are called twice. Anyone got an explaination?

                 

                Regards, Daniel

                • 5. Re: Rerender component on load
                  nbelaevski

                  External resources are rendered in two stages:

                  - on the first HTML element linking to resource (IMG, LINK, etc) is written

                  - on the second browser requests resource contents in the separate request

                  • 6. Re: Rerender component on load
                    poschd

                    I see. Thank you for the explaination!

                     

                    Is there better way to get rid of these redundant instances? Having HEIGHT declared static is not a nice solution, I guess.

                    • 7. Re: Rerender component on load
                      nbelaevski
                      You can pass width/height via bean bound as "data" attribute for the component.