2 Replies Latest reply on Mar 28, 2011 12:55 PM by denebj

    [Resolved] RF 4 - JSF 2.0 - ViewScoped problem

    denebj

      Good afternoon

       

      Like usual, I have an issue

       

      My problem is that when I use @ViewScoped for some beans, the bean is still being re-initialized - And I am still in the same view.

       

      It happens like that :

       

      <h:form>

       

      <rich:extendeddatatable id="test"

      var="archive" ...>

       

      ...

       

      <rich:column width="80px" >

                                                        <f:facet name="header">

                                                                  <h:outputText value="Status" />

                                                        </f:facet>

       

                                                                            <a4j:commandLink

                                                                                                id="uploadImgWarning"

                                                                                                execute="@this"

                                                                                                oncomplete="#{rich:component('modal')}.show()"

                                                                                                render="modal"

                                                                                                rendered="#{archive.status eq '2'}">

       

                                                   <h:graphicImage

                                                      onmouseover="this.src='/images/warningHover.png';"

                                                      onmouseout="this.src='/images/warning.png';"

                                                      url="/images/warning.png"

                                                      style="border:0px" />

       

                                                <f:setPropertyActionListener

                                                      value="#{archive}"

                                                      target="#{bean.selectedArchive}" />

       

                                           </a4j:commandLink>

       

                                              </rich:column>

       

       

      <rich:popupPanel

        id="modal" 

                                              modal="true"

                                              width="350"">

       

                                              <f:facet name="header">

              <h:outputText value="Modal" />

                                              </f:facet>

       

      <h:outputText

                                                                                      id="idInput"

                                                                                      value="#{bean.selectedArchive.id}" />

       

      <a4j:commandButton

                                                                                      id="ok"

                                                                                      value="Validate"

                                                                                      execute="modal"

                                                                                      action="#{bean.validate}">

                                                                                      <a4j:ajax

                                                                                                event="complete"

                                                                                                render="test"

                                                                                                oncomplete="#{rich:component('modal')}.hide();"/>

                                                                            </a4j:commandButton>

       

      </rich:popupPanel>

       

       

      </h:form>

       

      In my bean the   <f:setPropertyActionListener> is working properly, the value is being set and the value is displayed in the pop up.

      But when I am going into "#{bean.validate}", all the values of my bean have been re-initialized !!!

       

      If I put the bean in session scope it is working :-/

       

      With the RF 3.3.3 I had set the bean with keepAlive and it was in request mode and it was perfectly working :-/

       

      Any idea ?

       

      Thank you very much !!!

        • 1. RF 4 - JSF 2.0 - ViewScoped problem
          boy18nj

          View scope was added in JSF 2.0. A bean in view scope persists while the same

          JSF page is redisplayed. (The JSF specification uses the term view for a JSF page.)

          As soon as the user navigates to a different page, the bean goes out of scope.

          If you have a page that keeps getting redisplayed, then you can put the beans

          that hold the data for this page into view scope, thereby reducing the size of the

          session scope. This is particularly useful for Ajax applications.

           

          In JSF lifecycle, first validations takes place then update model values. How can you say your values are being reinitalized?

           

          Use phase listener to see the lifecycle and check if new life cycle starts whenever your method calls take place.

          • 2. RF 4 - JSF 2.0 - ViewScoped problem
            denebj

            Allright,

             

            I finally had the time to look at this issue ^^ Problem solved, I had to add domElementAttachment="parent" to the popuppanel that was submititng information to my bean.

             

            Problem solve ^^