I have written the question about how to use dropzone.js with JSF (Use dropzone with JSF) and it was correctly answered by BalusC.
However I want to pass a parameter to the save() method and I am not able to do it. I have the dropzone component in a page similar to this: http://localhost:8080/application/image-album.xhtml?albumId=1
And in that page I have:
<h:form id="uploadForm" enctype="multipart/form-data" styleClass="dropzone">
<div class="fallback">
<h:inputFile id="file" value="#{uploadImageController.part}"/>
<h:commandButton id="submit" value="submit" />
</div>
</h:form>
And in the UploadImageController I have:
@PostConstruct
public void init() {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
albumId = Long.valueOf(externalContext.getRequestParameterMap().get("albumId"));
}
So theoretically I could use the albumId in the save() method. However the init() method is being called three times, the first time with the value 1 and the other two with the value null so it fails by NullPointerException.
Any workaround to this?