Sunday, July 15, 2012


A JSF PhaseListener to Print the Component Tree (Example)
Have you ever wondered what the exact makeup of the server side JSF UI component tree in your page?
I was wondering the exact same thing, so I wrote a simple PhaseListener, that dumps the component tree to standard out.
The algorithm is a simple recursive printout of the entire component tree..
Here's the code:
package componentstuff;

import java.util.ArrayList;
import java.util.List;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

public class PrintComponentTree implements PhaseListener {
  public PrintComponentTree() {
  }

  public int indent = 0;
  public static final int INDENTSIZE = 2;

  public void beforePhase(PhaseEvent PhaseEvent) {
  }

  public void afterPhase(PhaseEvent PhaseEvent) {
    System.out.println("");
    System.out.println("(Rendering Component Tree)");
    printComponentTree(FacesContext.getCurrentInstance().getViewRoot());
  }

  public PhaseId getPhaseId() {
    return PhaseId.RENDER_RESPONSE;    
  }
  
  public void printComponentTree(UIComponent comp){
    printComponentInfo(comp);
    
    List complist = (ArrayList)comp.getChildren();
    if (complist.size()>0)
      indent++;
    for   (int i = 0; i < complist.size(); i++) {
      UIComponent uicom = (UIComponent) complist.get(i);
      printComponentTree(uicom);
      if (i+1 == complist.size())
        indent--;
    }
    
  }

  public void printComponentInfo(UIComponent comp){
  
   if (comp.getId() == null){
     System.out.println("UIViewRoot" + " " + "(" + comp.getClass().getName() + ")");
   } else {
       printIndent();
       System.out.println("|");
       printIndent();
       System.out.println(comp.getId() + " " + "(" + comp.getClass().getName() + ")");
     }  
  }
 
  public void printIndent(){
    for (int i=0; i
Also, don't forget to register it in your faces-config..
  
    componentstuff.PrintComponentTree
  
Here's what the output looks like for a simple Faces page:
06/03/03 17:26:39 (Rendering Component Tree)
06/03/03 17:26:39 UIViewRoot (javax.faces.component.UIViewRoot)
06/03/03 17:26:39   |
06/03/03 17:26:39   form1 (javax.faces.component.html.HtmlForm)
06/03/03 17:26:39     |
06/03/03 17:26:39     panelGrid1 (javax.faces.component.html.HtmlPanelGrid)
06/03/03 17:26:39       |
06/03/03 17:26:39       outputLabel1 (javax.faces.component.html.HtmlOutputLabel)
06/03/03 17:26:39       |
06/03/03 17:26:39       inputText1 (javax.faces.component.html.HtmlInputText)
06/03/03 17:26:39       |
06/03/03 17:26:39       outputLabel2 (javax.faces.component.html.HtmlOutputLabel)
06/03/03 17:26:39       |
06/03/03 17:26:39       inputSecret1 (javax.faces.component.html.HtmlInputSecret)
06/03/03 17:26:39       |
06/03/03 17:26:39       commandButton1 (javax.faces.component.html.HtmlCommandButton)

Feel free to tweak the code however you like!

13 comments:

Anonymous said...

http://louboutinmart.co.uk Most likely crow or kestrel. [url=http://dkgoose.com]canada goose[/url] Aoacfulrb http://www.louboutinoutletuks.co.uk
axwplk 242913 [url=http://www.chilliwackbombersoutlet.com]goose image[/url] 150379 [url=http://www.officialcanadagooseparkas.ca]canada goose jackets montreal[/url]

Anonymous said...

[url=http://louboutinmart.co.uk]christian louboutin uk[/url] as an acronym. [url=http://dkgoose.com]Canada Goose tilbud[/url] Exvlxrakx [url=http://www.louboutinoutletuks.co.uk]louboutin outlet[/url]
vxdgby 288478 [url=http://www.chilliwackbombersoutlet.com]canada goose freestyle[/url] 258688 [url=http://www.beatsbydreaonsales.com]dr dre[/url]

Anonymous said...

Major depression is actually a difficult point to
emerge from, plus it does not matter when the depressive disorders
is hereditary or perhaps a solution to a heartbreaking function. Nonetheless, there are many
different treatment options, which includes prescription drugs, psychotherapy and also
basic behavioral changes. The next article
provides you with information to aid clear despression symptoms out of your daily life.


Permit you to ultimately crash often. One of the biggest stuff
individuals with despression symptoms have a problem with
is perfectionism. You don't must do everything correct at all times.

Often you'll get issues wrong, and that's alright.
Concentrate on what performed go correct as an alternative of what
gone wrong, and move ahead.

Among the best ways to take care of depressive disorders
is as simple as acquiring a new pastime. A stable deficiency
of curiosity about activities can really become a
major consider the onset of major depression. Try commencing a new artistic interest or subscribe to a category to reduce feeling of boredom through
your daily life. Regardless of what suits you, performing something in any
way will decrease your probability of creating despression symptoms.



If you're dealing with your personalized concerns, it will help you together with your depressive disorders.
Using some tiny techniques can stop you from obtaining overwhelmed.
Just do a couple of tasks at one time. Divide bigger targets into modest goals to
assist overcome depressive disorders, and this can also
help resolve some things that are resulting in depression.

The difference involving specialized medical
major depression and typical unhappiness is much like the
main difference from a supply and a stream. If you are you may have been unfortunate for absolutely no reason or remained unfortunate for a long time there exists a possibility you may have scientific major depression. Make sure you
have this examined by way of a specialist.

Will not be ashamed when your despression symptoms has pressured you to need to acquire prescription medication. At times, despression symptoms signs or symptoms are so poor the finest points to enable them to are
medicines. Speak with a psychiatrist to learn if medication is
a good choice to suit your needs and which medicine is greatest.


Even though the research on aromatherapy is inconclusive, no specialist will deny the power of scent.

Possessing a few enjoyable-smelling candle lights getting rid of
through the residence will help you to feel good effortlessly.

One of the best fragrances for evoking nice feelings is vanilla, though any fragrance that you like will continue to work.


As with anything at all, the management of major depression has several scientific studies, approaches, and theories right behind the way
to treat it. It is additionally fully reliant on the person. Ideally, you possess received help from these guidelines into how to
start with dealing with your depressive disorders to enable you
to begin sensing better earlier.

Feel free to surf to my weblog - hypnose émétophobie

Anonymous said...

Or patio furniture covers child wooden desk may also be cost prohibitive.
Make sure that there is a picture. Besides this features,
beds should be a beaming, vibrant, and inviting kids' room!
Also watch out for corner posts. If think your baby is too a
bit older to get a desk. There are different ways of decorating
and creating your particular one.

my webpage - children bedspreads ()

oakleyses said...

jordan pas cher, chanel handbags, nike outlet, michael kors pas cher, kate spade outlet, replica watches, longchamp pas cher, nike free, jordan shoes, christian louboutin shoes, nike free run, louis vuitton outlet, oakley sunglasses, ray ban sunglasses, polo ralph lauren, ugg boots, christian louboutin uk, air max, louis vuitton outlet, ugg boots, tiffany jewelry, polo ralph lauren outlet online, burberry pas cher, prada outlet, nike air max, gucci handbags, sac longchamp pas cher, ray ban sunglasses, louboutin pas cher, louis vuitton, uggs on sale, tiffany and co, oakley sunglasses, louis vuitton outlet, ray ban sunglasses, longchamp outlet, louis vuitton, longchamp outlet, replica watches, nike roshe, polo outlet, oakley sunglasses, cheap oakley sunglasses, oakley sunglasses wholesale, christian louboutin, christian louboutin outlet, tory burch outlet

oakleyses said...

lululemon canada, nike air max, burberry outlet, oakley pas cher, burberry handbags, coach outlet store online, kate spade, michael kors outlet, michael kors, nike air force, true religion jeans, true religion outlet, michael kors, polo lacoste, nike tn, new balance, abercrombie and fitch uk, michael kors outlet, uggs outlet, michael kors outlet, ralph lauren uk, michael kors outlet online, replica handbags, coach outlet, true religion outlet, coach purses, nike free uk, sac vanessa bruno, mulberry uk, michael kors outlet online, michael kors outlet online, michael kors outlet online, north face, uggs outlet, converse pas cher, hogan outlet, nike air max uk, hollister pas cher, sac hermes, nike roshe run uk, hollister uk, nike air max uk, true religion outlet, timberland pas cher, vans pas cher, ray ban pas cher, guess pas cher, ray ban uk

oakleyses said...

supra shoes, marc jacobs, canada goose, converse outlet, toms shoes, ugg uk, ugg pas cher, canada goose outlet, canada goose, nike air max, louis vuitton, karen millen uk, doudoune moncler, converse, louis vuitton, vans, gucci, montre pas cher, moncler outlet, canada goose uk, canada goose outlet, moncler, pandora jewelry, barbour uk, moncler outlet, juicy couture outlet, louis vuitton, canada goose, pandora uk, coach outlet, swarovski crystal, ugg,uggs,uggs canada, juicy couture outlet, links of london, louis vuitton, louis vuitton, hollister, swarovski, canada goose outlet, ray ban, moncler, ugg, barbour, ugg,ugg australia,ugg italia, replica watches, pandora charms, moncler uk, pandora jewelry, wedding dresses, canada goose jackets, hollister, lancel

Unknown said...


zhengjx20160721
michael kors outlet
ray bans
adidas stan smith
michael kors outlet online
michael kors outlet
christian louboutin sale clearance
michael kors outlet clearance
michael kors canada outlet
christian louboutin sale
christian louboutin wedges
toms outlet
michael kors outlet
polo ralph lauren
pandora charms
louis vuitton purses
gucci outlet
gucci outlet
louis vuitton purses
cheap toms
lebron james shoes 13
michael kors outlet clearance
copy watches
adidas superstar
ralph lauren outlet
giuseppe zanotti outlet
air max 95
jordan 3 retro
cheap louis vuitton handbags
louis vuitton outlet
christian louboutin sale
coach factory outlet
fitflops
michael kors outlet
kate spade handbags
tory burch flats
kobe shoes
ray bans
louis vuitton outlet stores
christian louboutin shoes
oakley sunglasses wholesale

raybanoutlet001 said...

adidas tubular x
true religion jeans
ray ban sunglasses outlet
tiffany and co jewelry
tiffany and co uk
mlb jerseys shop
chrome hearts online store
yeezy
chrome hearts online
yeezy boost 350
http://www.chromehearts.com.co
adidas yeezy uk
louboutin shoes
michael kors outlet
cheap oakley sunglasses
http://www.nikedunks.us.org
retro jordans
ralph lauren uk
michael jordan shoes
toms outlet store
yeezy boost
tiffany and co uk

Unknown said...

tommy hilfiger canada
hermes bags
bottega
birkenstock outlet
burberry scarf
michaelkors outlet
north face
nike outlet
longchamp
north face
20181.20wengdongdong

jeje said...

basket hommes nike air max tn Cette entreprise air jordan team basketball jerseys est assez célèbre pour la fabrication sportive Nike Shox R3-R4 pour différents sports comme le tennis et air jordan 5 grape gs le basket-ball. C'est certainement l'un des produits et des solutions les asics chaussures trail plus courants offerts à la télévision, et d'innombrables ont déjà été offerts air jordan 11 low concord retail price dans le monde entier. Si nous nous réveillons tous les matins Air Jordan 4 Femme à 6h du matin pour boire un café et basket nike femme presto fly manger des beignets si vous regardez la télé, nous pouvons vous garantir que baskets nike air presto vous vous réveillerez à 6h du matin pour manger sainement et faire du sport.

tamer said...

شركات نقل عفش خارج الرياض
تتنافس شركات نقل عفش خارج الرياض فيما بينها لتفوز برضا العملاء، وتساعدهم على نقل العفش والأثاث داخل وخارج الرياض أو حتي خارج المملكة، لذلك يمكن للعميل أن يلاحظ إختلاف الأسعار والعروض بين الشركات المختلفة، كما يظهر هذا واضحا على أسلوب تنفيذ الخدمة، فبعض شركات نقل عفش خارج الرياض تقوم بتقليل أسعارها على حساب استخدام أدوات وخامات تحافظ على قطع الأثاث المختلفة أثناء عملية النقل، في حين أن استخدام تلك القطع حتي وإن كان تكلفة إضافية يتحملها العميل وتزيد من التكلفة الإجمالية، إلا أنها تعتبر واجبه للحفاظ على قطع الأثاث من الخدش أو التلف أثناء عملية النقل مما يخفض من إمكانية التلف

Unknown said...

شركة تنظيف مكيفات بالرياض
شركة تنظيف مجالس بالرياض
شركة تنظيف شقق بالرياض
شركة تنظيف فلل بالرياض
شركة تنظيف خزانات بالرياض
شركة تنظيف افران بالرياض
شركة جلي بلاط بالرياض
شركة مكافحة الحمام بالرياض