Não estou entendendo o que acontece. Tenho definido um ContextBean. Segue o código:
@ManagedBean(name = "contextBean")
@SessionScoped
public class ContextBean {
private Company company = null;
private Client activeClient = null;
public Company getCompany() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext external = context.getExternalContext();
String companyName = external.getRemoteUser();
if (this.company == null || !companyName.equals(this.company.getName())) {
if (companyName != null) {
CompanyRN companyRN = new CompanyRN();
this.company = companyRN.getCompanyByName(companyName);
this.activeClient = null;
}
}
return this.company;
}
public void setCompany(Company company) {
this.company = company;
}
public Client getActiveClient() {
return this.activeClient;
}
public void setActiveClient(ValueChangeEvent event) {
Integer clientCode = Integer.parseInt((String)event.getNewValue());
ClientRN clientRN = new ClientRN();
this.activeClient = clientRN.get(clientCode);
}
}
Estou usando Facelets. Se o meu header.xhtml está assim:
[code]<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition>
<h:form id="header">
<h:outputLabel value="#{contextBean.company.longName}" />
<h:outputLabel value=" #{msg.client_active_client}: "/>
<h:selectOneMenu valueChangeListener="#{contextBean.setActiveClient}" rendered="#{!empty contextBean}" onchange="submit()">
<f:selectItem itemLabel="" noSelectionOption="true" />
<f:selectItems value="#{clientBean.list}" var="client" itemValue="#{client.code}" itemLabel="#{client.longName}"/>
</h:selectOneMenu>
<h:outputLabel value="#{contextBean.activeClient.address}"/>
<a href="#{request.contextPath}/j_spring_security_logout">Logout</a>
</h:form>
</ui:composition>
[/code]
Funciona perfeitamente, a página abre e eu posso navegar sem problemas. Porém, sempre que entro com uma parte de código COMENTADA, dá erro:
[code]<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition>
<h:form id="header">
<h:outputLabel value="#{contextBean.company.longName}" />
<h:outputLabel value=" #{msg.client_active_client}: "/>
<h:selectOneMenu valueChangeListener="#{contextBean.setActiveClient}" rendered="#{!empty contextBean}" onchange="submit()">
<f:selectItem itemLabel="" noSelectionOption="true" />
<f:selectItems value="#{clientBean.list}" var="client" itemValue="#{client.code}" itemLabel="#{client.longName}"/>
</h:selectOneMenu>
<h:outputLabel value="#{contextBean.activeClient.address}"/>
<a href="#{request.contextPath}/j_spring_security_logout">Logout</a>
<!--
<p:layout>
<p:layoutUnit position="west" size="190">
<h:outputLabel value="#{contextBean.company.longName}" />
<h:outputLabel value=" #{msg.client_active_client}: "/>
<h:selectOneMenu valueChangeListener="#{contextBean.setActiveClient}" rendered="#{!empty contextBean}" onchange="submit()">
<f:selectItem itemLabel="" noSelectionOption="true" />
<f:selectItems value="#{clientBean.list}" var="client" itemValue="#{client.code}" itemLabel="#{client.longName}"/>
</h:selectOneMenu>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:outputLabel value="#{contextBean.activeClient.address}"/>
</p:layoutUnit>
<p:layoutUnit position="east">
<a href="#{request.contextPath}/j_spring_security_logout">Logout</a>
</p:layoutUnit>
</p:layout>
-->
</h:form>
</ui:composition>
[/code]
O erro é:
javax.el.PropertyNotFoundException: Property 'setActiveClient' not found on type br.com.spai.systraxxnet.web.ContextBean
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:214)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:191)
at javax.el.BeanELResolver.property(BeanELResolver.java:300)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:81)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:57)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:45)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
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:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at br.com.spai.systraxxnet.web.filter.ConnectionHibernateFilter.doFilter(ConnectionHibernateFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Alguém tem noção do pq acontece isso?