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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:58:13+00:00 2026-05-25T06:58:13+00:00

I have a XHTML page which on submission goes back to itself. The backing

  • 0

I have a XHTML page which on submission goes back to itself.
The backing bean is session scoped. On the redirect to itself the page renders the h:dataable twice and gives me duplicate id error.I can visually see the table being rendered twice as well next to each other.
I releaize that it has some thing to do with the fact that backing bean has a property of faces html table and on return it creates again but whats the solution.

Following is roughly derived from this tutorial from JavaBeat . Only main difference is that my backing bean is Session Scoped.

I also releaize that my question probably does not clears it enough but code should 🙂 here it is

Backing bean

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.event.ValueChangeEvent;

import com.example.common.web.bean.BaseBean;

@ManagedBean(name = "registrationBean")
@SessionScoped
public class RegisterationViewManagedBean extends BaseBean {


    private String field;
    private List<Employee> employees;
    private Employee employee;
    private HtmlDataTable htmlDataTable;
    private List<Employee> list = new ArrayList();

    public void setSelected(ValueChangeEvent event) {
        employee = (Employee) htmlDataTable.getRowData();
        list = new ArrayList<Employee>();
        list.add(employee);
    }

    public List<Employee> getEmployees() {
        return employees;
    }

    public void setEmployees(List<Employee> employees) {
        this.employees = employees;
    }

    public HtmlDataTable getHtmlDataTable() {
        return htmlDataTable;
    }

    public void setHtmlDataTable(HtmlDataTable htmlDataTable) {
        this.htmlDataTable = htmlDataTable;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String dataSubmit() {
        for (Employee employee : this.list) {
            System.out.println(employee.getCity());
            System.out.println(employee.getName());
            System.out.println(employee.getEmpNo());
        }
        return "success";
    }

    public String submit() {
        this.employees = new ArrayList<Employee>();
        Employee employee1 = new Employee();
        employee1.setCity("Bangalore");
        employee1.setEmpNo("1");
        employee1.setName("Krishna");
        Employee employee2 = new Employee();
        employee2.setCity("Bangalore");
        employee2.setEmpNo("2");
        employee2.setName("ShunmugaRaja");
        Employee employee3 = new Employee();
        employee3.setCity("Bangalore");
        employee3.setEmpNo("3");
        employee3.setName("JoyChristy");
        this.employees.add(employee1);
        this.employees.add(employee2);
        this.employees.add(employee3);
        return "success";
    }
}

Xhtml Page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">



    <ui:define name="body">

        <h:form>
            <h:dataTable var="loc" value="#{registrationBean.employees}"
                binding="#{registrationBean.htmlDataTable}">
                <h:column>
                    <h:selectOneRadio onclick="radioButton(this);"
                        valueChangeListener="#{registrationBean.setSelected}">
                        <f:selectItem itemValue="null" />
                    </h:selectOneRadio>
                </h:column>
                <h:column>
                    <h:outputText value="#{loc.name}" />
                </h:column>
                <h:column>
                    <h:outputText value="#{loc.empNo}" />
                </h:column>
                <h:column>
                    <h:outputText value="#{loc.city}" />
                </h:column>
            </h:dataTable>
            <!-- Summary ends -->
            <div class="submitButtons">
                <h:commandButton id="register" action="#{registrationBean.submit}"
                    value="Perform Some Action" />
            </div>
        </h:form>
    </ui:define>
</ui:composition>

Stack trace

Caused by: java.lang.IllegalStateException: component with duplicate id "j_id397249623_10fed7a7:j_id397249623_10fed7bd:j_id397249623_10fed793" found
    at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.checkIds(DefaultFaceletsStateManagementStrategy.java:784)
    at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.checkIds(DefaultFaceletsStateManagementStrategy.java:800)
    at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.checkIds(DefaultFaceletsStateManagementStrategy.java:800)
    at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.checkIds(DefaultFaceletsStateManagementStrategy.java:800)
    at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.saveView(DefaultFaceletsStateManagementStrategy.java:432)
    at org.apache.myfaces.application.StateManagerImpl.saveView(StateManagerImpl.java:160)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1554)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:281)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:93)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)

Snap
enter image description here

  • 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-25T06:58:14+00:00Added an answer on May 25, 2026 at 6:58 am

    The problem is you are using a session scoped bean to store a page binding. The first time the page is rendered as expected. The second time, the binding has already a component, so all children is duplicated. The problem cannot be solved changing of JSF implementation (because both has the same code inherited from facelets). Try use two beans, one session scoped and the other one request scoped with the binding.

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

Sidebar

Related Questions

Here is my use cases. I have a login page which is /public/login.xhtml .
I have a complex ICEFaces XHTML page that renders certain components conditionally, based on
I have the following conversation scoped backing bean: @Named @ConversationScoped public class TestConversation implements
I have a JSF page which is outputting XHTML (from a facelet). One of
i have a xhtml popup page which has two buttons.The two buttons have actionListener
I have an .xhtml page in which I have tried both BalusC's suggestion here
I have a xhtml page in which there can be 0 to 6 check
I have a JSF project and I already have an index.xhtml page which is
I have an XHTML strict page that has an invisible div that is controlled
I have a well formed XHTML page. I want to find the destination URL

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.