08-11-2017 04:03 AM
In relation to the question getParametersValue is empty , i have built a surf extensions:
==================================================================
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.otp"/>
<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"/>
</field-visibility>
<appearance>
<field id="my_form_sign_firma.otp" label-id="property.form.sign.my_form_sign_firma.otp">
<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>
</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) {
paramList.add(new ParameterDefinitionImpl("my_form_sign_firma.otp", DataTypeDefinition.TEXT, true, getParamDisplayLabel("my_form_sign_firma.otp")));
paramList.add(new ParameterDefinitionImpl("my_form_sign_firma.luogo", DataTypeDefinition.TEXT, true, getParamDisplayLabel("my_form_sign_firma.luogo")));
paramList.add(new ParameterDefinitionImpl("my_form_sign_firma.motivo", DataTypeDefinition.TEXT, true, getParamDisplayLabel("my_form_sign_firma.motivo")));
paramList.add(new ParameterDefinitionImpl("my_form_sign_firma.username", DataTypeDefinition.TEXT, true, getParamDisplayLabel("my_form_sign_firma.username")));
paramList.add(new ParameterDefinitionImpl("my_form_sign_firma.password", DataTypeDefinition.TEXT, true, getParamDisplayLabel("my_form_sign_firma.password")));
}
public void setContentService(ContentService contentService) {
this.contentService = contentService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public void setConfigurazioniBean(ConfigurazioniBean configurazioniBean) {
this.configurazioniBean = configurazioniBean;
}
}
================================================================
i fill the form alfresco "popup" when click on the custom action label and click on the ok button for send the post of the form to my action java, but it's return always the error "A value for the mandatory parameter "my_form_sign_firma.otp" has not been set on the rule "signed-as-aruba"" o any other field of the form.
whar i'm doing wrong? i don't understand this error !
08-11-2017 05:36 AM
Ahh - I can imagine what the problem is. The values in the POST body look correct for your form configuration. But one thing that might trip the whole thing up is that you include an underscore in the names of your variable. The underscore is used in a semi-special way within the Alfresco forms engine / service - it is used to encode a colon character, which you will find in the fields for regular node properties (forms for documents / folders). So when mapping the key-values to parameters it may convert the first underscore (after prop_ is removed) into a colon, thus not matching your defined action parameters. I usually prefer using camel-cased parameter names over any that include non-alphanumeric characters.
08-11-2017 04:28 AM
This error is straight forward - a parameter is usually deemed as "not provided" if it there either is no such field in the form or the input of the field is empty, while the parameter is defined as mandatory - which you did via the parameter definitions where you set the specific flag to "true". If you have filled out all the fields, then this error should not occur - if it still does, start analysing where the data may be dropped (or where you may have a typo) by checking the HTTP POST body of the form (use network view of the browser developer tools).
08-11-2017 05:30 AM
Hi Axel ty for fast response , indeed i want all the parameter beeing mandatory and i fill all the field on the form , i'm sure of that from the post json message i analize with the browser web tool, but i keep find this error :
POST:
{"alf_destination":"workspace://SpacesStore/b7929334-ef6c-4b69-8343-c988a8eeb330","prop_my_form_sign_firma
#dot#otp":"Test","prop_my_form_sign_firma#dot#luogo":"Test","prop_my_form_sign_firma#dot#motivo":"Test"
,"prop_my_form_sign_firma#dot#username":"Test","prop_my_form_sign_firma#dot#password":"Test"}
RESPONSE:
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP
server which prevented it from fulfilling the request."},
"message" : "org.alfresco.service.cmr.rule.RuleServiceException: 07110002
A value for the mandatoryparameter my_form_sign_firma.username
has not been set on the rule item signed-as-aruba","exception" : "",
"callstack" :
[
],
"server" : "Community v5.1.0 (r122274-b3) schema 9.016",
"time" : "11-ago-2017 11.24.22"
}
Any other suggestion?
08-11-2017 05:36 AM
Ahh - I can imagine what the problem is. The values in the POST body look correct for your form configuration. But one thing that might trip the whole thing up is that you include an underscore in the names of your variable. The underscore is used in a semi-special way within the Alfresco forms engine / service - it is used to encode a colon character, which you will find in the fields for regular node properties (forms for documents / folders). So when mapping the key-values to parameters it may convert the first underscore (after prop_ is removed) into a colon, thus not matching your defined action parameters. I usually prefer using camel-cased parameter names over any that include non-alphanumeric characters.
08-11-2017 06:22 AM
Aaaaaargh , 3 days of my life for this bullshit , using the camelCase syntax it's all ok now.
Just for let it now even the "." give the same problem so in the end:
my_form_sign_firma.luogo WRONG
myFormSignFirma.luogo WRONG
myFormSignFirmaLuogo OK
Explore our Alfresco products with the links below. Use labels to filter content by product module.