JSF-自定义组件,属性表达式有问题
我想创建具有属性“title”的自定义组件,该属性可以具有表达式,但出现以下错误: 无法将字符串“#{myBean.text}”转换为属性“title”的类“javax.el.ValueExpression”:属性编辑器未向PropertyEditorManager注册 原因: org.apache.jasper.jaspereException-无法将属性“title”的字符串“#{myBean.text}”转换为类“javax.el.ValueExpression”:属性编辑器未向PropertyEditorManager注册 我的班级:JSF-自定义组件,属性表达式有问题,jsf,custom-component,Jsf,Custom Component,我想创建具有属性“title”的自定义组件,该属性可以具有表达式,但出现以下错误: 无法将字符串“#{myBean.text}”转换为属性“title”的类“javax.el.ValueExpression”:属性编辑器未向PropertyEditorManager注册 原因: org.apache.jasper.jaspereException-无法将属性“title”的字符串“#{myBean.text}”转换为类“javax.el.ValueExpression”:属性编辑器未向Prope
<d:ticker title="#{myBean.text}">
<f:verbatim>Hello JSF Custom Component</f:verbatim>
</d:ticker>
MyBean.java
public class MyBean {
private String text = "TITLE!!!!";
public String getText() {
return text;
}
}
TickerTag.java
private ValueExpression title = null;
public void setTitle(ValueExpression title)
{
this.title = title;
}
protected void setProperties(UIComponent component) {
super.setProperties(component);
if (title != null) {
if (!title.isLiteralText()) {
component.setValueExpression("title", title);
} else {
component.getAttributes().put("title",title.getExpressionString());
}
}
taglib.tld
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-jsptaglibrary_2_1.xsd">
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>d</short-name>
<uri>http://jsftutorials.com/</uri>
<tag>
<name>ticker</name>
<tag-class>ticker.TickerTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>title</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
Hello JSF自定义组件
MyBean.java
公共类MyBean{
私有字符串text=“TITLE!!!!”;
公共字符串getText(){
返回文本;
}
}
TickerTag.java
private-ValueExpression-title=null;
public void setTitle(ValueExpression title)
{
this.title=标题;
}
受保护的void集合属性(UIComponent){
super.setProperties(组件);
如果(标题!=null){
如果(!title.isLiteralText()){
组件.setValueExpression(“标题”,标题);
}否则{
component.getAttributes().put(“title”,title.getExpressionString());
}
}
taglib.tld
1
1.2
D
http://jsftutorials.com/
股票行情
股票代码
JSP
标题
真的
有人看到这个问题了吗?我遇到了同样的问题,并且能够通过在我的taglib.tld文件中包含延迟值标记来解决它。当组件具有可以用EL表达式设置的属性时,这是必需的。“type”标记是EL表达式应该计算的类型 taglib.tld:
<tag>
<name>CustomComponent</name>
<tag-class>com.test.components.CustomComponent</tag-class>
<attribute>
<name>someAttribute</name>
<description>The custom attribute</description>
<deferred-value>
<type>java.lang.String</type>
</deferred-value>
</attribute>
</tag>
自定义组件
com.test.components.CustomComponent
某些属性
自定义属性
java.lang.String
我遇到了同样的问题,并且能够通过在我的taglib.tld文件中包含延迟值标记来解决它。当组件具有可使用EL表达式设置的属性时,这是必需的。“type”标记是EL表达式应计算的类型
taglib.tld:
<tag>
<name>CustomComponent</name>
<tag-class>com.test.components.CustomComponent</tag-class>
<attribute>
<name>someAttribute</name>
<description>The custom attribute</description>
<deferred-value>
<type>java.lang.String</type>
</deferred-value>
</attribute>
</tag>
自定义组件
com.test.components.CustomComponent
某些属性
自定义属性
java.lang.String
它为
显示错误。我使用的doctype是
它为
显示错误。我使用的doctype是