2

While designing my jsf pages I realized that some of the components are being re-used at least twice or thrice in my application's different layouts. For example, as a hypothetical situation consider the vote-up button on SO which is included numerous times in a topic questions page(this is not in actual case) and (in a different layout) on each post on a specific question page.

So my concern is that, since a few of my components are being re-used twice (in different layouts), (like voteup buttons or options bar on posts) should I go with putting up my markup in custom components and use those components instead of writing same code at more than one place. Is there a performance issue to consider while chosing custom components for frequently rendered components?

And also is the markup for JSF components converted into html, during the build time or during the render time ?

1

1 Answer 1

3

On the easiest part of your question, I would say there is no appreciable performance issue with regard to using a custom component verses the in-line facelet tags. Although it looks complicated to you the Faclets servlet still has to pick through and compile about the same number of XML elements either way.

Aside from the issues discussed in the topic that BalusC linked to, I would add the primary purpose of JSF extensibility is to allow the developer to re-use code as much as possible. A related benefit is that your Facelet client page (one that uses a template) will be as compact and succinct as it is possible for XML markup to be.

My experience has been this can be a double-edged sword. You can burn a lot of development time sitting and tweaking custom components where you would have been better off just "compromising" and doing the cut-and paste thing from a working page to another page just to get the job done. This is where your trade-off really is. You really don't want to get into another Faces Component Library development project if you want to get your app deployed anytime soon.

My advice is to ignore as much as possible all the whiz-bang stuff (Javascript interactive graphics, etc.) and code your application with just boring old JSF basic components as much as possible. Get it working with the least-complicated components that will do the job. After the app is working you can go back and rework the presentation layer (Facelets markup) to optimize into reusable components or higher-function components like those from RichFaces, IceFaces, PrimeFaces, or *Faces.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I just didn't had the idea that composite components & custom components are different things (clarified through balusC's link). I am just trying to put up a mix of components provided by JSF & Primefaces as a reuseable piece of code that I could use at several places & not trying to introduce any new functionality thus I guess composite components qualify for the kind of thing I'm trying to achieve (!?) & the things you just spoke about were meant for custom components & composite components should be my choice if I want to reuse mix of components at multiple places??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.