Skip to content

Commit

Permalink
add no-op editFileMetadata() to FilePage to prevent errors #8305
Browse files Browse the repository at this point in the history
As of Payara 6/JSF 4/Jakarta EE 10, this syntax doesn't work:

action="#{bean[editFileAction]()}"

(Or it logs errors in server.log at the very least.)

So we switch to this syntax:

action=#{bean.editFileMetadata()}"

This means we have to make sure the method exists on all the beans,
though, or we get errors. (It's unclear why we weren't seeing errors
before!) So we add the method to FilePage, which gets passed as bean.

We also remove the now unused "editFileAction".
  • Loading branch information
pdurbin committed Aug 10, 2023
1 parent 44874b3 commit 8993d9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/FilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1246,4 +1246,13 @@ public boolean isHasPublicStore() {
return settingsWrapper.isTrueForKey(SettingsServiceBean.Key.PublicInstall, StorageIO.isPublicStore(DataAccess.getStorageDriverFromIdentifier(file.getStorageIdentifier())));
}

/**
* This method only exists because in file-edit-button-fragment.xhtml we
* call bean.editFileMetadata() and we need both FilePage (this bean) and
* DatasetPage to have the method defined to prevent errors in server.log.
*/
public String editFileMetadata(){
return "";
}

}
3 changes: 1 addition & 2 deletions src/main/webapp/file-edit-button-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
configureTools - for single file, list of configureTools for the file
bean - the named value of the backing bean for the below method(s), also used by isFilePg param
unrestrictFileAction - name of the method on the above bean to call for unrestrict (method must take a boolean)
editFileAction - for selected files, name of method on the above bean to send for edit metadata
refreshTagsPopoupAction - for selected files, name of method on the above bean to refresh tags popup
-->
</ui:remove>
Expand All @@ -38,7 +37,7 @@
<p:commandLink onclick="if (!(#{fileMetadata!=null} || testFilesSelected()))
return false;"
oncomplete="if(#{fileMetadata!=null}) window.location.assign('/editdatafiles.xhtml?selectedFileIds=#{fileMetadata.dataFile.id}&#38;datasetId=#{fileMetadata.datasetVersion.dataset.id}#{isFilePg?'&#38;referrer=FILE':''}&#38;version=#{fileMetadata.datasetVersion.version}')"
action="#{bean[editFileAction]()}">
action="#{bean.editFileMetadata()}">
<h:outputText value="#{bundle['file.metadata']}"/>
</p:commandLink>
</li>
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/filesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@
<ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
<ui:param name="bean" value="#{DatasetPage}"/>
<ui:param name="unrestrictFileAction" value="restrictFiles"/>
<ui:param name="editFileAction" value="editFileMetadata"/>
<ui:param name="refreshTagsPopoupAction" value="refreshTagsPopUp"/>
</ui:include>
</ul>
Expand Down

0 comments on commit 8993d9a

Please sign in to comment.