primefaces - p:datagrid 不会从视图中加载数据
问题描述
我正在使用 JAVA 10、WildFly 14、Primefaces 6.2
我正在做一个礼品店,这是 xhtml 文件中网格的代码:
<p:dataGrid var="car" value="#{giftList.lgif}" columns="3" layout="grid"
rows="12" paginator="true" id="gifts"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="6,12,16">
<f:facet name="header">
REGALOS
</f:facet>
<p:panel header="#{giftList.number}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage name="car.gif"/>
<h:outputText id="out" value="#{giftList.text}" />
<h:outputText value="#{giftList.number}" />
<p:commandLink update=":form:carDetail" oncomplete="PF('carDialog').show()" title="View Detail">
<h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
<f:setPropertyActionListener value="#{gifts}" target="#{giftList.lgif}" />
</p:commandLink>
</h:panelGrid>
</p:panel>
</p:dataGrid>
我希望网格显示礼物列表,我有两个类,一个是带有名称和价格的命名礼物,另一个是构建所有礼物的命名礼物列表:
礼物:
package org.primefaces.showcase.view.ajax;
public class gifts {
public String name;
public int price;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}}
礼品清单:
package org.primefaces.showcase.view.ajax;
import java.util.List;
import javax.annotation.PostConstruct;
import org.primefaces.showcase.view.ajax.gifts;
public class giftList {
private List<gifts> lgif;
private int numero =1;
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
gifts gf = new gifts();
@PostConstruct
public void init() {
gf.setName("OSITO");
gf.setPrice(40);
lgif.add(gf);
}
public int getGifts() {
return lgif.size();
}
public gifts getcurrentgift() {
return lgif.get(0);
} }
首先,我希望数据网格中的 value="" 等于 #{giftList.lgif} 包含礼物的对象,由于某种原因它不会采用我输入的值,它只会在值为“1”时显示一些东西“或者更多,我做错了什么?
解决方案
推荐阅读
- reactjs - React Router DOM - 重定向组件无法正确呈现路由
- android - Android Kotlin:调试期间局部变量不可用
- java - 用mysql数据库创建jar文件
- cordova - 我可以使用完整的用户代理字符串吗?
- python-3.x - 用 opc ua Python 写一个值
- java - Spring bean 防止实例化并使用预期的实现
- python - 无法在 pandas 的列中找到特定值,但我可以在 R 中找到它
- php - UTF-8 转换问题
- php - Laravel 7.0 中不允许序列化“闭包”
- sql - oracle 使用时间戳列跟踪表上的历史记录