Duplicate Component Id Issue with UIAjax

UI Components for JSF
Post Reply
rubi
Posts: 160
Joined: 24 May 2010, 16:53

25 May 2010, 11:12

Hi;

What is wrong with this approach. I am getting a duplicate Component Id Issue

Code: Select all

        <h:form> 
            <h:panelGrid columns="1">
                <h:selectOneRadio binding="#{Bean.radio}">
                    <p:ajax event="change" update="menu"/>
                </h:selectOneRadio>
                <h:selectOneMenu id="menu" binding="#{Bean.menu}"/>
            </h:panelGrid>
        </h:form>

Code: Select all

@javax.faces.bean.ManagedBean(name = "Bean")
@javax.faces.bean.SessionScoped
public class Bean {

    HtmlSelectOneMenu menu = new HtmlSelectOneMenu();
    HtmlSelectOneRadio radio = new HtmlSelectOneRadio();

    public Bean() {
        menu.getChildren().add(getMenuItemSet1());
        radio.getChildren().add(getRadioItems());
        radio.addValueChangeListener(new ValueChangeListener() {

            public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
                if (((String) event.getNewValue()).equalsIgnoreCase("One")) {  
                    menu.getChildren().clear();
                    menu.getChildren().add(getMenuItemSet2());

                } }
        });
    }

    private UISelectItems getRadioItems() {
        List tempList = new ArrayList();
        UISelectItems uISelectItems = new UISelectItems();
        tempList.add(new SelectItem("One"));
        tempList.add(new SelectItem("Two"));
        tempList.add(new SelectItem("Three"));
        uISelectItems.setValue(tempList);
        return uISelectItems;
    }

    private UISelectItems getMenuItemSet1() {
        List tempList = new ArrayList();
        UISelectItems uISelectItems = new UISelectItems();
        tempList.add(new SelectItem("A"));
        tempList.add(new SelectItem("B"));
        uISelectItems.setValue(tempList);
        return uISelectItems;
    }

    private UISelectItems getMenuItemSet2() {
        List tempList = new ArrayList();
        UISelectItems uISelectItems = new UISelectItems();
        tempList.add(new SelectItem("C"));
        tempList.add(new SelectItem("D"));
        uISelectItems.setValue(tempList);
        return uISelectItems;
    }

    public HtmlSelectOneMenu getMenu() {
        return menu;
    }

    public void setMenu(HtmlSelectOneMenu menu) {
        this.menu = menu;
    }

    public HtmlSelectOneRadio getRadio() {
        return radio;
    }

    public void setRadio(HtmlSelectOneRadio radio) {
        this.radio = radio;
    }
}
Error:
An Error Occurred:
Component ID j_idt6:j_id4 has already been found in the view.
+- Stack Trace

java.lang.IllegalStateException: Component ID j_idt6:j_id4 has already been found in the view.
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:724)
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:708)
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:708)
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:708)
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:708)
at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:136)
at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:126)
at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:397)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)

+- Component Tree

<UIViewRoot id="j_id1" inView="true" locale="en_US" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/issue1.xhtml">
javax_faces_location_HEAD

<ComponentResourceContainer id="javax_faces_location_HEAD" inView="true" rendered="true" transient="false">

<Resource id="j_id2" inView="true" name="/yui/utilities/utilities.js" rendered="true" transient="false"/>

<Resource id="j_id3" inView="true" name="/jquery/jquery.js" rendered="true" transient="false"/>

<Resource id="j_id4" inView="true" name="/primefaces/core/core.js" rendered="true" transient="false"/>

</ComponentResourceContainer>

<?xml version="1.0" encoding="UTF-8"?> <!-- To change this template, choose Tools | Templates and open the template in the editor. --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<UIOutput id="j_idt4" inView="true" rendered="true" transient="false"/>

<UIOutput id="j_idt5" inView="true" rendered="true" transient="false">

<HtmlForm enctype="application/x-www-form-urlencoded" id="j_idt6" inView="true" prependId="true" rendered="true" submitted="false" transient="false">

<HtmlPanelGrid border="-2147483648" columns="1" id="j_idt7" inView="true" rendered="true" transient="false">

<HtmlSelectOneRadio border="-2147483648" disabled="false" id="j_idt8" immediate="false" inView="true" localValueSet="true" onchange="PrimeFaces.ajax.AjaxRequest('/BillingEE6/issue1.jsf',{formId:'j_idt6',global:true},{'j_idt6:j_idt9':'j_idt6:j_idt9','primefacesPartialUpdate':'j_idt6:menu'});" readonly="false" rendered="true" required="false" transient="false" valid="true" value="Three" binding="#{Bean.radio}">

<UISelectItems id="j_id2" inView="true" rendered="true" transient="false"/>

<UIAjax async="false" event="change" global="true" id="j_idt9" immediate="false" inView="true" rendered="true" transient="false" update="menu"/>

</HtmlSelectOneRadio>

<HtmlSelectOneMenu disabled="false" id="menu" immediate="false" inView="true" localValueSet="true" readonly="false" rendered="true" required="false" transient="false" valid="true" value="C" binding="#{Bean.menu}">

<UISelectItems id="j_id4" inView="true" rendered="true" transient="false"/>

<UISelectItems id="j_id4" inView="true" rendered="true" transient="false"/>


</HtmlSelectOneMenu>

</HtmlPanelGrid>

</HtmlForm>

</UIOutput>

</html>

</UIViewRoot>

JSF-2.0
PRIMEFACE : 2.0.2
SERVER : GLASSFISH v3
Glassfish V3.1.1,Mojarra 2.1.2, PrimeFaces-3.0RC1

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

25 May 2010, 11:17

Hi,

Maybe you have included this fragment twice (with ui:include). Is it your entire page or do you have more code?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

rubi
Posts: 160
Joined: 24 May 2010, 16:53

25 May 2010, 11:37

Thanks; No I just have one fragment
Glassfish V3.1.1,Mojarra 2.1.2, PrimeFaces-3.0RC1

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

25 May 2010, 11:59

rubi wrote:Thanks; No I just have one fragment
Try to set explicit exactly IDs. It will help. I had this issue too a long time ago with dynamic includes. I can not remember, but I think I tried to create a view fragment programmatically in the render response phase (quite late in the JSF lyfecycle). Check you lyfecycle.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

28 May 2010, 11:06

Avoid using component bindings to a bean that has session scope, otherwise you might end up with duplicate component id error, more information is at;

http://myfaces.apache.org/orchestra/myf ... dings.html

rubi
Posts: 160
Joined: 24 May 2010, 16:53

28 May 2010, 11:12

Thanks for the reply.
Glassfish V3.1.1,Mojarra 2.1.2, PrimeFaces-3.0RC1

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 May 2010, 14:13

You are welcome, hope it helped.

hemanth
Posts: 4
Joined: 24 Jun 2011, 20:16

24 Jun 2011, 21:19

I have the same Error.

I am using jsf 2.0 with primefaces 2.2.1 in RAD envi.


[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R java.lang.IllegalStateException: Component ID j_idt13:metadata has already been found in the view.
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.util.Util.checkIdUniqueness(Util.java:820)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.util.Util.checkIdUniqueness(Util.java:804)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.util.Util.checkIdUniqueness(Util.java:804)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.util.Util.checkIdUniqueness(Util.java:804)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:134)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:126)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at javax.faces.application.StateManager.getViewState(StateManager.java:525)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.context.PartialViewContextImpl.renderState(PartialViewContextImpl.java:390)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:285)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:179)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:968)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:378)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3933)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:445)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:504)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:275)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[6/24/11 14:16:51:541 CDT] 00000028 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[6/24/11 14:16:51:557 CDT] 00000028 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[6/24/11 14:16:51:557 CDT] 00000028 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[6/24/11 14:16:51:557 CDT] 00000028 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)

Any help would be appriciated.

Thanks in advance.

hemanth
Posts: 4
Joined: 24 Jun 2011, 20:16

24 Jun 2011, 22:28

I fixed the bug!

As I am finishing someone else's code, its difficult to recognize the nature of bug.

Thanks though

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

06 Oct 2011, 21:19

Code: Select all

SEVERE: Error Rendering View[/index.xhtml]
java.lang.IllegalStateException: [b]Component ID[/b] customerDetailForm:rowDetailTab:notesTx [b]has already been found in the view.[/b]  
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:821)
I experienced this bug as well, and yes, Oleg, I have dynamic ui:include's as well. I have a CUSTOMER page with a CUSTOMER tab that contains notesTx and also a POINT OF CONTACT tab which contains notesTx. When I saw the error, immediatley, i was pretty confident that the fix was to rename the fields, so I renamed them to pocNotesTx and customerNotesTx, respectively, and that solved this error.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests