0

Primefaces 7.0, JSF 2.1.19

I am trying to replace richfaces 3.3.3 with primefaces 7.0 (and upgrade JSF to 2.1) and got a special behaviour from the fileUpload widget: When I first render the page it works without problems (no fileupload done, just render it), then I navigate again to the same page it is broken:

Edge 91

The fileupload component:

                    <p:fileUpload disabled="#{antragAttachments.fileUploadDisabled}" id="attachmentUpload" widgetVar="attachmentUpload" binding="#{antragAttachments.fileUpload}"
                        fileUploadListener="#{antragAttachments.fileUploadListener}" label="Durchsuchen..." uploadLabel="Datei anhängen" cancelLabel="Abbrechen" invalidFileMessage="test typ"
                        mode="advanced" fileLimit="1" sizeLimit="15728640" invalidSizeMessage="Der Dateianhang ist zu groß! Die maximale Größe beträgt 15MB!" previewWidth="1"
                        oncomplete="uploadComplete();" auto="true">
                    </p:fileUpload>

This is the (menu) component the navigate again to the xthtml:

    <ui:repeat  value="#{name}" var="item"  >
        <div id="menuOP" class="ebene#{item.shifting} #{item.selected ? 'divselected' : 'divnotselected'} #{item.spriteClass}">
            <p:commandLink immediate="#{item.immediate}" value="#{item.label}" rendered="#{item.enabled}" action="#{item.navigate}"
                styleClass="#{item.selected ? 'selected' : 'notselected'}" oncomplete="#{item.oncomplete}"/>
            <h:outputText id="menuNoLinkText" rendered="#{!item.enabled}" styleClass="disabled" value="#{item.label}" />
        </div>
    </ui:repeat>

I tried to remove the immediate, set the type to "submit", use h:commandLink (without the oncomplete of course) just to see if I can get this running somehow. Does not work.

I also looked at the Primefaces fileupload introduction from balusC, but my problem is not the fileupload, it is the second rendering. There is also a Primefaces forum entry about something similar, but the trick von melloware did not work also. What I do not understand, by the first click on the menu the rendering works fine and after every click on the menu-commandlink the browser console tells me that the widget is not available.

I found examples with similar problems, but there is most of the time a javascript call of the widget like PF('attachmentUpload').doSomething(), but this is not the case here.

EDIT:

I found out that when I first click on the commandlink the fileupload.js is loaded:

enter image description here

By the second click this is not the case anymore:

enter image description here

I also found a thread with the same problem: <p:layout> and <p:fileUpload> not working on page refresh, but there the only solution seems to be to take the css and js for fileupload and add it manualy to as resource... which is a little creepy...

Ande Hofer
  • 150
  • 2
  • 14
  • 1
    Why upgrade to an old version? – Jasper de Vries Jul 20 '21 at 09:58
  • @Jasper de Vries, because I am stuck with Java 7 and my investigation shows me that JSF 2.1 and PF 7 is the highest I can reach with this. Also stuck with JBoss EAP 6.1. (Can not remember which of this two makes it impossible to get a higher PF & JSF version) – Ande Hofer Jul 20 '21 at 10:01

0 Answers0