cancel
Showing results for 
Search instead for 
Did you mean: 

'Invalid assignment left-hand side' error when setting param

gilles
Champ in-the-making
Champ in-the-making
When trying to set a parameter of an action called from javascript, I get an  'Invalid assignment left-hand side' error.
I follow exactly what's explained on the wiki (http://wiki.alfresco.com/wiki/Custom_Actions et http://wiki.alfresco.com/wiki/JavaScrip … Action_API)
But this code returns the error:
myAction.parameters.anything-name= "any";

Any idea?
(should I post the code?)
Thanks
3 REPLIES 3

lista
Star Contributor
Star Contributor
Definitely, post the code! Smiley Happy

gilles
Champ in-the-making
Champ in-the-making
Extract of my action-services-context.xml:

<bean id="createProjectBundle" class="org.eve.repo.action.executer.CreateProjectBundleActionExecuter" parent="action-executer">
      <property name="eveService">
         <ref bean="EveService"/>
      </property>
      <!–
      <property name="applicableTypes">
         <list>
            <value>{http://ec.europa.eu/eve/model/1.0}activity</value>
            <value>{http://www.alfresco.org/model/content/1.0}folder</value>
         </list>
      </property>
      –>
   </bean>
My ActionExecuter:
package org.eve.repo.action.executer;

import java.util.List;

import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.eve.EveService;
import org.alfresco.repo.action.ParameterDefinitionImpl;

public class CreateProjectBundleActionExecuter extends ActionExecuterAbstractBase
{
   
    public static final String NAME = "createProjectBundle";

    public final static String PARAM_BUNDLE_NAME = "bundle-name";

    public final static String PARAM_BUNDLE_TITLE = "bundle-title";

    public final static String PARAM_BUNDLE_DESCRIPTION = "bundle-description";
   
/**
     * The eve service
     */
    private EveService eveService;

    /**
     * Set the eve service
     *
     * @param eveService
     *            the eve service
     */
    public void setEveService(EveService eveService)
    {
        this.eveService = eveService;
    }
    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
    {
        eveService.createProjectBundle(actionedUponNodeRef, (String) action.getParameterValue(PARAM_BUNDLE_NAME), (String) action.getParameterValue(PARAM_BUNDLE_TITLE), (String) action.getParameterValue(PARAM_BUNDLE_DESCRIPTION));

    }

    @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList)
    {
        // The title passed
        paramList.add(
         new ParameterDefinitionImpl(                       // Create a new parameter defintion to add to the list
            PARAM_BUNDLE_NAME,                              // The name used to identify the parameter
            DataTypeDefinition.TEXT,                       // The parameter value type
            true,                                           // Indicates whether the parameter is mandatory
            getParamDisplayLabel(PARAM_BUNDLE_NAME)));      // The parameters display label
        // The title passed
        paramList.add(new ParameterDefinitionImpl(PARAM_BUNDLE_TITLE,DataTypeDefinition.TEXT,false,getParamDisplayLabel(PARAM_BUNDLE_TITLE)));   
        // The description passed
        paramList.add(new ParameterDefinitionImpl(PARAM_BUNDLE_DESCRIPTION,DataTypeDefinition.TEXT,false,getParamDisplayLabel(PARAM_BUNDLE_DESCRIPTION)));   

        // TODO Associated with an action is a title and description. In addition, each parameter has a displayable title.
        // All these string should be retrieved from I18N bundles to ensure that the repository remains I18N'able.
        // see http://wiki.alfresco.com/wiki/Custom_Actions#Internationalization_.28I18N.29_of_the_action
    }

}
And the javascript launched trough the 'Run Action>Execute script' :
var createProjectBundle= actions.create("createProjectBundle");
createProjectBundle.parameters.bundle-name = "testbundle";
createProjectBundle.parameters.bundle-title= "testbundle-title";
createProjectBundle.parameters.bundle-description= "testbundle-description";
createPB .execute(space);
The line  'createProjectBundle.parameters.bundle-name = "testbundle";'  throws an 'Invalid assignment left-hand side' error

Thanks for help.
Gilles

gilles
Champ in-the-making
Champ in-the-making
Assigning the parameter like that: createProjectBundle.parameters["bundle-name"] = "testbundle";  solved the problem.
(Advised by rivarola on the french forum)