由于我已升级到WildFly 8,因此我的JSF自定义组件出现问题:第一次加载自定义组件时,会抛出错误:
IllegalStateException: Component ID formDlgPesqPccs:pesqOcupacaoCC:pesquisaOcupacaoDlg:pesquisaOcupacaoDlgbuttonpesquisaOcupacao has already been found in the view.
第一次后,组件正常呈现。我正在使用Mojarra 2.2.10。
复合组件(pesquisarOcupacao.xhtml):
<composite:interface>
<composite:attribute name="beanReference"
type="seb.sarh.pccs.PesquisarOcupacaoBean" required="true"/>
<composite:attribute name="updatePesquisa" required="true"/>
<composite:attribute name="pesquisaScrollHeight" required="true"/>
<composite:attribute name="estilo" required="true"/>
<composite:attribute name="estiloPesquisa" required="true"/>
<composite:attribute name="edicao" default="true"/>
</composite:interface>
<composite:implementation>
<div id="divWraperPesqOcupacao" style="#{cc.attrs.estilo}">
<p:panel styleClass="panelgrid">
<h:panelGrid columns="2">
<p:fieldset legend="Tipo da Pesquisa">
<p:selectOneRadio value="#{cc.attrs.beanReference.tipo}"
requiredMessage="Selecione o tipo de pesquisa.">
<f:selectItem itemValue="1" itemLabel="Cargo " />
<f:selectItem itemValue="2" itemLabel="Função" />
</p:selectOneRadio>
</p:fieldset>
<p:fieldset legend="Criterio da Pesquisa">
<p:selectOneRadio value="#{cc.attrs.beanReference.criterio}"
requiredMessage="Selecione o criterio de pesquisa.">
<f:selectItem itemValue="2" itemLabel="Código" />
<f:selectItem itemValue="1" itemLabel="Descrição" />
</p:selectOneRadio>
</p:fieldset>
</h:panelGrid>
</p:panel>
<div id="divPesquisa" class="reference" style="clear: left">
<p:fieldset legend="Texto a pesquisar" style="#{cc.attrs.estiloPesquisa} ">
<p:commandButton id="#{cc.id}buttonpesquisaOcupacao"
style="float: right"
update="#{cc.attrs.updatePesquisa}"
actionListener="#{cc.attrs.beanReference.pesquisarOcupacao}"
icon="ui-icon-search" process="@form" />
<div style="overflow: hidden; padding: 2px 15px 0 0; margin-right: 4px">
<p:inputMask id="cod" value="#{cc.attrs.beanReference.texto}"
mask="?99999" rendered="#{cc.attrs.beanReference.criterio == 2}"
style="width: 100%" />
<p:inputText id="desc" value="#{cc.attrs.beanReference.texto}"
rendered="#{cc.attrs.beanReference.criterio == 1}"
style="width: 100%" />
</div>
</p:fieldset>
</div>
<div id="divExpandPesqEstrutura" class="expand">
<p:fieldset id="#{cc.id}fldsetOcupacoesPesquisadas"
styleClass="expand-content" legend="Resultados da Pesquisa"
style="#{cc.attrs.estiloPesquisa}">
<p:dataTable id="datatable" styleClass="corner" emptyMessage=""
selectionMode="single" selection="#{cc.attrs.beanReference.selecaoPesquisa}"
value="#{cc.attrs.beanReference.listOcupacoes}" var="cargo"
scrollable="true" rowKey="#{cargo.hashCode()}"
scrollHeight="#{cc.attrs.pesquisaScrollHeight}">
<p:ajax event="rowSelect"
listener="#{cc.attrs.beanReference.onRowSelect}" />
<p:column width="10%">
<f:facet name="header">
<h:outputText value="Código" />
</f:facet>
<h:outputText value="#{cargo.codigo}" />
</p:column>
<p:column width="68%">
<f:facet name="header">
<h:outputText value="Descrição" />
</f:facet>
<h:outputText value="#{cargo.descricao}" />
</p:column>
<c:if test="#{cc.attrs.edicao}">
<p:column width="10%" style="text-align:center">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton id="editarOcupacaoButton" icon="ui-icon-pencil"
style="width: 20px; height: 20px" />
<p:tooltip for="editarOcupacaoButton"
value="Editar Cargo/Função" />
</p:column>
<p:column width="10%" style="text-align:center">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton id="excluirOcupacaoButton" icon="ui-icon-trash"
style="width: 20px; height: 20px" />
<p:tooltip for="excluirOcupacaoButton"
value="Excluir Cargo/Função" />
</p:column>
</c:if>
</p:dataTable>
</p:fieldset>
</div>
</div>
</composite:implementation>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd” id =“WebApp_ID”version =“3.0”&gt;
<display-name>SARH</display-name>
<error-page>
<error-code>404</error-code>
<location>/xhtml/error.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/xhtml/error.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/xhtml/error.xhtml</location>
</error-page>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>redmond</param-value>
</context-param>
<context-param>
<param-name>javax.faces.SERIALIZE_SERVER_STATE</param-name>
<param-value>true</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>/xhtml/selecionar_empresa.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<display-name>RelatorioServlet</display-name>
<servlet-name>RelatorioServlet</servlet-name>
<servlet-class>seb.sarh.util.RelatorioServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RelatorioServlet</servlet-name>
<url-pattern>/RelatorioServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
<session-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>