07-18-2017 09:44 AM
Hi,
test.ftl:
<@templateHeader/>
<@templateBody type="alfresco-guest">
<@region id="myForm" scope="template" />
</@>
<@templateFooter/>
My template instance
<template-instance>
<components>
<component>
<scope>template</scope>
<region-id>myForm</region-id>
<source-id>myForm</source-id>
<url>/com/solution/form</url>
</component>
</components>
</template-instance>
form folder contains the following files: form.get.html.ftl, form.get.js,form.get.html.desc.xml
form.get.js:
function main() {
// Widget instantiation metadata...
var widget = {
id : "Create",
name : "Alfresco.component.Create",
options : {
myparam: url.args['myparam']
}
};
model.widgets = [widget];
}
main();
If I call ...url/page/test.ftl?myparam=123
How I can catch the value of myparam in the client javascript form.js?
Thanks
Jamil
07-19-2017 04:30 AM
You can pass parameters to components by including them in the component binding within the page / template-instance XML. Take the following excerpt form the Alfresco default edit-metadata.xml template instance definition:
<component>
<region-id>edit-metadata</region-id>
<url>/components/form</url>
<properties>
<itemKind>node</itemKind>
<itemId>{nodeRef}</itemId>
<mode>edit</mode>
<submitType>json</submitType>
<showCaption>true</showCaption>
<showCancelButton>true</showCancelButton>
</properties>
</component>
The {nodeRef} refers to a URL parameter that is passed from the global page context to the component. Within the component (web script) itself, this is referred to via args.itemId (you should not use the url root object for this).
07-19-2017 04:30 AM
You can pass parameters to components by including them in the component binding within the page / template-instance XML. Take the following excerpt form the Alfresco default edit-metadata.xml template instance definition:
<component>
<region-id>edit-metadata</region-id>
<url>/components/form</url>
<properties>
<itemKind>node</itemKind>
<itemId>{nodeRef}</itemId>
<mode>edit</mode>
<submitType>json</submitType>
<showCaption>true</showCaption>
<showCancelButton>true</showCancelButton>
</properties>
</component>
The {nodeRef} refers to a URL parameter that is passed from the global page context to the component. Within the component (web script) itself, this is referred to via args.itemId (you should not use the url root object for this).
Explore our Alfresco products with the links below. Use labels to filter content by product module.