自定义升降标签不起作用

发布于 2024-12-21 22:15:51 字数 1494 浏览 8 评论 0原文

Lift 中的以下类型的标签似乎对我不起作用:

<lift:snippet type="MyClass:render" />
<lift:MyClass.render/>
<lift:MyClass/>

使用这些标签会导致找不到类错误。如果我尝试使用它来调用一个类,

<div class=lift:myclass.mymethod />

它就可以工作。或者如果我使用跨度标签来调用它。例如,Pollak 的 Simply Lift 中的 Hello World 示例就适合我,它使用以下代码成功显示了 Howdy 方法:

<span class="lift:helloWorld.howdy">
      Welcome to your Lift app at <span id="time">Time goes here</span>
</span>

目前,我的问题来自于尝试实现 Exploring Lift >(又名 The Lift Book)第 13.1 章中的 OpenID 示例。我已经使用 sbt 以及 lift-openid 库下载了 OpenID4Java。该示例可以在 http://exploring.liftweb.net/master/index-13 找到.html。我已经实现了对 Boot 类的更改,并创建了 OpenID 类和 SimpleOpenIDVendor 类。但是创建包含以下内容的 html 文件

 <lift:OpenID.form>
  <openId:renderForm/>
 </lift:OpenID.form>

会导致浏览器中显示以下错误:

Error processing snippet: openid.form
Reason: Class Not Found
XML causing this error:
<lift:openid.form xmlns="http://www.w3.org/1999/xhtml">
<openid:renderform>
</openid:renderform></lift:openid.form>

类 OpenID 被放置在以包代码开头的包中,Lift 正在隐式找到该包。它包含在 Boot.scala 文件中,并带有“

LiftRules.addToPackages("code")

So, I am a损失”行。有什么想法吗?

请注意,其他提升标签(例如 lift:bind-at 和 lift:surround 等)可以正常工作。

The following types of tags in Lift do not seem to work for me:

<lift:snippet type="MyClass:render" />
<lift:MyClass.render/>
<lift:MyClass/>

Using these tags results in a Class Not Found error. If I attempt to call a class using

<div class=lift:myclass.mymethod />

it can work. Or if I call it using span tags. For instance, the Hello World example in Pollak's Simply Lift works for me, successfully displaying the Howdy method with the following code:

<span class="lift:helloWorld.howdy">
      Welcome to your Lift app at <span id="time">Time goes here</span>
</span>

Currently, my problem is coming from attempting to implement Exploring Lift's (aka The Lift Book) OpenID example in Chapter 13.1. I have downloaded OpenID4Java using sbt as well as the lift-openid library. That example can be found at http://exploring.liftweb.net/master/index-13.html. I have implemented the change to the Boot class, and created the OpenID class and the SimpleOpenIDVendor class. But creating an html file containing

 <lift:OpenID.form>
  <openId:renderForm/>
 </lift:OpenID.form>

causes the following error to be displayed in the browser:

Error processing snippet: openid.form
Reason: Class Not Found
XML causing this error:
<lift:openid.form xmlns="http://www.w3.org/1999/xhtml">
<openid:renderform>
</openid:renderform></lift:openid.form>

The class OpenID was placed in a package that starts with the package code, which is being implicitly found by Lift. It is included in the Boot.scala file with the line

LiftRules.addToPackages("code")

So, I am at a loss. Any ideas?

Note that other lift tags such as lift:bind-at and lift:surround and the like work fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离线来电— 2024-12-28 22:15:51

正如戴夫在我原来的评论下发表的那样,问题出在 HTML5 解析器上。 Lift 区分大小写,无法找到大小写不同的类。由于 HTML5 解析器自动将标签变为小写,因此您不能再使用自定义提升标签。相反,您必须使用类似

<div class="Lift:MyClass.render"></div>

Note that you CANNOT

<div class="Lift:MyClass.render" />

内容,因为 HTML5 显然不支持此类标签。

因此,我的 OpenID4Java 问题通过使用解决:

<div class="lift:OpenID.renderForm">         
</div>

为什么我不需要使用 openid.form 仍然不确定。可能我的实现稍有偏差,但我确认,如果我放入 openid 链接,它将带我进入 openid 登录页面,所以它确实可以正常工作。

来源:

As dave posted under my original comment, the problem was the HTML5 parser. Lift is case-sensitive, and cannot find a class with varying case. Since the HTML5 parser automatically makes tags lowercase, you can't use custom lift tags anymore. Instead, you have to use something like

<div class="Lift:MyClass.render"></div>

Note that you CANNOT have

<div class="Lift:MyClass.render" />

as HTML5 apparently does not support such tags.

My OpenID4Java problem is therefore resolved by using:

<div class="lift:OpenID.renderForm">         
</div>

Why I don't need to use openid.form still is uncertain. It could be possible I'm implementing it slightly off, but I confirmed that it will take me to an openid login page if I put in the openid link, so it is indeed functional.

Sources:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文