For some standard VF components there are predefined facets such as headers and footer on apex:pageblockTable

Now I need to create my own component and it is not enough to have just a single apex:componentBody to inject all the downstream markup but I need several places to put markup exactly like apex:facet does for standard components.

Is there a way to use facets?

It is always hard to be sure something is really not present, but ideas like the following indicate that this is a non-existing feature:


Reading the docs, this became not perfectly clear. It's stated that only predefined facets will work. However if or how we can define those facets isn't mentioned.

If it's not supported, is there any workaround?

The only thing I came up with is using jquery to rearrange the markup after rendering based on class attributes.

Anything better?

To ask if it's on the roadmap (as I tend to do always) will probably be answered with: no. But nevertheless I'd like to ask anyway.


As you've already seen, apex:component doesn't support custom facets, which means that you're going to have to look for an alternative solution if you want to have reusable code. If possible, use pure CSS for placement of the elements. It's arguably the cleanest solution if you want to place stuff on the page. Resist the urge to do DOM manipulation, because Visualforce likes its elements to stay put, and you might break something without extreme care, and I'd consider such an attempt to be brittle at best.

That said, if you want the sort of templates you're looking for, Visualforce isn't the solution. Use AngularJS, BackboneJS, Lightning, or some other template framework. There's enough choices out there today that you shouldn't arbitrarily think about being stuck in Visualforce, which was very cool in 2007, but is definitely showing its age a decade later.

Lightning has native support for defining custom sections by way of defining attributes. Also, if you go with Lightning, you're working on components that you'll be able to reuse in the coming years as we're shuffled towards Lightning, and Classic is retired or, at least, no longer actively maintained (note: this last part is just an educated guess, I have no idea what salesforce will do in the coming years).

My hypothesis, given the size of Lightning, is that Visualforce is only being very lightly developed at the moment, if at all; I would be highly surprised if custom facets ever saw the light of day. Salesforce is investing heavily in mobility, and Visualforce has never been particularly mobile. While Visualforce does work on mobile devices, when enabled, it was pretty much left up to the developer to make sure their code was mobile-friendly. Visualforce is based on now-ancient technology that pretty much assumed everyone was still using a computer to use the Internet. Lightning, in contrast, is mobile-friendly with minimal effort, and provides a lot of customization for components in ways Visualforce could only dream about.

  • there is still at least one very good reason to stick with visualforce for a while: that is apex:inputField - hopefully force:inputField might be par within a while, but right now if mobility is no priority just to quickly produce forms visualforce is still a pretty sharp blade. The fact that visualforce is not evolving anymore makes it also very stable, while in lightning a lot is going on, of which some changes comes with significant efforts to adapt... so I will find my way around the missing facets, I guess at least for a while.
    – Uwe Heim
    Jan 9 '17 at 23:00
  • @UweHeim Yeah, I've tried to do what you're doing before, and every time I just ended up using CSS to fake it. Once they shake out the force:inputField bugs, I think it'll definitely be the way to go, but for now we've been mostly limiting ourselves to using lightning:* and ui:* components.
    – sfdcfox
    Jan 9 '17 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.