0

I have Set responseDocumentsVar in my view and it holds three values. For instance, PASPGP_CND,COVER_LTR,PERMIT_LTR. I used this variable in my xhtml and iterated using primesfaces component p:repeat as shown below. However the unexpected behavior is when I try to access "PASPGP_CND" letter, COVER_LTR is downloaded and when I try to access PERMIT_LTR ,PASPGP_CND is downloaded. Not sure why, what I access is not downloaded. Could anyone explain this behavior ?

<p:repeat   value="#{sessionView.appCycleEntity.reviewResponseEntity.reviewResponseDocuments.toArray()}"
     var="revResDocument"
        width="100%" styleClass="hideDataTableColumnsHistory">
        <div class="cardWrapper ui-g-12 ui-md-6 ui-lg-6">
            <div class="cardDisplay fileCard">
                <div class="cardTypeId">
                    <div class="icon"></div>
                </div>
                <div class="cardInfo">
                    <!-- card meta data -->
                    <dl class="cardMetaData clearfix">
                        <dt>
                        <p:commandLink id="filename${fileTypeCounter}_${fileCounter}"
                                value="#{sessionView.getLetterNameForSummaryScreen(revResDocument.letterTypeCode).length() gt 30 ? sessionView.getLetterNameForSummaryScreen(revResDocument.letterTypeCode).substring(0,30).concat('...') : sessionView.getLetterNameForSummaryScreen(revResDocument.letterTypeCode)}"
                                actionListener="#{recordDecisionController.retrieveLetter(revResDocument)}"
                                ajax="false" process="@this" onstart="PF('statusDialog').show()"
                                        oncomplete="PF('statusDialog').hide();" immediate="true"/>


                        </dt>
                     </dl>

                </div>
            </div>
        </div>
</p:repeat>

image shows how it is displayed to the user

In above image when I try to access 1, 3 is download and when I try to access 3, 2 is downloaded i.e. desired file not downloaded. I debugged on the java side, the attachment id passed to backend is also not correct.

I am sorry if I was not clear in explaining the question.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
KPDS
  • 11
  • 3
  • Hi, please always try to create a [mcve] and post version info – Kukeltje Feb 22 '19 at 14:58
  • @Kukeltje I am new to posting questions. I will try to create Minimal,Complete and Verifiable example as suggested by you. I am using primefaces 6.0 and Java 1.7. Were you able to understand my question ? Was I clear? If not, please ask me I try to answer what's not clear in my question. – KPDS Feb 22 '19 at 15:06
  • 1
    Related: read https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – Kukeltje Feb 22 '19 at 16:22
  • Java 101: a HashSet is unordered. Apparently you created a new one every time. – BalusC Feb 22 '19 at 17:49
  • @Kukeltje .. Hi Thank you for the response...the link that you shared explains JSTL v/s JSF tags. But the code that I posted does not have any JSTL tags so I am not sure why that synchronization is not happening when HashSet is used with p:repeat. – KPDS Feb 26 '19 at 15:01
  • @BalusC Thank you very much for the response. I understand HashSet is not an ordered one. HashSet is unordered that is why I do not see the same order of display every time I refresh the screen. My question is the how the var "revResDocument" at same time can be different at different places.I mean p:commandLink's value="#{revResDocument.letterTypeCode}" is ABC but value of the same variable that is passed in actionListener is different. ActionListener passes XYZ as the value of revResDocument, but it should be ABC. However, when I used list, the values of both attributes are in sync. – KPDS Feb 26 '19 at 15:15
  • @BalusC I am unable to understand this behavior. With list the values are in SYNC but with HashSet the values are not in SYNC. Please explain whenever you get time to respond. Thank you in advance. – KPDS Feb 26 '19 at 15:17
  • As said, the bahavior will occur when you created a new one every time. E.g. the bean is request scoped, or you're calling DB in getter instead of in postconstruct. The ordering of the one HashSet isn't necessarily the same as the other HashSet having exactly the same entries. – BalusC Feb 26 '19 at 16:51
  • Hi @BalusC.. I am sorry to ask so many questions. I admire your explanations and I follow your explanations on your blog but this I am not able to understand. When I replaced ui:repeat with p:repeat the download works as expected. Note :the reviewResponseDocuments is still HashSet. HashSet is behaving different with p:repeat and ui:repeat – KPDS Feb 27 '19 at 15:23

0 Answers0