1

我正在使用 JSF 2.0、Spring、Hibernate,并且在初始化 ManagedBean 时遇到问题。

这是错误:

SEVERE: Error Rendering View[/cadastroDeProdutoAdminSistemas.xhtml]
 com.sun.faces.mgbean.ManagedBeanCreationException: Não é possível criar instância     para·a classe: com.catalogor3e.controller.PesquisaSistemasAdminBean.
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:193)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
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.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:731)
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:729)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:575)
at javax.faces.component.UIData.getRowCount(UIData.java:356)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:579)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:220)
at   org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:192)
at   org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:74)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
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:55)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
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:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at   com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
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:305)
    Hibernate: select estado0_.id as id3_, estado0_.nome_estado as nome2_3_ from estado    estado0_
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
       Caused by: java.lang.NullPointerException
at com.catalogor3e.controller.PesquisaSistemasAdminBean.<init>(PesquisaSistemasAdminBean.java:51)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
... 58 more

这是我的 ManagedBean:

@ManagedBean(name="pesquisaSistemasAdminBean")
@SessionScoped
public class PesquisaSistemasAdminBean{

@ManagedProperty(value = "#{filtroEtiquetaCidadeSistemaBean}")    
private FiltroEtiquetaCidadeSistemaBean filtroEtiquetaCidadeSistemaBean;

@ManagedProperty("#{facadeService}")
private FacadeService service;

private DataModel<Sistema> listaSistemas ;

//variáveis para filtro
private int idCategoriaParaFiltro = -1;
private List<String> idsDeComponentesParaFiltro = new ArrayList<String>();
private int idFabricanteParaFiltro = -1;


public PesquisaSistemasAdminBean() {
    this.listaSistemas = new ListDataModel<Sistema>  (this.service.getServiceSistemas().filtrarSistemaConstrutivo(null, null, null, null, null));
}


//retorna todas as categorias(tipos) dos sistemas existentes no banco
public List<CategoriaSistema> getListaDeCategorias(){
    List<CategoriaSistema> listaDeCategorias = this.service.getServiceCategoriaDeSistemas().getTodasAsCategoriasDeSistemas();
    return listaDeCategorias;
}

public void filtrarSistemaConstrutivo(){
     CategoriaSistema categoriaDeSistema = null;
     Fabricante fabricante = null;
     ZonaBioclimatica zona = null;
     Etiqueta etiqueta = null;
     List<CategoriaCamada> listaDeCategoriasDeComponentes = null;
     if(this.idCategoriaParaFiltro != -1){
         categoriaDeSistema =  this.service.getServiceCategoriaDeSistemas().getCategoriaPeloID(idCategoriaParaFiltro);
     }
     if(this.idFabricanteParaFiltro != -1){
         fabricante = this.service.getServiceFabricante().getFabricantePeloID(idCategoriaParaFiltro);
     }
     if(this.filtroEtiquetaCidadeSistemaBean.getZonaBioclimaticaParaFiltro() != null){
         zona = this.filtroEtiquetaCidadeSistemaBean.getZonaBioclimaticaParaFiltro();
     }
     if(this.filtroEtiquetaCidadeSistemaBean.getIdEtiqueta() != -1){
         etiqueta = this.service.getServiceCidadeEstado().getEtiquetaPeloID(this.filtroEtiquetaCidadeSistemaBean.getIdEtiqueta());
     }

     if(!this.idsDeComponentesParaFiltro.isEmpty()){
         listaDeCategoriasDeComponentes = new ArrayList<CategoriaCamada>();
         for(int i = 0; i < idsDeComponentesParaFiltro.size(); i++){
             CategoriaCamada categoriaCamada = this.service.getServiceCategoriaDeComponentesConstrutivos().getCategoriaComponenteConstrutivoPeloId(Integer.parseInt(idsDeComponentesParaFiltro.get(i)));
             listaDeCategoriasDeComponentes.add(categoriaCamada);
         }
     }
     this.listaSistemas = new ListDataModel<Sistema>  (this.service.getServiceSistemas().filtrarSistemaConstrutivo(categoriaDeSistema, listaDeCategoriasDeComponentes, fabricante, zona, etiqueta));
}

//retorna todos os fabricantes existentes no banco
 public List<Fabricante> getListaFabricantes(){
    List<Fabricante> listaDeFabricantes = this.service.getServiceFabricante().listaDeTodosOsFabricantes();
    return listaDeFabricantes;
}

 ///gets e sets está implementado, mas economizei código aqui!!!

这是我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>catalogo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>catalogo</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.6</version>
</dependency>

  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-impl</artifactId>
   <version>2.1.10</version>
  </dependency> 

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>

<dependency>
  <groupId>javax.persistence</groupId>
  <artifactId>persistence-api</artifactId>
   <version>1.0</version>
 </dependency>

 <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-core</artifactId>
   <version>3.1.2.RELEASE</version>
 </dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-expression</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context-support</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
   <artifactId>spring-orm</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>



<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.2.6.ga</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.3.1.GA</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.3.2.GA</version>
            <type>jar</type>
        </dependency>

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.15</version>
</dependency>


<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
   <version>1.6.1</version>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.6.1</version>
</dependency>

<dependency> 
  <groupId>commons-collections</groupId>
  <artifactId>commons-collections</artifactId>
  <version>3.1</version> 
</dependency> 

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.10</version>
  <scope>test</scope>
</dependency>


<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>ejb3-persistence</artifactId>
   <version>1.0.1.GA</version>
</dependency>

<dependency>
  <groupId>javax.sql</groupId>
  <artifactId>jdbc-stdext</artifactId>
  <version>2.0</version>
</dependency>

<dependency>
  <groupId>javax.transaction</groupId>
  <artifactId>jta</artifactId>
  <version>1.0.1B</version>
</dependency>

<dependency>
  <groupId>org.primefaces</groupId>  
  <artifactId>primefaces</artifactId>
  <version>3.4.1</version>
</dependency>

<dependency>
  <groupId>org.primefaces.themes</groupId>
  <artifactId>all-themes</artifactId>
  <version>1.0.9</version>
</dependency>

<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>   
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.7</version>
</dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <type>jar</type>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<repositories>


  <repository>
        <url>http://download.java.net/maven/2/</url>
        <id>jsf20</id>
        <layout>default</layout>
        <name>Repository for library Library[jsf20]</name>
    </repository>
    <repository>
        <url>http://repo1.maven.org/maven2/</url>
        <id>jstl11</id>
        <layout>default</layout>
        <name>Repository for library Library[jstl11]</name>
    </repository>
    <repository>  
        <id>prime-repo</id>  
        <name>PrimeFaces Maven Repository</name>  
        <url>http://repository.primefaces.org</url>  
        <layout>default</layout>  
    </repository> 


        <repository>
            <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>apache.snapshots</id>
        <name>Apache Snapshot Repository</name>
        <url>https://repository.apache.org/content/repositories/snapshots</url>
    </repository>
</repositories>

这是我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
     xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">


<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>


<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

<welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bootstrap</param-value>
</context-param>

   <filter-mapping> 
   <filter-name>PrimeFaces FileUpload Filter</filter-name>  
   <servlet-name>Faces Servlet</servlet-name> 
   </filter-mapping>
   <filter> 
   <filter-name>PrimeFaces FileUpload Filter</filter-name>      
   <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> 
   </filter>    



  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
 <listener>
  <listener-class>
     org.springframework.web.context.request.RequestContextListener
  </listener-class>
 </listener>
 <listener>
  <listener-class>
     org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>

</web-app>

这是我的 applicationContext.xml

  <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  <!-- Seta anotaçoes para serem  <context:annotation-config />usadas pelo Spring -->
  <context:annotation-config />


  <!-- Define o pacote onde o Spring vai procurar por beans anotados --> 
  <context:component-scan base-package="com.catalogor3e.dao, com.catalogor3e.service"  />

  <!-- define que as transaçoes irao ser anotadas -->
  <tx:annotation-driven />



 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/bancodedados"/>
    <property name="username" value="root"/>
    <property name="password" value="852456"/>
  </bean>

< bean id="entityManagerFactory"  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="catalogoPU" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
                <property name="showSql" value="true" /> 
            </bean>
        </property>
</bean>

<!-- Configuracao do gerente de transacoes do Spring -->
<bean id="transactionManager"   class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

</beans>

拜托,有人可以帮我解决这个问题吗?

阿特,

迭戈·萨比诺

4

1 回答 1

0

这是您的异常的根本原因,它是最底层的部分。这是最相关的:

Caused by: java.lang.NullPointerException
    at com.catalogor3e.controller.PesquisaSistemasAdminBean.<init>(PesquisaSistemasAdminBean.java:51)

因此,null当代码尝试访问/调用它时,bean 的构造函数中有一些东西。让我们看一下构造函数:

public PesquisaSistemasAdminBean() {
    this.listaSistemas = new ListDataModel<Sistema>  (this.service.getServiceSistemas().filtrarSistemaConstrutivo(null, null, null, null, null));
}

嘿,您正在尝试访问service声明为托管属性的内容。您似乎期望托管属性注入的工作方式如下:

PesquisaSistemasAdminBean pesquisaSistemasAdminBean; // Declare bean.
pesquisaSistemasAdminBean.setService(facadeService); // Set service.
pesquisaSistemasAdminBean = new PesquisaSistemasAdminBean(); // Invoke constructor.

但这是不可能的。在构造实例之前,从技术上讲根本不可能将服务设置为实例变量。实际上,以下是真正发生的事情:

PesquisaSistemasAdminBean pesquisaSistemasAdminBean; // Declare bean.
pesquisaSistemasAdminBean = new PesquisaSistemasAdminBean(); // Invoke constructor.
pesquisaSistemasAdminBean.setService(facadeService); // Set service.

这就解释了为什么服务仍在null构造函数中。如果您打算在 bean 构建后直接基于注入的依赖项执行一些业务逻辑,那么您应该使用带@PostConstruct注释的方法。

所以,你需要替换构造函数

public PesquisaSistemasAdminBean() {
    this.listaSistemas = new ListDataModel<Sistema>  (this.service.getServiceSistemas().filtrarSistemaConstrutivo(null, null, null, null, null));
}

用一种@PostConstruct方法

@PostConstruct
public void init() {
    this.listaSistemas = new ListDataModel<Sistema>  (this.service.getServiceSistemas().filtrarSistemaConstrutivo(null, null, null, null, null));
}

顺便说一句,方法名称完全由您选择。

于 2013-04-18T11:28:28.340 回答