Monday, September 29, 2014

Primefaces Tree with Header for children

So this time the requirement was to generate a primefaces tree on UI which demonstrates hierarchical relationship between some business objects. Easy enough, the only problem was to show the header of children once per parent something like:

                 Parent Header 1                 Parent Header 2               Parent Header 3
Parent 1
|_____ Child 1A
                 Child Header 1                 Child Header 2               Child Header 3
             |_____ Child 1Aa
             |_____ Child 1Ab
|_____ Child 1B
|_____ Child 1C
                 Child Header 1                 Child Header 2               Child Header 3
             |_____ Child 1Ca

The possible options are put a panelGroup and render it based upon whether children are present or not...

or the easy way where you can fix the model by adding one dummy child for headers only so the tree looks like:

Parent 1
|_____ Child 1A
             |_____ (H) Child Header 1                 Child Header 2               Child Header 3
             |_____ Child 1Aa
             |_____ Child 1Ab
|_____ Child 1B
|_____ Child 1C
                 Child Header 1                 Child Header 2               Child Header 3
             |_____ (H) Child Header 1                 Child Header 2               Child Header 3
             |_____ Child 1Ca

where this can be managed easily with model.

Friday, August 1, 2014

Creating Java Entity from Table definition

Every now and then I run into this situation where I have to create a new Java entity from a table and I have created this formula to generate the names of the fields which works really efficiently every time in MS Excel.

=CONCATENATE(LOWER(LEFT(SUBSTITUTE(PROPER((SUBSTITUTE(A1,"_"," ")))," ",""),1)),RIGHT(SUBSTITUTE(PROPER((SUBSTITUTE(A1,"_"," ")))," ",""),LEN(SUBSTITUTE(PROPER((SUBSTITUTE(A1,"_"," ")))," ",""))-1))