0

extend the chosenbox component

asked 2014-03-26 17:59:36 +0800

pmonteir gravatar image pmonteir
9

I'm trying to extend the chosenbox component, and add a new property, but I'm having this js error: "Unknown widget: custom.zk.component.CustomChosenbox"

Has anyone an idea what I'm doing wrong?

Thanks in advance.

Paulo

lang-addon.xml

<language-addon>
<addon-name>customChosenbox</addon-name>

<language-name>xul/html</language-name>
<component>
    <component-name>customChosenbox</component-name>
    <component-class>custom.zk.component.CustomChosenbox</component-class>
    <widget-class>custom.zk.component.CustomChosenbox</widget-class>
     <annotation>
        <annotation-name>ZKBIND</annotation-name>
        <property-name>colors</property-name>
        <attribute>
            <attribute-name>ACCESS</attribute-name>
            <attribute-value>both</attribute-value>
        </attribute>
        <attribute>
            <attribute-name>LOAD_REPLACEMENT</attribute-name>
            <attribute-value>colors</attribute-value>
        </attribute>
        <attribute>
            <attribute-name>LOAD_TYPE</attribute-name>
            <attribute-value>java.lang.String</attribute-value>
        </attribute>
    </annotation>

</component>

</language-addon>

CustomChosenbox.js

(function () {

// simply extends chosenbox
custom.zk.component.CustomChosenbox = zk.$extends(zkmax.inp.Chosenbox, {
    _colors : '',

    getColors : function() {
        return this._colors;
    },

    setColors : function(value) {
            this._colors = value;
    }

});

})();

zk.wpd

<package name="custom.zk.component" language="xul/html" depends="zul">
  <widget name="CustomChosenbox"/>
</package>

CustomChosenbox.java

public class CustomChosenbox extends Chosenbox {


private static final long serialVersionUID = -5929845559826449285L;

private String _colors;


public CustomChosenbox() {

}

public void setColors(String colors) {
    if (colors != null && colors.length() == 0)
        colors = null;
    if (!Objects.equals(_colors, colors)) {
        _colors = colors;
        smartUpdate("colors", colors);
    }
}

public String getColors() {
    return _colors;
}

protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
        throws IOException {
    super.renderProperties(renderer);

    render(renderer, "colors", _colors);
}

}

delete flag offensive retag edit

Comments

The package of Chosenbox is "zkmax.inp". Try change zk.wpd content with depends="zkmax.inp"

vincentjian ( 2014-03-27 04:49:19 +0800 )edit

thanks, it solved my issue.

pmonteir ( 2014-03-28 12:48:43 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-03-26 17:59:36 +0800

Seen: 28 times

Last updated: Mar 26 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More