如何将选定的列值传递给方法?
How to pass selected column values to a method?
我需要你的帮助,将 <p:dataTable>
中选定行列的值传递给一个方法。现在在我的代码中,我得到了不正确的值,其中一些是空的,所以你能帮忙吗。
我的数据表代码是:
<p:dataTable id="PendingRequests" var="hr" value="#{hrd.pendingRequests}">
<p:column headerText="Request Date">
<h:outputText value="#{hr.requestDate}"/>
</p:column>
<p:column headerText="Request No.">
<h:outputText value="#{hr.reqNo}"/>
</p:column>
<p:column headerText="Employee Code">
<h:outputText value="#{hr.employeeCode}"/>
</p:column>
<p:column>
<f:facet name="header">View</f:facet>
<p:lightBox style="align:center;" iframe="true" width="1200px" height="600px">
<h:outputLink value="#{hr.link}">
<p:commandButton icon="ui-icon-search" actionListener="#{hrd.HRCESS}">
<f:setPropertyActionListener target="#{hrd.employeeCode}" value="#{hr.employeeCode}"/>
<f:setPropertyActionListener target="#{hrd.reqNo}" value="#{hr.reqNo}"/>
</p:commandButton>
</h:outputLink>
</p:lightBox>
</p:column>
</p:dataTable>
但是,如果我单击 <p:commandButton>
,我将检查 employeeCode
和 reqNo
的打印值。在 HRCESS()
方法中,我会发现 employeeCode
和 reqNo
。错了。
这是我在 bean 中的代码:
@PostConstruct
public void init() {
listPendingRequests = new ArrayList<PendingRequests>();
try {
//SQL Statement
while (result.next()) {
PendingRequests pendingList = new PendingRequests();
requestDate = result.getString("ECW_REQ_DT");
reqNo = result.getString("ECW_REQ_SEQ_NO");
employeeCode = result.getString("ECW_EMP_CD");
pendingList.setRequestDate(requestDate);
pendingList.setReqNo(reqNo);
pendingList.setEmployeeCode(employeeCode);
listPendingRequests.add(pendingList);
}
} catch (Exception e) {
System.err.print(e);
e.printStackTrace();
}
}
在 JSF 2.2 中,您可以将值作为方法参数传递。
public void HRCESS(String employeeCode, String reqNo)
我需要你的帮助,将 <p:dataTable>
中选定行列的值传递给一个方法。现在在我的代码中,我得到了不正确的值,其中一些是空的,所以你能帮忙吗。
我的数据表代码是:
<p:dataTable id="PendingRequests" var="hr" value="#{hrd.pendingRequests}">
<p:column headerText="Request Date">
<h:outputText value="#{hr.requestDate}"/>
</p:column>
<p:column headerText="Request No.">
<h:outputText value="#{hr.reqNo}"/>
</p:column>
<p:column headerText="Employee Code">
<h:outputText value="#{hr.employeeCode}"/>
</p:column>
<p:column>
<f:facet name="header">View</f:facet>
<p:lightBox style="align:center;" iframe="true" width="1200px" height="600px">
<h:outputLink value="#{hr.link}">
<p:commandButton icon="ui-icon-search" actionListener="#{hrd.HRCESS}">
<f:setPropertyActionListener target="#{hrd.employeeCode}" value="#{hr.employeeCode}"/>
<f:setPropertyActionListener target="#{hrd.reqNo}" value="#{hr.reqNo}"/>
</p:commandButton>
</h:outputLink>
</p:lightBox>
</p:column>
</p:dataTable>
但是,如果我单击 <p:commandButton>
,我将检查 employeeCode
和 reqNo
的打印值。在 HRCESS()
方法中,我会发现 employeeCode
和 reqNo
。错了。
这是我在 bean 中的代码:
@PostConstruct
public void init() {
listPendingRequests = new ArrayList<PendingRequests>();
try {
//SQL Statement
while (result.next()) {
PendingRequests pendingList = new PendingRequests();
requestDate = result.getString("ECW_REQ_DT");
reqNo = result.getString("ECW_REQ_SEQ_NO");
employeeCode = result.getString("ECW_EMP_CD");
pendingList.setRequestDate(requestDate);
pendingList.setReqNo(reqNo);
pendingList.setEmployeeCode(employeeCode);
listPendingRequests.add(pendingList);
}
} catch (Exception e) {
System.err.print(e);
e.printStackTrace();
}
}
在 JSF 2.2 中,您可以将值作为方法参数传递。
public void HRCESS(String employeeCode, String reqNo)