You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Manuel K (Jira)" <de...@myfaces.apache.org> on 2023/03/08 08:26:00 UTC

[jira] [Created] (MYFACES-4590) NullPointerException when PrimeFaces FileUpload used in composite component

Manuel K created MYFACES-4590:
---------------------------------

             Summary: NullPointerException when PrimeFaces FileUpload used in composite component
                 Key: MYFACES-4590
                 URL: https://issues.apache.org/jira/browse/MYFACES-4590
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 4.0.0, 4.0.1
         Environment: primefaces-test project, jakarta branch 
            Reporter: Manuel K


Using the following composite component, an exception occurs upon rendering only on MyFaces but not on Mojarra. Please let me know if this is a PrimeFaces bug instead and I'll open an issue there.

 
{code:java}
<?xml version="1.0" encoding="UTF-8"?>

<ui:component xmlns="http://www.w3.org/1999/xhtml"
              xmlns:cc="http://xmlns.jcp.org/jsf/composite"
              xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
              xmlns:p="http://primefaces.org/ui"
              xmlns:h="http://xmlns.jcp.org/jsf/html">
    <cc:interface>

        <cc:attribute name="fileUploadListener"
                      required="true"
                      method-signature="void listener(org.primefaces.event.FileUploadEvent)"/>

        <cc:attribute name="update"
                      type="java.lang.String"/>

        <cc:attribute name="allowTypes"
                      default="/.*/"/>
        <cc:attribute name="accept"/>
        <cc:attribute name="fileLimit"
                      default="1"/>
        <cc:attribute name="sizeLimit"/>
        <cc:attribute name="multiple"
                      default="false"/>
    </cc:interface>
    <cc:implementation>
        <div id="#{cc.clientId}">
            <p:fileUpload id="fileUpload"
                          listener="#{cc.attrs.fileUploadListener}"
                          update="#{cc.attrs.update}"
                          fileLimit="#{cc.attrs.fileLimit}"
                          sizeLimit="#{cc.attrs.sizeLimit}"
                          auto="true"
                          accept="#{cc.attrs.accept}"
                          sequential="true"
                          allowTypes="#{cc.attrs.allowTypes}"
                          multiple="#{cc.attrs.multiple}"/>
        </div>
    </cc:implementation>
</ui:component> {code}
The exception:

 

 
{code:java}
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "org.primefaces.component.fileupload.FileUpload.getSizeLimit()" is null
    at org.primefaces.component.fileupload.FileUploadRenderer.encodeScript (FileUploadRenderer.java:127)
    at org.primefaces.component.fileupload.FileUploadRenderer.encodeEnd (FileUploadRenderer.java:79)
    at jakarta.faces.component.UIComponentBase.encodeEnd (UIComponentBase.java:634) {code}
You can find my reproducer here: [https://github.com/mkomko/primefaces-test/tree/file-upload-npe]

 

Thank you very much in advance as always :).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)