如何在alfresco中将表单添加到页面

如何在alfresco中将表单添加到页面,alfresco,freemarker,Alfresco,Freemarker,我在share config custom.xml配置文件中定义了表单,我有一个home.ftl页面。如何将配置文件中的表单定义与home.ftl页面关联?您可以使用内容类型打开共享表单 打开表格 function render(htmlPageId) { var contentType = "content_type"; var formHtmlId = htmlPageId+ "-metadata-form"; var url = YAHOO.lang

我在
share config custom.xml
配置文件中定义了表单,我有一个
home.ftl
页面。如何将配置文件中的表单定义与
home.ftl
页面关联?

您可以使用内容类型打开共享表单 打开表格

function render(htmlPageId) {
var contentType = "content_type";
    var formHtmlId = htmlPageId+ "-metadata-form";
    var url = YAHOO.lang
            .substitute(
                    "{serviceContext}components/form"
                            + "?itemKind=type&itemId={itemId}&mode=create&submitType=json"
                            + "&formId={formId}&showCancelButton=true&htmlid={htmlid}"
                            + "&destination={destination}&siteId={siteId}&containerId={containerId}&uploadDirectory={uploadDirectory}",
                    {
                        serviceContext : Alfresco.constants.URL_SERVICECONTEXT,
                        itemId : contentType,
                        itemKind : "model",
                        formId : "upload-folder",
                        destination : "workspace://SpacesStore/e9d60c89-823a-4e3e-abb2-522e59a09d0f",
                        siteId : "production",
                        containerId : "documentLibrary",
                        uploadDirectory : "/GM",
                        htmlid : formHtmlId
                    });

    Alfresco.util.Ajax.request({
        url : url,
        responseContentType : "html",
        execScripts : true,
        successCallback : {
            fn : function(response) {
                var formNode = YAHOO.util.Dom.get(formHtmlId);
                formNode.innerHTML = response.serverResponse.responseText;

            },
            scope : this
        },
        failureCallback : {
            fn : function(response) {
                Alfresco.logger.debug("onContentTypeChange failureCallback",
                        arguments);
            },
            scope : this
        }
    });
}
在-contentType中将您的内容类型传递到此处,选择您想要打开的表单类型

formHtmlId是html组件的id 像

<div id="${el}-renderForm" onload="render(htmlID)">
</div>


在这个函数中传递您当前的htmlId。

您可以通过
/components/form
webscript检索配置好的表单,这样您就可以使用javascript控制器将表单注入到页面中,正如@vikash在前面的回答中提到的那样,或者您可以使用Spring surf创建页面,您可以进行检查

在定义页面中,将
/components/form
设为url,将url参数设为属性,如下例所述

<?xml version="1.0" encoding="UTF-8"?>
<component>
    <url>/components/form</url>
     <properties>
        <itemKind>type</itemKind>
        <itemId>contentType</itemId>
        <mode>edit</mode>
        <formUI>true</formUI>
        <submitType>json</submitType>
        <showCaption>true</showCaption>
        <showCancelButton>true</showCancelButton>
     </properties>
</component>

/组件/表格
类型
内容类型
编辑
真的
json
真的
真的
如果要获取配置类型的表单,应在
itemcind
中创建
type
,并在
itemId
中键入name(cm:xxx)

<?xml version="1.0" encoding="UTF-8"?>
<component>
    <url>/components/form</url>
     <properties>
        <itemKind>type</itemKind>
        <itemId>contentType</itemId>
        <mode>edit</mode>
        <formUI>true</formUI>
        <submitType>json</submitType>
        <showCaption>true</showCaption>
        <showCancelButton>true</showCancelButton>
     </properties>
</component>