This discussion is archived
1 2 Previous Next 16 Replies Latest reply: Oct 15, 2009 3:41 AM by 638892 RSS

Duplicate display of component after page refresh(F5)

638892 Newbie
Currently Being Moderated
Hi,
I am using jdev 11gR1.

In my JSF page , i have a af:foreach that creates multiple panel accordion and for each accordion i have another af:foreach that creates its corresponding links.

If i refresh the page (using F5) i sometimes get duplicated panel accordion or in some other cases the content of the panel accordion duplicated.

Thank in advance
Emile BITAR
  • 1. Re: Duplicate display of component after page refresh(F5)
    didier - oracle Journeyer
    Currently Being Moderated
    Hi Emile,

    did you specify the ID for each components on your page ?

    Regards,

    Didier.
  • 2. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Bonjour,

    Thank you for your reply.
    Actually no due to the fact that each component is created dynamically.
    <af:forEach var="itm"
           items="#{CurrentUserBean.extCodesMenu.userMenuHeaderList}">
    <af:panelBox text="#{itm.description} "
              showDisclosure="true"
              rendered="true"               
              inlineStyle="width:270px;height:125px;spacing:1px;padding:1px;">
      <af:panelGroupLayout layout="scroll"
                     valign="top"
                     inlineStyle="height:100px;spacing:0px;padding:0px;">
        <af:panelList inlineStyle="spacing:0px;padding:0px;border:0px;">
          <af:forEach var="i"
                items="#{itm.osaUserMenuDetailOsaUserMenuHdrList}">
         <af:goLink text="#{i.subMenuOid.libelle}"
                 styleClass="goLink"
                 rendered="#{i.subMenuOid ne null}"
                 disabled="#{CurrentUserBean.accessRights[i.subMenuOid.menuCode] eq false}" 
                 destination="/faces/#{i.subMenuOid.prefix}/#{i.subMenuOid.proc}x?_lang=#{view.locale}"/>
         <af:panelGroupLayout rendered="#{i.subRepOid ne null}" inlineStyle="spacing:0px;padding:0px;border:0px;"
                        valign="middle">
           <af:image source="/common/explorer/images/doc.png" inlineStyle="spacing:0px;padding:0px;border:0px;"/>
           <af:commandLink text="#{i.subRepOid.description}"
                     styleClass="goLink"
                     disabled="#{CurrentUserBean.accessRights[i.subRepOid.dsbRepCategory.code] eq false}" 
                     action="#{DsbRepManagerBean.editSynchro}">
             <f:param name="id"
                   value="#{i.subRepOid.id}"/>
           </af:commandLink>
         </af:panelGroupLayout>
          </af:forEach>
        </af:panelList>
      </af:panelGroupLayout>
    </af:panelBox>
    </af:forEach>
    if you can show me how to do it i will implement it and keep you posted.

    Best Regards
    Emile BITAR
  • 3. Re: Duplicate display of component after page refresh(F5)
    487442 Expert
    Currently Being Moderated
    Hi Émile,

    Here are some guidelines:

    1. #{i.subMenuOid ne null} --> use the empty operator instead so #{!empty i.subMenuOid}
    2. Use af:iterator, it's much more stable and predictable than af:forEach
    3. Specify the ids even if the components are within iterating component, the final client id will still be different based on the element index within the iterated collection
    4. #{CurrentUserBean.accessRights[i.subRepOid.dsbRepCategory.code] eq false} --> #{!CurrentUserBean.accessRights[i.subRepOid.dsbRepCategory.code]} (faster for the EL parser and evaluation)
    5. <f:param name="id" value="#{i.subRepOid.id}"/> (why?)


    Regards,

    ~ Simon
  • 4. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi Simon,


    3. Specify the ids even if the components are within iterating component, the final client id will still be different based on the element index within the iterated collection
    kindly elaborate more on how its done. cause i get error.

    5. <f:param name="id" value="#{i.subRepOid.id}"/> (why?)
    just to pass parameterfor called method

    Regards,
    Emile BITAR
  • 5. Re: Duplicate display of component after page refresh(F5)
    487442 Expert
    Currently Being Moderated
    Hi Émile,

    3. That's one of the main differences between af:forEach and af:iterator. Here's a description of each
    - <af:forEach/> is a replacement of <c:foreach/>, it executes its body for every item in the collection. As the result, the final JSF parent component of the forEach contains n*m children where n is the number of element in the collection and m the amount of components inside the forEach. In that mode, since the multi component are not within a Namingcontainer, you may get a duplicate id error
    - <af:iterator/> is a fully fledged JSF component (albeit renderer-less) that is also a NamingContainer. The iterator multi process its children during the various JSF phases (including rendering). Thus, the iterator component itself only contains m children, but stamp a different clientId for every element in the collection. therefore, using iterator, you can specify the id on the tag and don't get the duplicate id error.

    5. Why not using <f:setPropertyActionListener/> instead? That's actually a bit faster from the processing point of view. However the param remains liveable with and should not be the source of your error.


    Regards,

    ~ Simon
  • 6. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi Simon,

    Last question the af:iterator dispaly data vertically , how to display them horizontally.

    Thank you in advance
    Emile BITAR
  • 7. Re: Duplicate display of component after page refresh(F5)
    487442 Expert
    Currently Being Moderated
    Hi Émile,

    Really? Now that's weird. I know that panelGroupLayout and iterator have a synergic effect (aka semi hard coded interaction where the panelGroup actually consider every stamp like a children) so that would be explainable if the layout was set to vertical. Let me check the scroll layout feature ... Hmm it does seem to consider scroll as vertical... You could add another panelGroupLayout without layout defined between the scroll layout and the iterator. Another way to be to not use the scroll layout on the panelGroup, but I assume that one is required in your case if you explicitly specified it.


    Regards,

    ~ Simon
  • 8. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi,

    How can i display the iterator as a grid (4X4) or (5X3).
    Do i put it in a table because the panelGrid does not work.
    Any suggestions.


    Emile BITAR
  • 9. Re: Duplicate display of component after page refresh(F5)
    Sireesha Pinninti Expert
    Currently Being Moderated
    Hi Emile,

    You can't achieve this kind of requirement using table component. Why the panelGrid doesn't work?

    Sireesha
  • 10. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi,

    If i put PanelGrid with columns=3 for example or whatever the iterator displays may panelBox in vertical one column.

    and i need to have it as a grid

    Any hints
  • 11. Re: Duplicate display of component after page refresh(F5)
    Sireesha Pinninti Expert
    Currently Being Moderated
    Hi Emile,

    I didn't understand it clearly, following is a sample code(using forEach) which displays the data in grid kind of thing:
    //I  used forEach as it was easy for me to test with static data, you can just replace forEach with iterator
            <h:panelGrid columns="3">
                <af:forEach step="1" begin="0" end="7" var="count">
                    <af:outputText value="Test"/>
                </af:forEach>
            </h:panelGrid>
    Sireesha
  • 12. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi ,
    Yes its true, but i need to replace af:foreach with af:iterator in order to be able to assign ids to dynamic component.

    That my problem, with af:foreach the poanegrid works but not with af:iterator

    How to solve this ...

    Emile BITAR
  • 13. Re: Duplicate display of component after page refresh(F5)
    Sireesha Pinninti Expert
    Currently Being Moderated
    Hi Emile,
    in order to be able to assign ids to dynamic component
    Are you talking about assigning dynamic ids to components by providing EL expression for id property? If so, Id doesn't support EL expressions.

    Sireesha
  • 14. Re: Duplicate display of component after page refresh(F5)
    638892 Newbie
    Currently Being Moderated
    Hi,

    That's why i user af:iterator because it does not flag duplicate id.

    THX
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points