New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tagAttribute: default id #474

Closed
Rapster opened this Issue Jul 11, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Rapster

Rapster commented Jul 11, 2018

As recommanded after reading posts, I'm trying to convert some of our composites into facelet tags. So far so good, it works perfectly fine, except on little detail: default id. To handle that use case, I reuse this https://stackoverflow.com/a/43275214/4605161.

But since I did this, I have a strange behavior (certainly explainable...). Based on this code:

        <h:form>
            <p:outputLabel value="p:selectOneMenu" />
            <p:selectOneMenu value="#{testView.brand}">
                <f:selectItem itemValue="#{ null }" itemLabel="AUCUN" />
                <f:selectItems value="#{carService.brands}" 
                               var="object"
                               itemLabel="#{object}"
                               itemValue="#{object}" />
                <p:ajax update="@form" />
    
            </p:selectOneMenu>

            <p:outputLabel value="t:selectOneMenu" />
            <t:select items="#{carService.brands}" value="#{testView.brand}">
                <p:ajax event="change" update="@form" />
            </t:select>
        </h:form>

t:select is a facelet tags and it's just like the declaration of p:selectOneMenu. The problem is when I select an item from the facelet tag, it seems the selected item is not taking account. It works if I remove <o:tagAttribute name="id" default="#{view.createUniqueId()}"/> from the facelet tag.

default_id

I'm not sure <o:tagAttribute /> is handling well the case where the default attribute is an id. My guess is that using update="@form" force to generate a new id but it doesn't happen using <p:selectOneMenu />

P.S: using Omnifaces 2.6.9

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Jul 23, 2018

Member

Cause: #{view.createUniqueId()} increments on every postback whereas it should stay the same on a per-view basis.

I'll probably have to add a special case of defaultValue of <o:tagAttribute> with a name="id".

Member

BalusC commented Jul 23, 2018

Cause: #{view.createUniqueId()} increments on every postback whereas it should stay the same on a per-view basis.

I'll probably have to add a special case of defaultValue of <o:tagAttribute> with a name="id".

BalusC added a commit that referenced this issue Jul 23, 2018

@BalusC BalusC closed this Jul 23, 2018

@Rapster

This comment has been minimized.

Show comment
Hide comment
@Rapster

Rapster Jul 24, 2018

Thank a lot @BalusC this use case is working, but if I add a second t:select (without specifying an id again). I'll have this error:

java.lang.IllegalStateException: L’ID de composant «createCNT:containerCreateForm:j_ido6f315a52» a déjà été détecté dans la vue.
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1026)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.saveView(FaceletPartialStateManagementStrategy.java:460)
	at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:89)
	at com.sun.faces.application.view.WriteBehindStateWriter.getState(WriteBehindStateWriter.java:327)
	at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:473)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:180)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.NoCacheFilter.doFilter(NoCacheFilter.java:58)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.security.SparkSecurityFilter.doFilter(SparkSecurityFilter.java:87)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.security.SparkResourceFilter.doFilter(SparkResourceFilter.java:67)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.LogFilter.doFilter(LogFilter.java:54)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.IECompatibilityFilter.doFilter(IECompatibilityFilter.java:46)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.FlashScopeFixerFilter.doFilter(FlashScopeFixerFilter.java:29)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:97)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.omnifaces.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:123)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

(Sorry the error message is French... Basically, it says that the component id has already been found in the view)

Rapster commented Jul 24, 2018

Thank a lot @BalusC this use case is working, but if I add a second t:select (without specifying an id again). I'll have this error:

java.lang.IllegalStateException: L’ID de composant «createCNT:containerCreateForm:j_ido6f315a52» a déjà été détecté dans la vue.
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1026)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.util.Util.checkIdUniqueness(Util.java:1010)
	at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.saveView(FaceletPartialStateManagementStrategy.java:460)
	at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:89)
	at com.sun.faces.application.view.WriteBehindStateWriter.getState(WriteBehindStateWriter.java:327)
	at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:473)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:180)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.NoCacheFilter.doFilter(NoCacheFilter.java:58)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.security.SparkSecurityFilter.doFilter(SparkSecurityFilter.java:87)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.security.SparkResourceFilter.doFilter(SparkResourceFilter.java:67)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.LogFilter.doFilter(LogFilter.java:54)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.IECompatibilityFilter.doFilter(IECompatibilityFilter.java:46)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at spark.ui.web.FlashScopeFixerFilter.doFilter(FlashScopeFixerFilter.java:29)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:97)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.omnifaces.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:123)
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

(Sorry the error message is French... Basically, it says that the component id has already been found in the view)

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Jul 24, 2018

Member

I see.

Member

BalusC commented Jul 24, 2018

I see.

@Rapster

This comment has been minimized.

Show comment
Hide comment
@Rapster

Rapster Jul 25, 2018

Thanks, works like a charm ;-)

Rapster commented Jul 25, 2018

Thanks, works like a charm ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment