cancel
Showing results for 
Search instead for 
Did you mean: 

How to catch a ftl param from a region component

jamilnour
Star Contributor
Star Contributor

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

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

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).

View answer in original post

1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator

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).

Welcome to the new Hyland Connect. Get started or submit feedback.