嗨,我dataTable
使用 Primefaces 创建了一个,并创建了指向dataTable
. 现在它应该在下一页移动并在我单击名称链接后在下一页显示其选定的行内容,但我收到以下错误:
javax.el.PropertyNotFoundException: /view.xhtml at line 50 and column 81 target="#{OrderBean.selectedOrder}": Target Unreachable, identifier 'OrderBean' resolved to null
at org.apache.myfaces.view.facelets.el.TagValueExpression.setValue(TagValueExpression.java:121) at org.apache.myfaces.view.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:110) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:344)
at javax.faces.component.UICommand.broadcast(UICommand.java:103)
at javax.faces.component.UIData.broadcast(UIData.java:761)
at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
when i click on the link. Can anyone plz help me resolve this error out.check whether i made any mistake in the setpropertyaction Listener ???
if so plz post the correct code. I am waiting the answers please help me to clear the error using jas 2.0 and primefaces.
视图.xhtml
<p:dataTable id="dataTable" var="v" value="#{order.orderList}" paginator="true" rows="3" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowKey="#{order.year}" rowsPerPageTemplate="6,9">
<f:facet name="header">
Data Table
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<p:commandLink value="#{v.name}" action="/nextpage.xhtml?faces-redirect=true" rowSelectListener="#{orderBean.onRowSelectNavigate}" >
<f:setPropertyActionListener value="#{v}" target="#{orderBean.selectedOrder}"/>
</p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Year" />
</f:facet>
<h:outputText value="#{v.year}" />
</p:column>
----------</p:datatable>
OrderBean.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.SelectEvent;
@ManagedBean(name="order")
@SessionScoped
@ViewScoped
public class OrderBean implements Serializable{
private static final long serialVersionUID = 1L;
String name;
int year;
String company;
String number;
private Order selectedOrder;
public Order getSelectedOrder() {
return selectedOrder;
}
public void setSelectedOrder(Order selectedOrder) {
this.selectedOrder = selectedOrder;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
private static final ArrayList<Order> orderList =
new ArrayList<Order>(Arrays.asList(
new Order("vidhya",2020,"IT","1"),
new Order("madhu",1021,"BT", "2"),
new Order("manu",3846,"Mech","3"),
new Order("shruthi",5647,"Benz","4")
));
public ArrayList<Order> getOrderList() {
return orderList;
}
public String addAction() {
Order order = new Order(this.name, this.year,
this.company, this.number);
orderList.add(order);
return null;
}
public static class Order{
String name;
int year;
String company;
String number;
public Order(String name, int year,
String company, String number) {
this.name = name;
this.year = year;
this.company = company;
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String moveToNextPage(){
return "nextpage";
}
public String onRowSelectNavigate(SelectEvent event) {
FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedOrder", event.getObject());
return "nextpage?faces-redirect=true";
}
下一页.xhtml
<h:panelGrid id="display" columns="2" cellpadding="4" >
<f:facet name="header">
details
</f:facet>
<h:outputText value="Name:" />
<h:outputText value="#{orderBean.selectedOrder.name}" />
<h:outputText value="Year:" />
<h:outputText value="#{orderBean.selectedOrder.year}" />
<h:outputText value="Company:" />
<h:outputText value="#{orderBean.selectedOrder.company}" />
<h:outputText value="Number:" />
<h:outputText value="#{orderBean.selectedOrder.number}" />
</h:panelGrid>