cancel
Showing results for 
Search instead for 
Did you mean: 

Action Executer vs Java backed Webscript

m_scapoli
Champ in-the-making
Champ in-the-making
Hello, I've implemented a DocumentDetails Action that calls a Dilog containing a Form and pass some input to an Action Executer class.
The declaration for this action should be like this:
<action id="ext.plugin.doclib.action.version-difference" type="javascript" label="action.label.version-diff"
            icon="../../../components/documentlibrary/actions/version-diff-icon">
               <param name="function">onActionFormDialog</param>
               <param name="itemKind">action</param>
               <param name="itemId">version-difference</param>
               <param name="mode">create</param>
               <param name="destination">{node.nodeRef}</param>
               <param name="failureMessage">message.version-diff.failure</param>
               <evaluator>evaluator.doclib.action.versionDiffMimetype</evaluator>
         </action>

I've implemented the Dialog with inside the Form and I've written the ActionExecuter class that handle the parameters that I pass into the class and does the job I want
    /*
     * Form parameters:
     */
    public static final String PARAM_VDIFF_MAJOR_VERS = "major-vers-number";
    public static final String PARAM_VDIFF_MINOR_VERS = "minor-vers-number";
    …
    …
       @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
       
        paramList.add(new ParameterDefinitionImpl(
                PARAM_VDIFF_MAJOR_VERS,
                DataTypeDefinition.TEXT,
                true,
                getParamDisplayLabel(PARAM_VDIFF_MAJOR_VERS)));
    …
    …

My problem now is: if I wanted that after the ActionExecuter class has done the job the Action returns Json objects and bring me to a page that loads this Json Objects, how can I do this?

I know that for implement an action that load a page I've to write the action with the type="pagelink" and refer to a webscript that extends the DeclarativeWebScript class, the class produce a model and then this is loaded in the page that the action calls like in this post in this post I had written a while ago: https://forums.alfresco.com/en/viewtopic.php?f=48&t=43936 and this is the result that I want to have:

[img]http://desmond.imageshack.us/Himg341/scaled.php?server=341&filename=docdiffpagejson.png&res=medium[/img]

More precisely: there is a method to implement a Custom Action that popup a Dialog with Form to recive some data to pass to a Class that elaborate the data and then brings me to a Page that visualize this data?

Thanks in advance for the help

Regards
5 REPLIES 5

m_scapoli
Champ in-the-making
Champ in-the-making
ok I understand that I can return a value from my ActionExecutioner class using this I think (not tryed yet)


/** Standard action result parameter name */
   public static String PARAM_RESULT = "result";

   public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) {    
       if (this.nodeService.exists(actionedUponNodeRef))
       {
           // Get the parent node                
           int count = this.nodeService.getChildAssocs(actionedUponNodeRef).size();
           ruleAction.setParameterValue(PARAM_RESULT, Integer.valueOf(count));
       }
   }

but how I can call a page when the Action is terminated?

mrogers
Star Contributor
Star Contributor
You can't.  

If you are running your action synchronously then you get the result and continue with the next page in the dialog.

m_scapoli
Champ in-the-making
Champ in-the-making
You can't.  

If you are running your action synchronously then you get the result and continue with the next page in the dialog.
ok so how can I run the action asynchronously?

the other choice is to use a <action id="…" type="pagelink" action and java backed webscript passing the parameters through the URL like "http://localhost:8080/alfresco/service/mywebscript?myparameter=value" but how can I do this through a Dialog Form?
It's not possible to call the onActionFormDialog in a pagelink action and then pass the parameters from the form to the URL?

m_scapoli
Champ in-the-making
Champ in-the-making
I've found this in the Wiki: Dialog_Framework
[size=150]Simple Dialogs[/size]
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
To launch any dialog an action is prefixed with dialog:. Whenever the Alfresco navigation handler see a dialog prefix on an action the current page is added to a stack so it knows where to come back to when the dialog is closed.

is for this reason that I can't call a page after popping up a dialog, right? Because of the intrinsic mechanism of the Dialog Framework, right?

m_scapoli
Champ in-the-making
Champ in-the-making
Hello again, in this days I've tried another approach, probably more raw and made by novice but I tried..
My pagelink type action call a page where, in the page template implementation, I call a site-webscript (diffhook.get.) that call the SimpleDeclarativeWebScript Example

share-config-custom.xml
<action id="ext.plugin.doclib.action.declarative" type="pagelink" label="Declarative"
                 icon="../../../components/documentlibrary/actions/version-diff-icon">
             <param name="page">version-difference?nodeRef={node.nodeRef}</param>
             <evaluator>evaluator.doclib.action.versionDiffMimetype</evaluator>
         </action>
diffhook.get.js
var connector = remote.connect("alfresco");
var data = connector.get("/docdiff/declarative.json");

// create json object from data
var result = eval('(' + data + ')');
model.diffhooked = result;
template-instances/page_template.xml
       
          ….

      <!– Custom Component –>
      <component>
         <region-id>doclib-custom</region-id>
         <url>/components/diffhook</url>  <!– call to the diffhook.get.js webscript –>
      </component>

   </components>
</template-instance>
all this code works fine, well I thought that I can try to implement a dialog with the YUI library directly for the diffhook.get.js (with a diffhook.get.html.ftl file) and handle the parameter passage through the Javascript code and build the URL with the parameters I've to pass to the repository webscript like that:
…some code to catch the passed parameters…

var connector = remote.connect("alfresco");
var data = connector.get("/docdiff/declarative.json?args=argument");

// create json object from data
var result = eval('(' + data + ')');
model.diffhooked = result;
sorry for the bad pseudocode but I have not managed to look the part on JavaScript, which I'm learning the basics at this time.. but the behind concept is this..

Again, is possible for me to implement in some manner an action that call a dialog for the insertion of the parameters, then pass the parameters through the diffhook.get.js and build the appropriate URL to pass to the webscript on the repository side?

Thanks in advance

Marco