cancel
Showing results for 
Search instead for 
Did you mean: 

Force refresh after Share custom action

warinner
Champ in-the-making
Champ in-the-making
I have a couple of custom actions for Share that I have gotten working but for one pesky detail: the actions add or remove aspects and properties that will in turn affect the display of items on the action menu.

For example, in document-actions.get.config.xml, I have the following:


      <actionSet id="document">
         <action type="action-link" id="onActionArchive" permission="archive" label="actions.document.archive" />     
         <action type="action-link" id="onActionRestore" permission="restore" label="actions.document.restore" />

In evaluator.lib.js, I have the following:


   documentAndFolder: function Evaluator_documentAndFolder(node, permissions, status, actionLabels)
   {



      /* Set permissions for archiving */
     try
     {
         /* restore only if archived */
         if (node.hasAspect("ra:archived"))
         {
           permissions["restore"] = true;
         }
     
         /* always allowed to archive */
         permissions["archive"] = true;
      }
      catch (e)
      {
         /* eat exception thrown if Folders archiving not installed */
         logger.log("Folders archiving content model is not installed!");
      }

     …


The custom archive ultimately invokes a Java backed webscript that among other things, adds the ra:archived aspect to the target node.

However, after the action has been executed, the old action menu is still displayed, i.e., the onActionRestore action is not displayed. Manually refreshing the page will cause the action menu to display the onActionRestore action in the menu but I am looking for some way to do this programmatically.

N.B. I have equivalent actions defined for Explorer. In Explorer, I have a JSF bean that does a


         UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();


to refresh after the action. I am looking for its Share equivalent.

Andrew Warinner
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
It depends how your onActionArchive and onActionRestore functions have been written… you either need to call
YAHOO.Bubbling.fire("metadataRefresh");

or, if you're using the JSON structure approach
this.modules.actions.genericAction(
{
   success:
   {
      event:
      {
         name: "metadataRefresh"
      },
      …

Thanks,
Mike

warinner
Champ in-the-making
Champ in-the-making
That did the trick!

Many, many thanks, Mike.