Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:12:13+00:00 2026-05-26T07:12:13+00:00

@ResourceDependency(library = component/myComponent, name = myComponent1.css) public class MyComponent1 extends UIComponentBase { public void

  • 0
@ResourceDependency(library = "component/myComponent", name = "myComponent1.css")
public class MyComponent1 extends UIComponentBase {

    public void encodeBegin(FacesContext context) throws IOException {
        MyComponent2 comp2 = new MyComponent2();
        getChildren().add(comp2);
    }

}

@ResourceDependency(library = "component/myComponent", name = "myComponent2.css")
public class MyComponent2 extends UIComponentBase {

    // ...

}

myComponent1.css gets included into page, myComponent2.css does not.

Feature? Bug? Configuration issue?

It there programmatic way to add resources to maybe workaround this?

Running Mojarra 2.0.2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:12:14+00:00Added an answer on May 26, 2026 at 7:12 am

    I know this was asked 10 months ago, but I’ve been facing this same issue. Your resource problem here is caused by the fact that you are using “new” to instantiate your child component. Instead, you should use context.getApplication().createComponent("MyComponentType"),
    “MyComponentType” being whatever you specified as the value in @FacesComponent annotation. The application parses the annotations while it creates the component, not when it is rendering. Using new deprives the application from it’s opportunity to handle the annotations. Unfortunately, this doesn’t actually resolve the issue, it should, but it doesn’t.

    If you add:

    UIComponent headFacet = context.getViewRoot().getFacet("javax_faces_location_HEAD");
    if (headFacet == null) {
        System.out.println("No Head Facet");
    } else {
        System.out.println("Head Children: " + headFacet.getChildCount());
        for (UIComponent c : headFacet.getChildren()) {
            System.out.println(c.getRendererType());
            System.out.println(c.getAttributes().get("name"));
        }
    }
    

    to your encodeBegin method you will be able to see that the Resources have actually been added (example adding the PrimeFaces FileUpload as a child):

    INFO: Head Children: 4
    INFO: javax.faces.resource.Stylesheet
    INFO: fileupload/fileupload.css
    INFO: javax.faces.resource.Script
    INFO: jquery/jquery.js
    INFO: javax.faces.resource.Script
    INFO: core/core.js
    INFO: javax.faces.resource.Script
    INFO: fileupload/fileupload.js
    

    unfortunately, they still never get rendered, it is as if the component has a different view root than the page it is ultimately rendered on. I’m still looking into this further before report any bugs. I am currently running mojarra 2.0.6, I may try it on 2.2 to see if the issue is resolved.

    Update: Tested on Mojarra 2.1.3 and 2.2-SNAPSHOT. It does not work on either. I have added an issue to the Mojarra Issue Tracker

    Update Again: The people over at Mojarra have informed me that the encodeBegin is not the place to try adding components. They have pointed me to this blog posting, which describes how to “safely” do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting the following exception with a new resource Im making and i
I understand that they are compile time, so they can't be generic, and must
Initial Problem protected function _initMail() { $this->bootstrap('mail'); } in my Bootstrap.php Fails with a:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.