views:

333

answers:

1

I want to create custom component with attribute "title" that can have expression but I get this error:

Unable to convert string "#{myBean.text}" to class "javax.el.ValueExpression" for attribute "title": Property Editor not registered with the PropertyEditorManager

Caused by: org.apache.jasper.JasperException - Unable to convert string "#{myBean.text}" to class "javax.el.ValueExpression" for attribute "title": Property Editor not registered with the PropertyEditorManager

My classes:

<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/&lt;/uri&gt;
    <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>

anybody see the problem?

+1  A: 

This code is part of this tutorial at jsftutorials.net. Have you checked step 4 (adding attribute binding)? Note the differences in the tutorial and your code. True, it's an old tutorial which uses the deprecated JSF 1.0/1.1 ValueBinding, but you can in fact just continue using it and it should get you started.

If you want to create a fullworthy JSF 1.2 component, I'd suggest to look at JSF 1.2 targeted tutorials only. This Google search will give a lot of examples.

BalusC