5

I'm using MyFaces 2.1.9 and PrimeFaces 3.5. I've implemented a custom renderer for <p:inputText>. This works fine at home with Tomcat. But this does not work at work with Websphere. I've placed breakpoints in the custom renderer class, but they are never hit. I see nothing in my logs as well. However, when I register the very same custom renderer on standard JSF <h:inputText>, then it works fine.

I've registered it as follows in faces-config.xml:

<render-kit>
    <renderer>
        <component-family>org.primefaces.component</component-family>
        <renderer-type>org.primefaces.component.InputTextRenderer</renderer-type>
        <renderer-class>xxx.xxx.xxx.MyInputRenderer</renderer-class>
    </renderer>
</render-kit>

How can I troubleshoot the registration of the custom renderer?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
KOT
  • 1,986
  • 3
  • 21
  • 35
  • 1
    Start with a breakpoint on `RenderKit#addRenderer()`. – BalusC Apr 10 '13 at 11:45
  • Thanks! Now I know that my renderer is processed first, then the regular renderer comes along in addREnderer and overwrites mine! How can I solve this? – KOT Apr 10 '13 at 15:11
  • Okay, that indeed explains it. Where's your `faces-config.xml`? In a custom module JAR file in `/WEB-INF/lib` or directly in webapp's `/WEB-INF`? If in JAR, then the loading order is undefined. If it's loaded before the PrimeFaces one, then you get this problem. – BalusC Apr 10 '13 at 15:12
  • It's in my regular web module. Here's my location: /WEB-INF/spring/faces-config.xml. I point to that URL with the javax.faces.CONFIG_FILES context parameter. – KOT Apr 10 '13 at 15:15
  • Try declaring it directly in main `/WEB-INF/faces-config.xml`. – BalusC Apr 10 '13 at 15:16
  • Now it works! I wonder why though... – KOT Apr 11 '13 at 08:21
  • Do you want to create an answer so you can get the points? Otherwise I'll do it – KOT Apr 13 '13 at 15:37

1 Answers1

8

Custom renderers which needs to override renderers of 3rd party component libraries needs to be registered in webapp's own faces-config.xml, not in a faces-config.xml which is packed in another JAR in /WEB-INF/lib as well. The loading order of JAR files is unspecified, so it may happen that the custom renderer is loaded and registered before the one of the 3rd party component library which you'd like to override, exactly like as you faced.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555