-
Define and configure the Go-to-Google action.
This action is different from all the others that we have implemented in that it is not backed by a specific JavaScript function. Instead it is of type link and just takes you to the Google search home page when clicked.
Open the add-doclib-actions-extension-modules.xml Surf Extension module file that we have used so far in this tutorial, it is located in the aio/aio-share-jar/src/main/resources/alfresco/web-extension/site-data/extensions directory.
Then define the Go-to-Google DocLib action as follows:
<extension> <modules> <module> <id>Add Document Library Actions (Send-as-Email, Call WS, Show Msg, Go to Google)</id> <version>1.0</version> <auto-deploy>true</auto-deploy> <configurations> <config evaluator="string-compare" condition="DocLibActions"> <actions> ... <action id="alfresco.tutorials.doclib.action.goToGoogle" icon="google" type="link" label="alfresco.tutorials.doclib.action.goToGoogle.label"> <param name="href">http://www.google.com</param> <param name="target">_blank</param> </action> </actions> </config> </configurations> </module> </modules> </extension>
The google-16.png icon for this action should already be available if you implemented the Send-As-Email action above.
-
Add the label for the Go-to-Google action to the i18n resource file.
Open up the aio-share-jar.properties file locate din the aio/aio-share-jar/src/main/resources/alfresco/web-extension/messages directory. Then add the following property to it:
alfresco.tutorials.doclib.action.goToGoogle.label=Go to Google
-
Define where in the user interface the Go-to-Google action should be displayed.
This is done in the add-doclib-actions-extension-modules.xml file in the section called actionGroups::
<extension> <modules> <module> <id>Add Document Library Actions (Send-as-Email, Call WS, Show Msg, Go to Google)</id> <version>1.0</version> <auto-deploy>true</auto-deploy> <configurations> <config evaluator="string-compare" condition="DocLibActions"> <actions> ... </actions> <actionGroups> <actionGroup id="document-browse"> ... <action index="403" id="alfresco.tutorials.doclib.action.goToGoogle" /> </actionGroup> <actionGroup id="document-details"> ... <action index="403" id="alfresco.tutorials.doclib.action.goToGoogle" /> </actionGroup> <actionGroup id="folder-browse"> <action index="403" id="alfresco.tutorials.doclib.action.goToGoogle" /> </actionGroup> </actionGroups> </config> </configurations> </module> </modules> </extension>
The Go-to-Google action will be displayed in the same views as the other actions that we have implemented, plus for folders when in Browse view. We give it an index of 403 so it is displayed after all the other custom DocLib actions that we have implemented.
-
The implementation of the Go-to-Google DocLib action is now complete, not much to it
really, it’s very easy to add a DocLib action for navigating to an external
page. To try it out build and start the application server as follows:
/all-in-one$ ./run.sh build_start
-
Now, log in to Share (http://localhost:8080/share). You will see the new
Go-to-Googleaction in the Browse view when hovering over for example a folder
and clicking More… in the pop-up menu:
Note that the other DocLib actions are not visible when you look at the Folder actions. This is because they have not been configured to be visible for this view type. Invoking the “Go to Google” action will open up www.google.com in a different tab in the Browser.