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
Solved! Go to Solution.
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).
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).
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.