5 Replies Latest reply on Aug 13, 2012 9:28 AM by jboss_mario

    Richfaces 4 not loading some scripts when page is revisited

    teme_h

      Hello,

       

        After upgrading to Richfaces 4 I am getting javescript errors like  'RichFaces.ui.Calendar is undefined' when I revisit a page.  The pages containing the calendar component always come up fine the first time I navigate to them. I look at the scripts that are loaded in firebugs and it does include the ones for Calendar the first time I visit the page. If I back up and come back to the page or do anything in the page that resubmits and loads it again I get the undefined error. Looking at the scripts that are loaded this time around does not show calendar scripts although it has most of the other scripts.  I have attached the scripts loaded below. I am also having similar issue with pages that have collapsibleSubTable, I get  'RichFaces.ui.CollapsibleSubTable is not a constructor' error when page is revisited looking at the loaded scripts I see the same patter as the Calendar component.  I do have <h:head> and most of the other scripts are loading fine….


      I am wondering if anyone else has seen similar issues... I can also do more debugging if you point me to the files that have the logic to generate which script to include....

       

      Thanks,

      Teme

       

       

       

       

       

      Script Loaded first time page is visited include Calendar scripts like calendar.js.faces

      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:security="http://www.springframework.org/security/tags"><head><link type="text/css" rel="stylesheet" href="/dmm/rfRes/skinning.ecss.faces?db=eAHL6rC8BQAEkAIG" /><script type="text/javascript" src="/dmm/javax.faces.resource/jsf.js.faces?ln=javax.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/jquery.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-event.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-base-component.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/togglePanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/togglePanelItem.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/collapsiblePanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/collapsiblePanelItem.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/icons.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><link type="text/css" rel="stylesheet" href="/dmm/rfRes/collapsiblePanel.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><script type="text/javascript" src="/dmm/javax.faces.resource/datatable.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/datatable.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><link type="text/css" rel="stylesheet" href="/dmm/rfRes/datagrid.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><link type="text/css" rel="stylesheet" href="/dmm/rfRes/panel.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-queue.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/jquery.position.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/json-dom.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/jquery.effects.core.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/jquery.effects.highlight.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/JQuerySpinBtn.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/calendar-utils.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/calendar.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/calendar.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanelBorders.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanelSizer.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/popupPanel.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /

       

      Scripts loaded subsequent times do not include Calendar scripts like calendar.js.faces:

      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:security="http://www.springframework.org/security/tags"><head><link type="text/css" rel="stylesheet" href="/dmm/rfRes/skinning.ecss.faces?db=eAHL6rC8BQAEkAIG" /><script type="text/javascript" src="/dmm/javax.faces.resource/jsf.js.faces?ln=javax.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/jquery.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-event.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-base-component.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/togglePanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/togglePanelItem.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/collapsiblePanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/collapsiblePanelItem.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/icons.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><link type="text/css" rel="stylesheet" href="/dmm/rfRes/collapsiblePanel.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><script type="text/javascript" src="/dmm/javax.faces.resource/datatable.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/datatable.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" /><script type="text/javascript" src="/dmm/javax.faces.resource/richfaces-queue.js.faces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanel.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanelBorders.js.faces?ln=org.richfaces"></script><script type="text/javascript" src="/dmm/javax.faces.resource/popupPanelSizer.js.faces?ln=org.richfaces"></script><link type="text/css" rel="stylesheet" href="/dmm/rfRes/popupPanel.ecss.faces?db=eAHL6rC8BQAEkAIG&amp;ln=org.richfaces" />

        • 1. Re: Richfaces 4 not loading some scripts when page is revisited
          teme_h

          Lack of response to my question made me think it must have something to do with our code... I did more digging and I was able to isolate the issue to UI Components that are bound to backing beans at session level.  I guess that might explain why the scripts were getting loaded correctly only the first time the pages were visited.  I am thinking Richfaces 4 somehow has it where the scripts to be included are computed when the UI component is created... As session level bound UI components are only created once per session…

           

          We already run into Duplicate ID issues with some session level bound components on our last upgrade. We only made changes to remove the bindings with those that we had issues with, never got to changing all.  I guess we are paying for that now .The lesson learned is to totally stay away from binding UI components to session level beans, you never know when it will bite you. In our case we were binding DataGrid to get the selected row. We can do the same by using ListDataModels…

           

          • 2. Re: Richfaces 4 not loading some scripts when page is revisited
            kirillica

            We have the same issue after migrating to RichFaces 4.1 (from 3.3). Maybe you can explain your fix?

            • 3. Re: Richfaces 4 not loading some scripts when page is revisited
              teme_h

              The issue we had was caused by UI components that we had bound to session level.  If you are binding UI components in a backing bean and that bean is session scoped you may see a similar problem. The symptom would be if the page loads all scripts the first time you visit it but fails to load the required scripts on subsequent visits.

              The solution is really to remove UI component binding to session scoped beans.  I our case we were able do without any UI component bindings. Unless you are doing a lot of manipulation to the UI component you can usually do without directly binding the UI component to a backing bean. If you really need to do the UI binding you probably can have an intermediate request scoped bean that you can bind UI components to. I believe I saw some solution along those lines on the web a while back….

               

              • 4. Re: Richfaces 4 not loading some scripts when page is revisited
                feuyeux

                We met this issue also.

                 

                Is that really related with session scope beans? If so, I think it's an issue of JSF2.x.

                I cannot fix this issue after removed all sessionscoped bean.

                • 5. Re: Richfaces 4 not loading some scripts when page is revisited
                  jboss_mario

                  I just upgraded Mojarra JSF2 to 2.1.11 and it works the same (bad). And same problem when using MyFaces 2.1.8. Is the problem really in JSF? I doubt it.

                  The workaround suggested above by teme_h (an intermediate request-scoped bean) is not solving it either.

                   

                  Does this issue have anything to do with our problem?

                  https://issues.jboss.org/browse/RF-12358