我正在将一个旧的JSF应用程序迁移到新版本。我对Primefaces的lazyDataModel有问题
@Configurable
public class PerfilSeleccionLazyDataModel extends LazyDataModel<Perfil> {
@Autowired
private transient PerfilService perfilService;现在,这些类不注入服务,并且为空
我的新项目是Spring Boot,JoinFaces 4和Spring5。
谁能告诉我我应该使用什么新策略,或者我是否应该添加一些额外的确认,以便我的服务被很好地注入?
发布于 2020-10-26 22:02:36
我使用的是JoinFaces,下面是我的LazyDatatable的样子。在bean上使用JSF,并使用normal ViewScoped注入您想要的bean。
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
@Named
@ViewScoped
public class PerfilDatatable extends LazyDataModel<Perfil> {
@Inject
private transient PerfilService perfilService;JoinFaces配置:
joinfaces:
jsf:
project-stage: Development
state-saving-method: server
facelets-refresh-period: -1
facelets-skip-comments: true
interpret-empty-string-submitted-values-as-null: true
datetimeconverter-default-timezone-is-system-timezone: true
primefaces:
theme: babylon-bluegrey-accent
font-awesome: true
transform-metadata: true
move-scripts-to-bottom: true
submit: partial
omnifaces:
combined-resource-handler-cache-ttl: 3628800
combined-resource-handler-disabled: true
myfaces:
support-managed-beans: false
early-flush-enabled: true
check-id-production-mode: false发布于 2021-11-04 11:24:51
我在使用Spring-Boot-2.5.4和JoinFaces_4.5.4时遇到了类似的问题。我的解决方案是从外部传递依赖项。
public class LazyProductsDataModel extends LazyDataModel<Product> {
private static final long serialVersionUID = 1L;
private transient ProductRepository productRepository;
public LazyProductsDataModel(ProductRepository productRepository) {
this.productRepository = productRepository;
}
} 然后在中可以像这样初始化它:
@Named
@ViewScoped
public class ProductListView {
@Autowired
private ProductRepository productRepository;
private LazyProductsDataModel lazyProductsDataModel;
@PostConstruct
private void init() {
lazyProductsDataModel = new LazyProductsDataModel(productRepository);
}
}https://stackoverflow.com/questions/64534203
复制相似问题