1

PF 3.5.10, Mojarra 2.1.21, JBoss 7.1.1, Omnifaces 1.5

Sometimes I have problems with JSF which are complicated to understand, and difficult to solve. E.g. my question Duplicate id error with primefaces dialog in template . So my question(s) is what do I need to debug Mojarra.

Now I can set debug points in Mojarra sources.

a) What Mojarra (or primefaces) Methods are a good start point to begin the debugging ?

b) As in my example if I want to find out why JSF (or primefaces) generate duplicate id, which methods should I observe (and debug) to find out the reason.

c) Do you have any tips for debugging ?

Community
  • 1
  • 1
Tony
  • 2,266
  • 4
  • 33
  • 54

1 Answers1

2

Your best to avoid problems with ids is not using the id attribute if you don't need to specifically refer to it in the view (for example, an Ajax update over the component). Just let JSF assign its own-generated id, that way you avoid duplicates.

About the debugging, check the javax.faces.webapp.FacesServlet class, which is the Servlet where JSF does its work. Here you'll be able to check each building and rendering process. However, don't obsess debugging your JSF implementation's internal classes, they are supposed to be tested, you should keep your own code in mind.

So my tip is: start debugging your own methods!

Aritz
  • 30,971
  • 16
  • 136
  • 217
  • I understand your suggestion, but if you look at the component tree (in my example) you can see that tree is generated clearly wrong. I want to know the source of this problem and how I can avoid this. So more debugging tips are welcome :-) Now I look at FacesServlet) – Tony Aug 29 '13 at 14:06
  • Your problem will probably be fixed with my tip, don't use ids in columns! If you need to perform an update just do it over the table! – Aritz Aug 29 '13 at 15:15
  • Unfortunately not. But after some experimenting it seems the problem has to do with datatable binding. – Tony Aug 29 '13 at 15:47
  • Can: http://stackoverflow.com/questions/2101755/im-getting-duplicate-id-error-after-adding-binding-attribute/ – BalusC Aug 29 '13 at 16:27
  • @BalusC Thank you for your help. Your link has helped me to understand (partly) the problem and to resolve it. So my duplicate id question is answered. – Tony Aug 30 '13 at 08:32
  • @BalusC If you have some tips to debugging question, it were very interesting. – Tony Aug 30 '13 at 08:34
  • 1
    Mistakes in the XHTML side are hard to debug in Java side. You basically need to keep track of all added components and their `binding` attributes. To me, it's easier to read the XHTML source code from top to bottom to spot duplicates (and yes, the problem is easier to solve if you know all possible causes beforehand, as listed in the link in my previous comment). I'm not really interested in posting an answer as this is not a technical problem and somewhat on edge with subjective. – BalusC Aug 30 '13 at 11:34