Reputation: 1157
I am facing the duplicate ids for columns issue in p:treeTable
i.e. same problem as described in the below link
http://forum.primefaces.org/viewtopic.php?f=3&t=31158&p=99463#p99463
So I would like to implement the solution as suggested in the above solution. So I thought of changing the source code and recompile and use the jar but I haven't got permission to do the same. I was asked to customise the class by extending the org.primefaces.component.api.UITree
class or somehow without changing the actual class in primefaces jar.
So now assume I have created a class with same name UITree and made necessary changes for me. Is there anyway to register this class so that my class can be used instead of primefaces class
Upvotes: 1
Views: 4282
Reputation: 1157
After some effort I have figured out a way how to solve my problem
I have written class which extends primefaces TreeTable
class like below and implemented the method visitColumns
as specified in the link (given in my question).
You have to override all the methods which calls visitColumns
method in the child class.
Now register it in the faces-config.xml as below
<component>
<component-type>org.primefaces.component.TreeTable</component-type>
<component-class>com.example.component.MyTreeTable</component-class>
</component>
I believe this is the simplest way and solved my problem. Answering my own question so that it may help others.
Upvotes: 0
Reputation: 1109830
You've 2 options:
Just put it in Java source folder of WAR project, maintaining the original package structure (thus, having exactly the same FQN). Classes in WAR have higher precedence in classloading over those in JARs in WAR's /WEB-INF/lib
. So, if exactly the same class (by FQN) is encountered in WAR, then it will be loaded from WAR instead of from JAR (in this particular case, PrimeFaces' one).
Register the component class in faces-config.xml
of WAR project on <p:treeTable>
's component type:
<component>
<component-type>org.primefaces.component.TreeTable</component-type>
<component-class>com.example.component.CustomTreeTable</component-class>
</component>
Also here, any component class registered in WAR's faces-config.xml
has higher precedence over the one in JAR's faces-config.xml
(in this particular case, PrimeFaces' one).
Upvotes: 5