COLDFUSION:组件 [Document] 没有名称为 [FILENAME] 的可访问成员
COLDFUSION: Component [Document] has no accessible Member with name [FILENAME]
我正在尝试保存文档(文章中的图片)。我使用文章 uid 作为文档文件名。我想保存在文档中的是:
-caption(字符串文本由图像描述组成)。
-fileName(字符串文本由文章uid组成)
-fileHref(图像位置的路径)。
这是我的代码:
文档处理程序:
function save (event, rc, prc) localmode="modern" {
prc.article = articleService.findWhere({"uid"=rc.fileName});
try {
if (prc.article.hasDocument()) {
response = {
"status" = "error",
"message" = "Article already have an image.",
"data" = {}
};
} else {
structUpdate(rc,"fileName", #rc.fileName#&".jpg");
prc.document = documentService.new(rc);
documentService.save(prc.document);
prc.article.addDocument(prc.document);
articleService.save(prc.article);
response = {
"status" = "success",
"message" = "",
"data" = prc.document// Include newly uploaded image info. in struct
};
}
} catch(e) {
response = {
"status" = "error",
"message" = e.message,
"data" = {}
};
log.fatal("Failed to create image file.", e.message);
}
event.renderData(type="json", data=response);
}
文档 bean:
component entityname="Document" persistent="true" extends="BaseEntity" {
// primary key
// secondary key
property name="uid" ormtype="string" unique="true";
// non-relational columns
property name="fileName" ormtype="string" unique="true";
property name="caption" ormtype="string";
// one-to-one
// one-to-many
// many-to-one
property name="article" fieldtype="many-to-one" cfc="Article" fkcolumn="articleId" fetch="join";
// many-to-many
// calculated properties
property name="fileHref" ormtype="string" persistent="false";
// non-persistent
// object constraints
this.constraints = {
"caption" = { required=true, requiredMessage="Please enter Document caption." },
"fileName" = { required=true, requiredMessage="Please enter Document file." }
};
// methods
function init() localmode="modern" {
if(isNull(variables.uid)){
variables.uid = lCase(right(createUUID(), 16));
}
return this;
}
function onDIComplete() localmode="modern" {
variables.fileHref = "/docs/article/" & variables.fileName;
}
}
如您所见,我已经在我的 bean 中设置了文件名。但系统可以访问该文件名 属性。
对不起,我的英语不流利。
我在处理程序中调用了错误的 bean,所以发生了这种情况。
我正在尝试保存文档(文章中的图片)。我使用文章 uid 作为文档文件名。我想保存在文档中的是:
-caption(字符串文本由图像描述组成)。
-fileName(字符串文本由文章uid组成)
-fileHref(图像位置的路径)。
这是我的代码:
文档处理程序:
function save (event, rc, prc) localmode="modern" {
prc.article = articleService.findWhere({"uid"=rc.fileName});
try {
if (prc.article.hasDocument()) {
response = {
"status" = "error",
"message" = "Article already have an image.",
"data" = {}
};
} else {
structUpdate(rc,"fileName", #rc.fileName#&".jpg");
prc.document = documentService.new(rc);
documentService.save(prc.document);
prc.article.addDocument(prc.document);
articleService.save(prc.article);
response = {
"status" = "success",
"message" = "",
"data" = prc.document// Include newly uploaded image info. in struct
};
}
} catch(e) {
response = {
"status" = "error",
"message" = e.message,
"data" = {}
};
log.fatal("Failed to create image file.", e.message);
}
event.renderData(type="json", data=response);
}
文档 bean:
component entityname="Document" persistent="true" extends="BaseEntity" {
// primary key
// secondary key
property name="uid" ormtype="string" unique="true";
// non-relational columns
property name="fileName" ormtype="string" unique="true";
property name="caption" ormtype="string";
// one-to-one
// one-to-many
// many-to-one
property name="article" fieldtype="many-to-one" cfc="Article" fkcolumn="articleId" fetch="join";
// many-to-many
// calculated properties
property name="fileHref" ormtype="string" persistent="false";
// non-persistent
// object constraints
this.constraints = {
"caption" = { required=true, requiredMessage="Please enter Document caption." },
"fileName" = { required=true, requiredMessage="Please enter Document file." }
};
// methods
function init() localmode="modern" {
if(isNull(variables.uid)){
variables.uid = lCase(right(createUUID(), 16));
}
return this;
}
function onDIComplete() localmode="modern" {
variables.fileHref = "/docs/article/" & variables.fileName;
}
}
如您所见,我已经在我的 bean 中设置了文件名。但系统可以访问该文件名 属性。 对不起,我的英语不流利。
我在处理程序中调用了错误的 bean,所以发生了这种情况。