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 7459079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:57:13+00:00 2026-05-29T13:57:13+00:00

In my JSF 2.0 project, I get a name-space collision when I include two

  • 0

In my JSF 2.0 project, I get a name-space collision when I include two identical XHTML files in a single parent XHTML file. My goal is to create a dashboard of identical controls on a single page, with each control representing a separate context.

For example, in the following JSF file, called parent.xhtml (say), I include two “dashboard” facelets:

<ui:define name="body">
    <p:panel id="ONE"  >
        <ui:include src="raceboardunit.xhtml"/>
    </p:panel>

    <p:panel id="TWO" >
        <ui:include src="raceboardunit.xhtml"/>
    </p:panel>
</ui:define>

To be simple, say the child facelet “raceboardunit.xhtml” is the following:

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core" 
            xmlns:p="http://primefaces.prime.com.tr/ui">

    <p:panel header="Dashboard" >
        <h:panelGrid columns="2">
            <h:outputLabel value="Event" for="idEvent}" />
            <h:outputLabel value="#raceBoardController.name}" id="idEvent" />
        </h:panelGrid>
    </p:panel>
</ui:composition>

The problem is the collision involving the output label id=”idEvent”, since in the parent.xhtml file, the two inclusions of the child facelet have an identical named component.

The error is reported as: Component ID idEvent has already been found in the view.

The reason for the error is obvious, but what is the best way to include a variable number of identical components in a JSF 2.0 application that maximises code reuse?

  • 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-29T13:57:24+00:00Added an answer on May 29, 2026 at 1:57 pm

    Easiest but ugliest way is to wrap it in a <f:subview> which basically introduces a new UINamingContainer layer.

    <p:panel id="ONE">
        <f:subview id="board1">
            <ui:include src="raceboardunit.xhtml"/>
        </f:subview>
    </p:panel>
    <p:panel id="TWO">
        <f:subview id="board2">
            <ui:include src="raceboardunit.xhtml"/>
        </f:subview>
    </p:panel>
    

    Better is to make it a tag file or a composite component instead.

    Here’s an example of how it can look like as a tag file:

    <p:panel id="ONE">
        <my:raceboardunit id="board1" />
    </p:panel>
    <p:panel id="TWO">
        <my:raceboardunit id="board2" />
    </p:panel>
    

    with in tag file

    <h:outputLabel for="#{id}_idEvent" value="Event" />
    <h:inputText id="#{id}_idEvent" value="#{raceBoardController.name}" />
    

    (I think that you oversimplified the example in the question too much that it made no sense; a label referring another label? So I’ve also fixed it so that it makes somewhat sense.)

    A composite component has basically the same usage as a tag file, but is by itself implicitly already an UINamingContainer, so you wouldn’t need to manually prefix the IDs inside the composite component implementation.

    <h:outputLabel for="idEvent" value="Event" />
    <h:inputText id="idEvent" value="#{raceBoardController.name}" />
    

    See also:

    • When to use <ui:include>, tag files, composite components and/or custom components?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: I want to use jsf`s i18n Scenario: creating resource bundle (utf-8) file info:
I am using JSF and EJB as two separate project in my application. Below
I'm trying to get an imported project to work and i'm new to JSF.
I'm scrubbing through a large number of XML based files in a JSF project,
Is there any documentation about introducing jBoss seam to an old Hibernate/JSF project? Have
I am using NetBeans and JSF to do my project. Recently I encountered a
In JSF is it possible to have a datatable displays records as follows? [Name
Because I get some errors on conversations ending abruptly, I created in my project
In my current project we're trying to write an application (using SUN RI JSF
I'm working on an Enterprise project with Java EE 5 and JSF 2.0 (Mojarra

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.