f:attribute inside p:fileUpload

UI Components for JSF
Post Reply
mikic
Posts: 10
Joined: 20 Jul 2016, 14:51

06 Jan 2017, 13:55

Hello,
I have a p:fileUpload component with a listener method defined and I need to pass additional attributes to use during file handling. My idea is to use the f:attribute element inside the p:fileUpload component as follow:

Code: Select all

            <p:fileUpload fileUploadListener="#{dataObjectBean.handleFileUpload}" mode="advanced" dragDropSupport="true">
              <f:attribute name="simpleAtt" value="mySimpleAtt" />
              <f:attribute name="activeFlag" value="#{dataObjectBean.isActive}" />
            </p:fileUpload>
The problem is that when the handleFileUpload() method is invoked, the map of attributes obtained from the component only contains the "simpleAtt" and not the "activeFlag" attribute.

Code: Select all

  public void handleFileUpload(FileUploadEvent event)
  {
    Map myAttributes = event.getComponent().getAttributes();
    LOG.info(myAttributes.get("simpleAtt")); // displays value
    LOG.info(myAttributes.get("activeFlag")); // displays null
  }
I even tried using a very simple attribute, but this was not available in the list of attributes either:

Code: Select all

                      <f:attribute name="trueAttr" value="#{true}" />
It appears that only attributes with string literals are being added to the Map of attributes in the fileUpload component. How can I get dynamic attributes passed to the listener method?

Please note that this approach should work according to http://stackoverflow.com/questions/1723 ... 2#17236222
PF 6.0, JSF 2.2, Payara 4.1.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests