在我的应用程序中,我想在扩展行之前执行客户端方法,<p:dataTable>
所以我正在使用onExpandStart="alert('Helo');"
. 但这也不适合我。
.xhtml 代码片段:
<p:dataTable value="#{ExampleDataModel}" lazy="true" paginator="true" onExpandStart="alert('Helo');">
<p:column id="rowToggle" styleClass="rowtoggle">
<p:rowToggler />
</p:column>
<p:rowExpansion>
..........
</p:rowExpansion>
</p:dataTable>
谁能告诉我哪里做错了?我正在使用 PF 3.4,Mojara(2)。谢谢。
Update-1: managedBean 的代码片段:
@ManagedBean(name = "columnController")
@ViewScoped
public class ColumnController implements Serializable {
private List<ColumnDTO> userNames;
public List<ColumnDTO> getUserNames() {
List<ColumnDTO> columns = new ArrayList<ColumnDTO>();
columns.add(new ColumnDTO(Integer.valueOf(1), "Diganta"));
columns.add(new ColumnDTO(Integer.valueOf(2), "Jayanta"));
columns.add(new ColumnDTO(Integer.valueOf(3), "Proloy"));
return columns;
}
public void setUserNames(List<ColumnDTO> userNames) {
this.userNames = userNames;
}
}
列DTO.java:
public class ColumnDTO implements Serializable {
private static final long serialVersionUID = 4828438441215128064L;
private Integer columnId;
private String columnName;
public ColumnDTO(Integer index, String columnName) {
this.columnId = index;
this.columnName = columnName;
}
//...........getter setter
}
.xhtml 代码:
<h:head></h:head>
<body>
<h:form>
<p:dataTable value="#{columnController.userNames}" var="name" onExpandStart="alert('Hello')">
<p:column>
<p:rowToggler/>
</p:column>
<p:column>
<h:outputText value="#{name.columnName}" />
</p:column>
<p:rowExpansion>
<h:outputText value="#{name.columnId}" />
</p:rowExpansion>
</p:dataTable>
</h:form>
</body>
</html>