在vaadin克拉拉的内部html

时间:2014-11-06 18:49:53

标签: java html vaadin declarative

我正在使用vaadin clara来构建UI。
1.当我使用这种结构时:

<?xml version="1.0" encoding="UTF-8"?>
<VerticalLayout xmlns="urn:import:com.vaadin.ui" xmlns:p="urn:vaadin:parent"  defaultComponentAlignment="MIDDLE_CENTER">
        <Label caption=<![CDATA[<b>Register</b>]]> contentMode="HTML" width=""></Label>
        <Form>
            <TextField id="name" caption="Name"></TextField>
            <TextField id="login" caption="E-mail"></TextField>
            <PasswordField id="password" caption="Pass"></PasswordField>
            <PasswordField id="password-check" caption="Pass check"></PasswordField>
        </Form>
        <HorizontalLayout>
            <Button id="register-button" caption="Register"></Button>
            <Button id="login-button" caption="Login"></Button>
        </HorizontalLayout>
</VerticalLayout>

我有错误:

  

HTTP状态500 - com.vaadin.server.ServiceException:   org.vaadin.teemu.clara.inflater.LayoutInflaterException:   org.xml.sax.SAXParseException; lineNumber:3; columnNumber:18;打开   对于与元素类型相关联的属性“{1}”,需要quote   “标题”。


2.如果我使用这样的结构:

...
<Label caption="<b>Register</b>" contentMode="HTML" width=""></Label>
...

我有错误:

HTTP Status 500 - com.vaadin.server.ServiceException: org.vaadin.teemu.clara.inflater.LayoutInflaterException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 19; The value of attribute "caption" associated with an element type "null" must not contain the '<' character.<br>


3.如果我使用不带内部html的标签,则代码可以正常工作。

...
<Label caption="Register" contentMode="HTML" width=""></Label>
...

我的问题是如何在vaadin clara框架中使用内部html。 感谢。

1 个答案:

答案 0 :(得分:1)

您必须引用/转义HTML。在您的情况下,它将是:&lt;b&gt;Register&lt;/b&gt;。 XML必须有效。一个好的编辑或IDE会警告你这件事,甚至可能为你逃避。