You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ole Ersoy <ol...@gmail.com> on 2007/12/17 01:36:17 UTC
How to Hack the HtmlFormRenderer?
Hi,
I've been trying to hack the HtmlFormRenderer. It's contained in org.apache.myfaces.shared.renderkit.html...but appears to be moved to org.apache.myfaces.shared_impl.renderkit.html during the build.
I tried commenting out all of encodeBegin. Then I deleted the myfaces directory in my maven repository. Then rebuilt. Then redeployed the testing application, and maven only downloaded non-shared resources, so I'm certain that I'm changing the right dependency. The forms are still rendering though. When I do a find on HtmlFormRendererBase the following shows up:
[ole@ole myfaces-shared-core-3_0_0]$ find . -name HtmlFormRendererBase.java
./shared-impl/target/refactored-shared-sources/main/java/org/apache/myfaces/shared_impl/renderkit/html/HtmlFormRendererBase.java
./core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
./shared-tomahawk/target/refactored-shared-sources/main/java/org/apache/myfaces/shared_tomahawk/renderkit/html/HtmlFormRendererBase.java
So it seems like there is only one HtmlFormRenderBase to be changed, since the second one is the first one, and the Tomahawk one is not being used by the HtmlFormRenderer. Ideas?
TIA,
- Ole
Re: How to Hack the HtmlFormRenderer?
Posted by Ole Ersoy <ol...@gmail.com>.
Hi Simon,
Excellent explanation. It all makes much more sense now. I'll give it go.
Thanks again,
- Ole
simon wrote:
> On Mon, 2007-12-17 at 09:52 -0600, Ole Ersoy wrote:
>
>> This is what I did initially (Might be valuable in case there are some build issues):
>> svn co http://svn.apache.org/repos/asf/myfaces/shared/branches/3_0_0 myfaces-shared-3.0.0
>> Then made the change, deleted myfaces from the repository, and rebuilt. My assumption was that these changes would replace the dependencies needed by the webapp dependencies (And it did seem to work because maven only downloaded non-shared artifact):
>>
>> <dependency>
>> <groupId>org.apache.myfaces.core</groupId>
>> <artifactId>myfaces-api</artifactId>
>> <version>1.2.0</version>
>> <scope>runtime</scope>
>> </dependency>
>>
>> <dependency>
>> <groupId>org.apache.myfaces.core</groupId>
>> <artifactId>myfaces-impl</artifactId>
>> <version>1.2.0</version>
>> <scope>runtime</scope>
>> </dependency>
>>
>> However the the webapp worked the same way as before, even with everything commented out in the renderer.
>
> What happens when you *build* the shared jar is that multiple jars are
> generated:
> * shared-impl
> * shared-tomahawk
> * etc
> each with a renamed version of the classes in the shared project.
>
> Then when you build myfaces-impl.jar, it fetches shared-impl and copies
> all the .class files into its own jar.
>
> This trickery is done so that there is only one lot of shared source to
> maintain, write unit tests for, etc. But a user can simultaneously use
> myfaces-impl that was build with shared-3.0.0 and tomahawk that was
> build with shared-3.0.2.
>
> Without this, myfaces would have to either re-release all projects any
> time we release a new shared version (even when the changes only affect
> one user of shared), or ensure complete binary and functional
> compatibility between shared releases, even though the api is private
> and internal to the myfaces subprojects.
>
> But yes it does make debugging/building a little trickier.
>
> In your case, once you have rebuild shared, you then need to rebuild
> myfaces-impl so that it imports those changes into its jar. Or, just for
> testing purposes, you can ensure your modified shared-impl jar is
> earlier on the classpath than myfaces-impl, so the new classes are used
> instead of the old ones inside myfaces-impl.
>
> Note that normally there is no shared-* jar on the classpath; the
> classes are embedded inside other jars. Have a look at the contents of
> the myfaces-impl.jar file...
>
> Regards,
>
> Simon
>
>
Re: How to Hack the HtmlFormRenderer?
Posted by simon <si...@chello.at>.
On Mon, 2007-12-17 at 09:52 -0600, Ole Ersoy wrote:
> This is what I did initially (Might be valuable in case there are some build issues):
> svn co http://svn.apache.org/repos/asf/myfaces/shared/branches/3_0_0 myfaces-shared-3.0.0
> Then made the change, deleted myfaces from the repository, and rebuilt. My assumption was that these changes would replace the dependencies needed by the webapp dependencies (And it did seem to work because maven only downloaded non-shared artifact):
>
> <dependency>
> <groupId>org.apache.myfaces.core</groupId>
> <artifactId>myfaces-api</artifactId>
> <version>1.2.0</version>
> <scope>runtime</scope>
> </dependency>
>
> <dependency>
> <groupId>org.apache.myfaces.core</groupId>
> <artifactId>myfaces-impl</artifactId>
> <version>1.2.0</version>
> <scope>runtime</scope>
> </dependency>
>
> However the the webapp worked the same way as before, even with everything commented out in the renderer.
What happens when you *build* the shared jar is that multiple jars are
generated:
* shared-impl
* shared-tomahawk
* etc
each with a renamed version of the classes in the shared project.
Then when you build myfaces-impl.jar, it fetches shared-impl and copies
all the .class files into its own jar.
This trickery is done so that there is only one lot of shared source to
maintain, write unit tests for, etc. But a user can simultaneously use
myfaces-impl that was build with shared-3.0.0 and tomahawk that was
build with shared-3.0.2.
Without this, myfaces would have to either re-release all projects any
time we release a new shared version (even when the changes only affect
one user of shared), or ensure complete binary and functional
compatibility between shared releases, even though the api is private
and internal to the myfaces subprojects.
But yes it does make debugging/building a little trickier.
In your case, once you have rebuild shared, you then need to rebuild
myfaces-impl so that it imports those changes into its jar. Or, just for
testing purposes, you can ensure your modified shared-impl jar is
earlier on the classpath than myfaces-impl, so the new classes are used
instead of the old ones inside myfaces-impl.
Note that normally there is no shared-* jar on the classpath; the
classes are embedded inside other jars. Have a look at the contents of
the myfaces-impl.jar file...
Regards,
Simon
Re: How to Hack the HtmlFormRenderer?
Posted by Ole Ersoy <ol...@gmail.com>.
Hi Martin,
Martin Marinschek wrote:
> Hi ole,
>
> what form are you using? h:form or s:form?
I'm using the h:form.
> If you are using h:form,
> then you'll be working against:
> org/apache/myfaces/shared_impl/renderkit/html/HtmlFormRendererBase.java
>
> In any case, you are right, they stem from the same source in:
>
> org.apache.myfaces.shared.renderkit.html
Super.
>
> - you should only need to change this, do a full maven build, and this
> should take on your changes.
This is what I did initially (Might be valuable in case there are some build issues):
svn co http://svn.apache.org/repos/asf/myfaces/shared/branches/3_0_0 myfaces-shared-3.0.0
Then made the change, deleted myfaces from the repository, and rebuilt. My assumption was that these changes would replace the dependencies needed by the webapp dependencies (And it did seem to work because maven only downloaded non-shared artifact):
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>1.2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>1.2.0</version>
<scope>runtime</scope>
</dependency>
However the the webapp worked the same way as before, even with everything commented out in the renderer.
> The problem might however be that the
> pom.xml of MyFaces impl is referring to an old version of shared, so
> you might need to upgrade this to the snapshot version so that you
> actually see your changes when you do the build.
I did check the dependency management of the parent project in myfaces_core_1.2.0 and it had this in it:
<dependency>
<groupId>org.apache.myfaces.shared</groupId>
<artifactId>myfaces-shared-impl</artifactId>
<version>3.0.0</version>
</dependency>
But maybe that was updated post sending the release artifacts to the repository? In any case I'll try a snapshot build, as you are recommending. Is there a svn co ... that checks out an entire build with everything in it. I tried looking at the source checkout page within the myfaces site, but that command only checks out the website ... (Incidentally should I file a JIRA to have this updated / looked at?) and when I browse around in subclipse I see there is core/trunk and core/trunk1.2.x and correspondingly shared/trunk and shared/trunk3.0.x.
I'm assuming I should check out 1.2.x 3.0.x and rebuild these?
Thanks again for all your help,
- Ole
Re: How to Hack the HtmlFormRenderer?
Posted by Martin Marinschek <ma...@gmail.com>.
Hi ole,
what form are you using? h:form or s:form? If you are using h:form,
then you'll be working against:
org/apache/myfaces/shared_impl/renderkit/html/HtmlFormRendererBase.java
In any case, you are right, they stem from the same source in:
org.apache.myfaces.shared.renderkit.html
- you should only need to change this, do a full maven build, and this
should take on your changes. The problem might however be that the
pom.xml of MyFaces impl is referring to an old version of shared, so
you might need to upgrade this to the snapshot version so that you
actually see your changes when you do the build.
regards,
Martin
On 12/17/07, Ole Ersoy <ol...@gmail.com> wrote:
> Hi,
>
> I've been trying to hack the HtmlFormRenderer. It's contained in
> org.apache.myfaces.shared.renderkit.html...but appears to be moved to
> org.apache.myfaces.shared_impl.renderkit.html during the build.
>
> I tried commenting out all of encodeBegin. Then I deleted the myfaces
> directory in my maven repository. Then rebuilt. Then redeployed the
> testing application, and maven only downloaded non-shared resources, so I'm
> certain that I'm changing the right dependency. The forms are still
> rendering though. When I do a find on HtmlFormRendererBase the following
> shows up:
>
> [ole@ole myfaces-shared-core-3_0_0]$ find . -name HtmlFormRendererBase.java
> ./shared-impl/target/refactored-shared-sources/main/java/org/apache/myfaces/shared_impl/renderkit/html/HtmlFormRendererBase.java
> ./core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
> ./shared-tomahawk/target/refactored-shared-sources/main/java/org/apache/myfaces/shared_tomahawk/renderkit/html/HtmlFormRendererBase.java
>
> So it seems like there is only one HtmlFormRenderBase to be changed, since
> the second one is the first one, and the Tomahawk one is not being used by
> the HtmlFormRenderer. Ideas?
>
> TIA,
> - Ole
>
>
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces