Reputation: 89169
Let's take a simple scenario of HTML5 tag. A <html>
tag can only permit one <head>
and one <body>
tag. Suppose we have a HTMLUIComponent
, HTMLHeadUIComponent
, HTMLBodyUIComponent
represent each HTML tags specified above respectively, how would I allow that the HTMLHeadUIComponent
and HTMLBodyUIComponent
be rendered only inside a HTMLUIComponent
and not in other component?
Upvotes: 1
Views: 182
Reputation: 1108782
Easiest way would be to just do something like this during encodeBegin()
:
if (!(component.getParent() instanceof HTMLUIComponent)) {
throw new IllegalArgumentException("HTMLHeadUIComponent must have a parent of type HTMLUIComponent");
}
If you need to do this during view build time (instead of view render time), then you can't go around creating and adding a tag handler for the component and do the check over there in apply()
method.
Upvotes: 1