0

我试图通过一个简单的例子来帮助下面的问题。 任何人都可以提供-aikau-form-example-with-data-loading

基本上,当表单对话框加载并想要在对话框中显示文档库 noderef 时,我会做一个 repo 请求。所以我在对话框加载期间调用了 makeRepoRequest(),但是网络选项卡抛出 401 错误。

请告诉我,这个样本有什么问题?

/* studentForm.get.js */
function makeRepoRequest()
{
    var alfDestination = "something";


    var site = page.url.templateArgs.site;
    var result = remote.call("/slingshot/doclib/container/" + site + "/documentLibrary");
    return result.status.code;
    if (result.status.code == status.STATUS_OK) {
        alfDestination = JSON.parse(result).container.nodeRef;
    }
}

var formControls = [
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      name: "name1",
      label:"Name",
      placeHolder:"Enter Name Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  },
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"Age",
      name: "age",
      placeHolder:"Enter Age Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  }
  ,
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"NodeRef",
      name: "nodeRef",
      visibilityConfig: {
        initialValue: true
      },
      value : makeRepoRequest()
    }
  }
];

var showDialog = {
  name: "alfresco/buttons/AlfButton",

  config: {
    readOnly:"true",
    id:"dialog1",
    label: "Create New Student",
    additionalCssClasses: "call-to-action",
    publishTopic: "ALF_CREATE_FORM_DIALOG_REQUEST",
    publishPayloadType: "PROCESS",
    publishPayload: {
      dialogTitle: "Student Form",
      dialogConfirmationButtonTitle: "Register",
      dialogCancellationButtonTitle: "Cancel",
      formSubmissionTopic: "ALF_CRUD_CREATE",
      formSubmissionPayloadMixin: {
        url: "api/type/cm%3Astudent/formprocessor"
      },
      fixedWidth: true,
      widgets: formControls
    }
  }
};

model.jsonModel = {
widgets :[showDialog 
         ],
services : [
            "alfresco/dialogs/AlfDialogService",
            "alfresco/services/CrudService" 
        ]     
};
4

2 回答 2

1

401 状态代码表示用户未通过身份验证。你在哪里运行这段代码?它是在 Share 上还是在独立的 Aikau 客户端上?用户是否登录?他们是否拥有访问该 API 的必要权限?他们是网站的成员吗?网站有什么隐私?

于 2016-12-12T09:06:44.330 回答
0

我已经通过在 alfreso sdk 中静态给出我的站点名称(例如演示)来测试您的代码,它工作正常并使用此代码给我 nodeRef

function makeRepoRequest()
{
var alfDestination = "something";


var site = "demo";
var result = remote.call("/slingshot/doclib/container/" + site + "/documentLibrary");

if (result.status.code == status.STATUS_OK) {
    alfDestination = JSON.parse(result).container.nodeRef;
}
 return alfDestination ;
}

您是否测试过所获得的任何站点名称都是正确的?我已经使用浏览器 url 测试了这段代码。

于 2016-12-14T08:21:55.760 回答