Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 57206 invoked from network); 5 Feb 2008 21:27:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2008 21:27:23 -0000 Received: (qmail 52376 invoked by uid 500); 5 Feb 2008 21:27:06 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 52328 invoked by uid 500); 5 Feb 2008 21:27:05 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 52296 invoked by uid 99); 5 Feb 2008 21:27:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Feb 2008 13:27:05 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lu4242@gmail.com designates 72.14.246.243 as permitted sender) Received: from [72.14.246.243] (HELO ag-out-0708.google.com) (72.14.246.243) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Feb 2008 21:26:36 +0000 Received: by ag-out-0708.google.com with SMTP id 31so4153086agc.0 for ; Tue, 05 Feb 2008 13:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=zUMBa71bS6ogXd0Dq6qX2AUcnBoMjH3Zl9aOcZRT0ps=; b=jYiDLI0V4KnQbiqJnh37CPYfZtO0itu3nluieiaaqgXXw58v5Ev/4BShWZr7jA5LtS34evsJWqWi1TSLKDkhKmdsALkPIKMndlrzrqgrTIYfikdENUVKgRAqXbGGgLwmqX91B4/sAJ3wS9Xo8NbWJjibUV4gQs/T4Paz31IOv1Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=xr7u8kL00gkvkb6nriPp0DJhRvE3p18wQ0GXZ09NcndkKAG8yw8y4IKsz/t3TkwJE62wn134K3yaAXOuaXQ3TxuiBhzaUPBydd+RTQzEbt4ZgM8JR45T9oMablTLsHqznlYscoa+jDyrYgdJVspUOtHvqPEhm58dgh4Ke2oi2GU= Received: by 10.150.92.11 with SMTP id p11mr3784488ybb.36.1202246802236; Tue, 05 Feb 2008 13:26:42 -0800 (PST) Received: by 10.151.27.17 with HTTP; Tue, 5 Feb 2008 13:26:42 -0800 (PST) Message-ID: Date: Tue, 5 Feb 2008 16:26:42 -0500 From: "Leonardo Uribe" To: "MyFaces Development" Subject: Re: [Myfaces Wiki] Update of "Code Generation" by SimonKitching In-Reply-To: <5a99335f0802010936p491ccbdcw280c91ebb039049b@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4929_3706568.1202246802226" References: <20080131214002.8895.82839@eos.apache.org> <1201818283.6247.23.camel@simon-laptop> <47A310CD.7060101@ataco.cz> <5a99335f0802010549k4233b0f6y9c8189b5a0bbe0bb@mail.gmail.com> <47A34F21.1020200@ataco.cz> <5a99335f0802010936p491ccbdcw280c91ebb039049b@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_4929_3706568.1202246802226 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi I have checked this topic of the wiki http://wiki.apache.org/myfaces/Code_Generation: Generating base classes instead of templatesAnd based on some work with tomahawk I have some observations to do: *".......Note that (in a feature that may surprise some Java developers) it appears quite valid for a class to have a package-scoped parent; the class can still be subclassed or instantiated from outside the package. It inherits public and protected members from its package-scoped parent which can be called as normal. The only constraint is that it cannot be cast to its parent type, as this is not accessible (although the Class object for that type can still be obtained). It is not yet known whether inserting such a package-scoped ancestor class into the ancestry of a component class in the javax.faces package scope would be acceptable to the JSF TCK or not. If the TCK accepts this, then the approach of generating a base class could also be applied to myfaces core components......". * In some cases doing something like this: abstract class AbstractHtmlInputText extends javax.faces.component.html.HtmlInputText implements UserRoleAware, DisplayValueOnlyCapable { works but in other cases do not, It throws an exception like this: java.lang.IllegalAccessException: Class javax.faces.component._ComponentAttributesMap can not access a member of class org.apache.myfaces.custom.tabbedpane.AbstractHtmlPanelTabbedPane with modifiers "public abstract" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.reflect.Method.invoke(Method.java:588) at javax.faces.component._ComponentAttributesMap.getComponentProperty (_ComponentAttributesMap.java:390) at javax.faces.component._ComponentAttributesMap.put (_ComponentAttributesMap.java:311) at javax.faces.component.UIComponent.setValueExpression(UIComponent.java :112) at org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPaneTag.setProperties( HtmlPanelTabbedPaneTag.java:389) at javax.faces.webapp.UIComponentELTag.createComponent( UIComponentELTag.java:100) There are some methods on java api that use reflection to set some variables, and fails if the parent class is not public, so I do not believe that this approach works for myfaces core api, and pass the TCK. *"....With this setup, we have the question of which source directory the generated base class gets written to. Option (1) is to write it to a generated-source dir, option (2) is to write it to the normal source dir....." * *".....Question: When there are multiple source trees for a module, does maven build against them all simultaneously? That is, if a normal source file references a source file in the generated-source tree which itself references a source file in the normal source tree, does this work?..." * Yes, this works and it is awesome. One successful example is this hierarchy used for t:schedule javax.faces.UIComponentBase -----------myfaces core api org.apache.myfaces.custom.schedule.AbstractUIScheduleBase ----------- on src/main/java org.apache.myfaces.custom.schedule.UIScheduleBase ------------ generated on target/maven-faces-plugin/main/java org.apache.myfaces.custom.schedule.UISchedule ------------ on src/main/java org.apache.myfaces.custom.schedule.HtmlSchedule ------------ generated on target/maven-faces-plugin/main/java On eclipse I works like if all files were on the same directory. Code completion works using base classes (with templates do not!). Generate in src/main/java or in target/maven-faces-plugin/main/java is transparent for the IDE. If we generate in src/main/java, the generated code will mix with hand written code, if we translate generated code to a separate directory on src/main/java technically it is equivalent to generate in target/maven-faces-plugin/main/java. In conclusion: Actually 100% of the components in tomahawk (I have only a problem with t:tree2 that can be solved with more work) can use abstract classes aproach (with some little modifications on myfaces-faces-plugin). The list of modifications is this. : - component-includes parameter on component-extension - component-serial-uid parameter on component-extension - is-get-local-method-scope and is-get-local-method parameters on property-extension to generate automatically getLocalXXX method - is-set-method-scope and is-set-method parameters on property-extension to generate automatically isSetXXXX method. regards Leonardo Uribe ------=_Part_4929_3706568.1202246802226 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi

I have checked this topic of the wiki http://wiki.apache.org/myfaces/Code_Generation:

Generating base classes instead of templates

And based on some work with tomahawk I have some observations to do:

".......Note that (in a feature that may surprise some Java developers) it appears quite valid for a class to have a package-scoped parent; the class can still be subclassed or instantiated from outside the package. It inherits public and protected members from its package-scoped parent which can be called as normal. The only constraint is that it cannot be cast to its parent type, as this is not accessible (although the Class object for that type can still be obtained). It is not yet known whether inserting such a package-scoped ancestor class into the ancestry of a component class in the javax.faces package scope would be acceptable to the JSF TCK or not. If the TCK accepts this, then the approach of generating a base class could also be applied to myfaces core components......".

In some cases doing something like this:

abstract class AbstractHtmlInputText
        extends javax.faces.component.html.HtmlInputText
        implements UserRoleAware, DisplayValueOnlyCapable
{

works but in other cases do not, It throws an exception like this:

java.lang.IllegalAccessException: Class javax.faces.component._ComponentAttributesMap can not access a member of class org.apache.myfaces.custom.tabbedpane.AbstractHtmlPanelTabbedPane with modifiers "public abstract"
    at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
    at java.lang.reflect.Method.invoke(Method.java:588)
    at javax.faces.component._ComponentAttributesMap.getComponentProperty(_ComponentAttributesMap.java:390)
    at javax.faces.component._ComponentAttributesMap.put(_ComponentAttributesMap.java:311)
    at javax.faces.component.UIComponent.setValueExpression(UIComponent.java:112)
    at org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPaneTag.setProperties(HtmlPanelTabbedPaneTag.java:389)
    at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:100)


There are some methods on java api that use reflection to set some variables, and fails if the parent class is not public, so I do not believe that this approach works for myfaces core api, and pass the TCK.

"....With this setup, we have the question of which source directory the generated base class gets written to. Option (1) is to write it to a generated-source dir, option (2) is to write it to the normal source dir....."

".....Question: When there are multiple source trees for a module, does maven build against them all simultaneously? That is, if a normal source file references a source file in the generated-source tree which itself references a source file in the normal source tree, does this work?..."

Yes, this works and it is awesome. One successful example is this hierarchy used for t:schedule

javax.faces.UIComponentBase                                                    -----------myfaces core api
org.apache.myfaces.custom.schedule.AbstractUIScheduleBase    ----------- on src/main/java
org.apache.myfaces.custom.schedule.UIScheduleBase                ------------ generated on target/maven-faces-plugin/main/java
org.apache.myfaces.custom.schedule.UISchedule                        ------------ on src/main/java
org.apache.myfaces.custom.schedule.HtmlSchedule                    ------------ generated on target/maven-faces-plugin/main/java

On eclipse I works like if all files were on the same directory. Code completion works using base classes (with templates do not!).

Generate in src/main/java or in target/maven-faces-plugin/main/java is transparent for the IDE. If we generate in src/main/java, the generated code will mix with hand written code, if we translate generated code to a separate directory on src/main/java technically it is equivalent to generate in target/maven-faces-plugin/main/java.

In conclusion: Actually 100%  of the components in tomahawk (I have only a problem with t:tree2 that can be solved with more work) can use abstract classes aproach (with some little modifications on myfaces-faces-plugin). The list of modifications is this. :

- component-includes parameter on component-extension
- component-serial-uid parameter on component-extension
- is-get-local-method-scope and is-get-local-method parameters on property-extension to generate automatically getLocalXXX method
- is-set-method-scope and is-set-method parameters on property-extension to generate automatically isSetXXXX method.

regards

Leonardo Uribe

------=_Part_4929_3706568.1202246802226--