我正在使用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”或更高,我在做什么错了?