Simon write
> > That does solve the problem in many cases. But it means that the
> > hand-written class can never itself define any method in the public API.
> > Any code that it implements itself will be overridden by the generated
> > class.
>
Leonardo
> No if we use component-class-excluded and use an xml to reference the
> property. That's what
> I'm doing now.
Simon

Can you please explain this further? I don't understand what you mean..

In the practice the only case that I have in tomahawk is related to t:tree2

This is the code for the workaround:

AbstractHtmlTree.java

public abstract class AbstractHtmlTree extends UITreeData
{
    /* ...................... */

    // Property: varNodeToggler
    private String _varNodeToggler;

    /**
     * Gets
     *
     * @return  the new varNodeToggler value
     */
    public String getVarNodeToggler()
    {
      return _varNodeToggler;
    }

    /**///setVarNodeToggler
    public void setVarNodeToggler(String varNodeToggler)
    {
        _varNodeToggler = varNodeToggler;

        // create a method binding for the expand control
        String bindingString = "#{" + varNodeToggler + ".toggleExpanded}";
        MethodBinding actionBinding =
FacesContext.getCurrentInstance().getApplication().createMethodBinding(bindingString,
null);
        getExpandControl().setAction(actionBinding);
    }

    /*....................*/

}


AbstractHtmlTree2.xml

<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee";
              xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin";
              xmlns:t="http://myfaces.apache.org/tomahawk";
              xmlns:xi="http://www.w3.org/2001/XInclude";>
    <component>
        <!--
        <description>
            This tag renders as an HTML input element.

            Unless otherwise specified, all attributes accept static values
            or EL expressions.
        </description>
         -->

        <component-type>org.apache.myfaces.AbstractHtmlTree2
</component-type>
        <component-class>org.apache.myfaces.custom.tree2.AbstractHtmlTree
</component-class>

        <!-- inherited from superclasses: -->
        <!--   'id' is declared in
javax.faces.webapp.UIComponentClassicTagBase -->
        <!--   'binding' and 'rendered' are declared in
javax.faces.webapp.UIComponentELTag -->
        <property>
            <description></description>
            <property-name>varNodeToggler</property-name>
            <property-class>java.lang.String</property-class>
            <property-extension>
                <mfp:required>false</mfp:required>
                <mfp:literal-only>true</mfp:literal-only>
            </property-extension>
        </property>
        <property>
            <description></description>
            <property-name>clientSideToggle</property-name>
            <property-class>boolean</property-class>
            <default-value>true</default-value>
            <property-extension>
                <mfp:required>false</mfp:required>
            </property-extension>
        </property>

        <component-extension>
            <!--for the Component generation-->
            <mfp:component-family>org.apache.myfaces.HtmlTree2
</mfp:component-family>
            <mfp:component-supertype>org.apache.myfaces.Tree2
</mfp:component-supertype>
            <mfp:component-superclass>
org.apache.myfaces.custom.tree2.UITreeData</mfp:component-superclass>

<mfp:component-class-excluded>true</mfp:component-class-excluded>
        </component-extension>
    </component>
</faces-config>

In other words. For define this component I use the following files

AbstractHtmlTree  //hand written base class
HtmlTree              //generated class

AbstractHtmlTree2.xml // Define properties to be included on faces-config
and tld
HtmlTree2.xml             // Define the generated class properties and all
stuff (his component type extends from
org.apache.myfaces.AbstractHtmlTree2instead UITreeData).

Now I remember why at start I do hand written on top and generated on
bottom. If you do generated on top, you need
to define 2 xml files (one for the generation and one for the real
component). But we could add properties to myfaces-faces plugin to do this
in one only file.

regards

Leonardo Uribe

Reply via email to