Alfresco's default update action just replaces the contents of the document without changing its name and other properties.
This blog deals with overriding the default update action with your customized one.
As update action consists of a dialog in which you needs to browse and select a new document from your local machine, a new upload jsp file needs to be written which will take care of the upload part and will perform the function which you have over ridden.
If you want to add a dialog on the action you provide, then you have to register it into 'web-client-config-dialogs-custom.xml' (here after we will mention it as 'dialogs-custom.xml')
Like, if you want to display your custom view details page on clicking of view details link action, you can define it here with bean reference for that particular jsp.
Suppose if you have defined your custom update link action on clicking which, you want your custom update jsp page should appear, you can define it here like –
[Note – I am just providing the update action and its dialog here, rest you can change as per the steps I have mentioned here]
Actions Tag in actions-custom.xml
<!-- Update document -->
<action id="update_doc">
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.UpdateDocEvaluator</evaluator>
<label-id>update</label-id>
<image>/images/icons/update.gif</image>
<action-listener>#{CheckinCheckoutDialog.setupContentAction}</action-listener>
<action>dialog:updateFile</action> <!-- Dialog Name -->
<params>
<param name="id">#{actionContext.id}</param></params>
</action>
<!-- Dialog Tag in dialogs.xml -->
<dialog name="updateFile" page="/jsp/extension/custom-update-file.jsp" managed-
bean="UpdateFileDialog" icon="/images/icons/update_large.gif" title-id="update"
description-id="updatefile_description"/>
Now when you use customized update action link, your custom update jsp file will appear with update button.
When you select the file from your local system and click on update, your overridden method will get called.
Here is the class file with overridden Update method.
Do not forget to register your bean into faces-config-custom.xml
<managed-bean>
<description>The bean for the Update File Screen.</description>
<managed-bean-name> UpdateFileDialog</managed-bean-name>
<managed-bean-class>
com.test.update.UpdateFileDialog
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>property</property-name>
<value>#{CCProperties}</value>
</managed-property>
</managed-bean>
No comments:
Post a Comment