I am trying to improve an old application that uses Oracle ADF 12c.
I need to compute the file name before it will be downloaded.
Currently the download of the file is written like this.
<af:table value="#{DocListManagedBean.list}" var="row"
disableColumnReordering="true" varStatus="vs" id="t1"
columnStretching="column:c2" emptyText="#{PageLabels.emptyText}"
styleClass="AFStretchWidth">
<af:column width="100px" align="center">
<f:facet name="header">
<af:outputText value="#{PageLabels.document}"/>
</f:facet>
<af:commandImageLink shortDesc="#{PageLabels.downloadDocument} ID: #{row.idDocument}"
icon="/skin/images/icons/pdf_icon4.gif">
<af:setPropertyListener from="#{row.idDocument}"
to="#{DocListManagedBean.selectedIdDocument}" type="action"/>
<af:fileDownloadActionListener contentType="application/pdf"
filename="#{row.documentName}"
method="#{DocListManagedBean.downloadFileListener}"/>
</af:commandImageLink>
</af:column>
<af:column>
<f:facet name="header">
<af:outputText value="#{PageLabels.documentName}"/>
</f:facet>
<af:outputText value="#{row.documentName}"/>
</af:column>
</af:table>
And it should now be so that (based on the document id) the file name should be computed, i.e. concatenated from several elements that are not in the object, the list of which is presented in af:table.
I already have the method returning the new file name in managed bean (called generateDocumentFileName). This method based on selectedIdDocument field in DocListManagedBean computes the correct filename and saves it in another field DocListManagedBean named selectedDocumentNewFilename.
Is it possible (without changing - without adding another field to the type of object presented by af:table) before running the af:downloadFileListener method, to run another method in managed bean (my generateDocumentFileName) ? ... which would calculate the missing name, save it to the field selectedDocumentNewFilename in managed bean and then new filename will be available e.g. via
<af:fileDownloadActionListener contentType="application/pdf"
filename="#{DocListManagedBean.selectedDocumentNewFilename}"
method="#{DocListManagedBean.downloadFileListener}"/>
Where I should put a call to my generateDocumentFileName method in the code above or is it a stupid idea and I should have done it differently ?
Thanks for help,
koli
question from:
https://stackoverflow.com/questions/66045288/name-of-the-downloaded-file-in-affiledownloadactionlistener-calculated-direc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…