使用关闭 cfpdf 标签导致错误
如果我在组件中使用以下代码:
<cfpdf action="merge" name="tender">
</cfpdf>
我收到以下错误:
结束标记“”与当前父项不匹配: 'cffunction'
但是,如果我将代码更改为:
<cfpdf action="merge" name="tender" />
我不会收到任何错误。请注意,我更改代码的唯一方法是关闭标签的方法。谁能向我解释为什么会这样,甚至更好,告诉我如何解决这个问题?
该错误显示在 CFEclipse 的“问题”视图中,但当我在服务器上运行代码时不会发生该错误。
系统设置: Win7,使用 CFEclipse v.1.4.3 运行 Eclipse Indigo。服务器运行 Coldfusion 8。
更新 1:
如果我只是忽略 CFEclipse 显示的解析错误并在服务器上运行代码,它会按预期工作。我想这表明它确实是 CFEclipse 本身的问题,就像 Peter Boughton 所建议的那样,而不是代码本身的问题。
以防万一,这里是该函数的完整代码(请注意,这不是生产代码,我目前只是进行测试以获得我需要工作的东西):
<cffunction name="GetTenderPDF" access="remote">
<cfargument name="Info" type="String" required="true" />
<cfset var Tender = {} />
<cfset var InfoJson = URLDecode(Arguments.Info) />
<cfif Not IsJSON(InfoJson)>
<cfreturn Error(Messages.NOT_JSON) />
</cfif>
<cfset Tender = DeserializeJSON(InfoJson) />
<cfset templatePath = "templates/tenderTemplate_"&Tender.GROUP&".cfm" />
<cfheader name="Content-Disposition" value="attachment; filename=offert.pdf" />
<cfdocument format="pdf" name="mydocument">
<cfloop index="x" from="1" to="15">
<p>
lorem upsom doloras paris hilton is my hero loreum ipsom dsoio foom an to dht end of the world
will anyone actually read this probably not but let me put more realtext in so it flows a bit nicely
<cfloop index="y" from="1" to="#randRange(1,9)#">This sentence will appear a random amount of time.</cfloop>
</p>
</cfloop>
</cfdocument>
<cfdocument format="pdf" name="base">
<cfinclude template="#templatePath#" />
</cfdocument>
<!--- <cfpdf action="merge" name="tender" /> --->
<cfpdf action="merge" name="tender">
<cfpdfparam source="base" />
<cfpdfparam source="mydocument" />
</cfpdf>
<cfcontent type="application/pdf" reset="true" variable="#toBinary(tender)#" />
</cffunction>
If I use the following code in my component:
<cfpdf action="merge" name="tender">
</cfpdf>
I get the following error:
Closing tag '' does not match the current parent item:
'cffunction'
However, if i change the code to:
<cfpdf action="merge" name="tender" />
I get no errors. Note that the only way I changed my code is the way I close the tag. Can anybody explain to me why that is and even better, tell me how to get around this?
The error is shown in CFEclipse in the "problems" view, but does not occur when I run the code on the server.
System setup:
Win7, running Eclipse Indigo with CFEclipse v.1.4.3. Server runs Coldfusion 8.
Update 1:
If I simply ignore the parse error that CFEclipse shows and run the code on the server, it works as expected. I guess this suggest that it is indeed something with CFEclipse itself like Peter Boughton suggested, and not a problem in the code itself.
Just in case, here is the complete code for the function (note that this is not production code, I'm currently just testing in order to get the things I need working):
<cffunction name="GetTenderPDF" access="remote">
<cfargument name="Info" type="String" required="true" />
<cfset var Tender = {} />
<cfset var InfoJson = URLDecode(Arguments.Info) />
<cfif Not IsJSON(InfoJson)>
<cfreturn Error(Messages.NOT_JSON) />
</cfif>
<cfset Tender = DeserializeJSON(InfoJson) />
<cfset templatePath = "templates/tenderTemplate_"&Tender.GROUP&".cfm" />
<cfheader name="Content-Disposition" value="attachment; filename=offert.pdf" />
<cfdocument format="pdf" name="mydocument">
<cfloop index="x" from="1" to="15">
<p>
lorem upsom doloras paris hilton is my hero loreum ipsom dsoio foom an to dht end of the world
will anyone actually read this probably not but let me put more realtext in so it flows a bit nicely
<cfloop index="y" from="1" to="#randRange(1,9)#">This sentence will appear a random amount of time.</cfloop>
</p>
</cfloop>
</cfdocument>
<cfdocument format="pdf" name="base">
<cfinclude template="#templatePath#" />
</cfdocument>
<!--- <cfpdf action="merge" name="tender" /> --->
<cfpdf action="merge" name="tender">
<cfpdfparam source="base" />
<cfpdfparam source="mydocument" />
</cfpdf>
<cfcontent type="application/pdf" reset="true" variable="#toBinary(tender)#" />
</cffunction>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这听起来像是 CFEclipse 字典文件中的错误。
如果您可以确认第一个代码实际上在 CF8 上运行,那么您可以将其报告为 CFE bug ,也许有人可以帮助您解决问题。
要自己修复它...
找到您的 Eclipse 插件目录(例如
/usr/lib/eclipse/plugins
或c:/program files/eclipse /plugins
或任何地方)。在你的插件目录中查找
org.cfeclipse.cfml
目录(它的名称后面可能有一个时间戳,这取决于你的版本,但应该只有一个*),然后在里面有一个dictionary
文件夹,其中包含一堆 XML 文件。(*如果有多个版本,请选择最新的版本 - 即最高版本。)
您需要
cf8.xml
或cf9.xml
- 取决于您为哪个项目配置了(要检查,在 CFE 导航器中,右键单击项目,选择属性,然后选择 cfeclipse,然后查看选择了哪个单选选项) -首先创建文件的备份,然后打开它使用任何文本/xml 编辑器。搜索
name="cfpdf"
- 应该出现一次 - 在同一标签中,您应该看到属性single="true"
- 更改此设置到single="false"
并保存文件。重新启动 CFEclipse,并且 - 如果我没有搞砸这些说明 - 那么错误消息应该已经消失。 :)
我还没有测试过这些(这台机器上还没有 CFE),但是只要您在编辑之前备份字典文件,就不会有任何问题。
This sounds like a bug in the CFEclipse dictionary files.
If you can confirm that the first code actually runs on CF8 then you can report it as a CFE bug, and someone can probably help you out with a fix.
To fix it yourself...
Locate your eclipse plugins directory (e.g.
/usr/lib/eclipse/plugins
orc:/program files/eclipse/plugins
or wherever).Inside your plugin dir look for the
org.cfeclipse.cfml
directory (it probably has a timestamp after the name, which depends on your version, but there should be only one*), and inside that there is adictionary
folder, containing a bunch of XML files.(*if there's multiple versions, go for the newest one - i.e. the highest number.)
You want either
cf8.xml
orcf9.xml
- depending on which one you have your project configured for (to check, in CFE navigator, right-click on project, select properties, then cfeclipse, and see what radio option is selected) - first create a backup of the file, then open it with any text/xml editor.Search for
name="cfpdf"
- there should be a single occurrence - and in the same tag you should see the attributesingle="true"
- change this tosingle="false"
and save the file.Restart CFEclipse, and - if I haven't screwed up these instructions - then the error message should have gone away. :)
I haven't tested any of this (don't have CFE on this machine yet), but so long as you backup the dictionary file before editing there shouldn't be any problems.
这可能与周围的代码或
标签内的代码有关。你能展示更多背景吗?It could be something to do with the surrounding code or the code inside the
<cfpdf></cfpdf>
tags. Can you show more context?