Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.cdlflex.ui.behavior;
Behavior that adds all added ResourceReferences as HeaderItems to the IHeaderResponse. It distinguishes between JavaScriptResourceReference (added as JavaScriptHeaderItem) and CssResourceReference (added as CssReferenceHeaderItem).

In a Component this can be used to add references to the Header when the page renders

 getPage().add(new FrontendDependencyBehavior(new JavaScriptResourceReference(...));
public class FrontendDependencyBehavior extends Behavior {
    private static final long serialVersionUID = 1L;
    private List<ResourceReferencereferences;
    protected FrontendDependencyBehavior() {
        this(new ArrayList<ResourceReference>());
    public FrontendDependencyBehavior(ResourceReference... references) {
        this(new ArrayList<>(Arrays.asList(references)));
    public FrontendDependencyBehavior(List<ResourceReferencereferences) {
        this. = references;
    public void renderHead(Component componentIHeaderResponse response) {
        for (HeaderItem item : getHeaderItems()) {

Returns the ResourceReferences used as dependencies as HeaderItems.

a list of HeaderItems
    public List<HeaderItemgetHeaderItems() {
        return ResourceReferences.asHeaderItems(getResourceReferences());

Returns the ResourceReferences used as dependencies.

a list of ResourceReferences
        return ;
New to GrepCode? Check out our FAQ X