我最近正在使用 glassfish 4。我有一个带有 primefaces 数据表组件的 jsf 页面。但是当我提交表单时,它总是显示“目标无法访问的标识符解析为空。我将范围从请求更改为已查看,然后更改为会话范围,但它们都不起作用。我已经阅读了类似的问题,但没有任何进展。这是jsf页面:
<ui:define name="content">
<h:form id="orderform">
<h:panelGroup id="orderinfor">
<p:panelGrid columns="6">
<f:facet name="header">
new order
</f:facet>
<h:outputLabel for="orderday" value="order day:" />
<p:calendar value="#{orderInfo.orderInfo_Day}" id="orderday" pattern="yyyy-mm-dd"/>
<h:outputLabel for="ordername" value="order name *" />
<p:inputText id="ordername" value="# {orderInfo.orderInfo_name}"/>
<h:outputLabel for="ordernnum" value="order number:" />
<p:inputText id="ordernnum" value="#{orderInfo.orderInfo_workId}"/>
<h:outputLabel for="ordermemo" value="memo:" />
<p:inputText id="ordermemo" value="#{orderInfo.orderInfo_Memo}"/>
</p:panelGrid>
<h:panelGroup id="orderpathpanel">
<p:dataTable id="multiDepts" var="depwork" value="#{dbOrderManager.workpaths}" paginator="false"
selection="#{orderInfo.selectedDepartments}" rowKey="#{depwork.manualwork_dept.dept_Id}">
<f:facet name="header">
path
</f:facet>
<p:column selectionMode="multiple" style="width:2%" />
<p:column headerText="department name" style="width:10%">
#{depwork.manualwork_dept.dept_name}
</p:column>
<p:column headerText="order number" style="width:2%">
<p:spinner size="2" min="1" value="#{depwork.manualwork_workOrder}" />
</p:column>
<p:column headerText="memo" style="width: 100%;">
<p:inputText style="width: 100%;" value="#{depwork.manualwork_Memo}"/>
</p:column>
</p:dataTable>
<h:commandButton id="multiViewButton" action="#{dbOrderManager.saveOrder(orderInfo)}" value="add order">
</h:commandButton>
</h:panelGroup>
</h:form>
</ui:define>
这是托管 Bean
@Named(value = "orderInfo")
@ViewScoped
public class OrderInfo implements Serializable {
private OrderPath[] selectedDepartments;
private Date orderInfo_Day;
// get and set methods...
}
OrderPath 是一个普通的对象类
public class OrderPath implements Serializable {
//..
}
错误信息是:
/testorder.xhtml @49,127 selection="#{orderInfo.selectedDepartments}": Target Unreachable, identifier 'orderInfo' resolved to null
我尝试使用 p:commandButton 和 h:commandButton,但得到了同样的错误。