AnsweredAssumed Answered

getParameterValues() is empty when post on action

Question asked by 4535992 on Aug 9, 2017
Latest reply on Aug 11, 2017 by 4535992

i have a surf extensions like this on my share project:

==================================================================

alfresco/web-extensions/site-data/extensions/my-module-actions-extension-modules

==================================================================

<extension>
    <modules>
        <module>
            <id>signed-as-aruba</id>
            <version>${project.version}</version>
            <auto-deploy>true</auto-deploy>
            <configurations>
                
                <config evaluator="string-compare" condition="DocumentLibrary">
                    <indicators>                       
                        <indicator id="indicator.isSigned"
                            icon="signed-doc-16.png"
                            index="100"
                            label="indicator.isSigned.label">
                            <evaluator>alfresco.evaluator.isSignable</evaluator>
                        </indicator>
                    </indicators>
                    
                    <toolbar-actions>
                          <action type="action-link" id="doclib.action.signedAsAruba" label="menu.selected-items.signedAsAruba" />
                      </toolbar-actions>

 

                </config>
                
                <config evaluator="string-compare" condition="DocLibActions">
                    <actions>

 

                        <action id="doclib.action.signedAsAruba"
                            icon="signed-doc-16.png"
                            type="javascript"
                            label="doclib.action.signedAsAruba.label">
                            <param name="function">onActionFormDialog</param>
                            <param name="itemKind">action</param>
                            <param name="itemId">signed-as-aruba</param> <!-- Repository action id = Spring Bean id -->
                            <param name="mode">create</param>
                            <param name="destination">{node.nodeRef}</param>
                            <param name="successMessage">sign.doclib.action.signed.msg.success</param>
                            <param name="failureMessage">sign.doclib.action.signed.msg.failure</param>
                            <evaluator>alfresco.evaluator.isSignable</evaluator>
                        </action>

 

                        <action id="sign.doclib.action.callWebScript"
                                icon="callws"
                                type="javascript"
                                label="sign.doclib.action.callWebScript.label">
                            <param name="active">true</param>
                            <param name="function">onActionCallWebScript</param>
                            <param name="successMessage">sign.doclib.action.callWebScript.msg.success</param>
                            <param name="failureMessage">sign.doclib.action.callWebScript.msg.failure</param>
                        </action>
                    </actions>

 

                    <actionGroups>
                        <actionGroup id="document-browse">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>
                        <actionGroup id="document-details">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>

 

                        <actionGroup id="folder-browse">
                            <action index="400" id="doclib.action.signedAsAruba" />
                        </actionGroup>
                    </actionGroups>
                </config>

 

                <config evaluator="string-compare" condition="DocLibCustom">
                    <dependencies>
                        <js src="components/documentlibrary/custom-doclib-actions.js" />
                    </dependencies>
                </config>

 

                <!-- ====== -->
                <!-- FORMS  -->
                <!-- ====== -->
                <config evaluator="string-compare" condition="signed-as-aruba">
                    <forms>
                        <form>
                            <field-visibility>
                                <show id="my_form_sign_firma.opt"/>
                                <show id="my_form_sign_firma.luogo"/>
                                <show id="my_form_sign_firma.motivo"/>
                                <show id="my_form_sign_firma.username"/>
                                <show id="my_form_sign_firma.password"/>
                                <show id="my_form_sign_firma.tipo"/>
                            </field-visibility>
                            <appearance>
                              <field id="my_form_sign_firma.opt" label-id="property.form.sign.my_form_sign_firma.opt">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>    
                              <field id="my_form_sign_firma.luogo" label-id="property.form.sign.my_form_sign_firma.luogo">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>                                                        
                              <field id="my_form_sign_firma.motivo" label-id="property.form.sign.my_form_sign_firma.motivo">
                                    <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                              </field>
                              <field id="my_form_sign_firma.username" label-id="property.form.sign.my_form_sign_firma.username">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>
                              <field id="my_form_sign_firma.password" label-id="property.form.sign.my_form_sign_firma.password">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                              </field>
                              <field id="my_form_sign_firma.tipo" label-id="property.form.sign.my_form_sign_firma.tipo">
                                      <control template="/org/alfresco/components/form/controls/selectone.ftl"/>
                                    <control-param name="options">PADES,CADES,DETACHED</control-param>
                                    <control-param name="insertBlank">true</control-param>
                              </field>                      
                            </appearance>
                        </form>
                    </forms>
                </config>  
            </configurations>
        </module>
    </modules>
</extension>

===============================================================

 

,while in my repo project i have set:

 

==================================================================

alfresco/module/mymodule/context/webscript-context.xml

or

alfresco/module/mymodule/context/action-context.xml

==================================================================

   <bean id="signed-as-aruba" class="my.module.actions.SignAction.java" parent="action-executer">
        <property name="contentService">
            <ref bean="ContentService"/>
        </property>
        <property name="nodeService">
            <ref bean="NodeService"/>
        </property>
        <property name="configurazioniBean">
            <ref bean="configurazioniBeanCompleto" />
        </property>
    </bean>

============================================================

 

when  i start share and click on the label of the custom action on the right menu of the content, i 'm correctly redirect to the class java action i have realized:

 

================================================================

my.module.actions.SignAction.java

================================================================

public class SignAction extends ActionExecuterAbstractBase  {
    private static Log logger = LogFactory.getLog(SignAction.class);
    
    private ContentService contentService;
    private NodeService nodeService;
    
    private ConfigurazioniBean configurazioniBean;
    
    @SuppressWarnings("unchecked")
    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef)  {
        logger.debug("START SERVICE SignAction#executeImpl");
        try {        
            if (action.getParameterValues() == null || action.getParameterValues().size() == 0) {
                throw new Exception("NO parameters value are arrived here");//HERE THROW THE EXCEPTION
            }
            logger.debug("END SignAction#executeImpl");
        } catch (Throwable t) {
            throw new RuntimeException("Something is wrong",t);
        }
    }

 

    @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList) {

 

    }

 

    public void setContentService(ContentService contentService) {
        this.contentService = contentService;
    }

 

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }

 

    public void setConfigurazioniBean(ConfigurazioniBean configurazioniBean) {
        this.configurazioniBean = configurazioniBean;
    }
}

================================================================

 

but i always arrived to the java class of the action whit a null parameters values for the method org.alfresco.service.cmr.action.ParameterizedItem.getParameterValues() , i try everythng but i msut do some thing wrong with the configuration.

Outcomes