我有数据表格。我想通过按编辑链接进入rowedit模式时禁用命令链接:
JSF:
<p:growl id="messages" showDetail="true" />
<p:dataTable value="#{employeeBean.employees}"
var="employee" id="employeeDTable"
editable="true">
<p:ajax event="rowEdit" listener="#{employeeBean.edit}" update=":employeeForm:messages" />
<p:ajax event="rowEditCancel" listener="#{employeeBean.undoEdit}" update=":employeeForm:messages" />
<p:column id="id" headerText="Id">
<h:outputText value="#{employee.id}"/>
</p:column>
<p:column id="firstname" headerText="Voornaam">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{employee.firstName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{employee.firstName}" label="firstname"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column id="editButtonsId" headerText="">
<p:rowEditor />
</p:column>
<p:column id="cashbook" headerText="">
<div align="center">
<h:panelGroup id="cashbookPanel">
<p:commandLink title="Cashbook" update="employeeDTable" styleClass="ui-icon ui-icon-cart" /> <!-- DISABLE THIS IN EDITMODE -->
</h:panelGroup>
</div>
</p:column>
</p:dataTable>
CODE:
@Component("employeeBean")
@Scope("session")
public class EmployeeBean {
List<EmployeeModel> employees;
private EmployeeModel employeeModel;
@Autowired
private EmployeeService employeeService;
public EmployeeBean() {
if(employeeService == null){
employeeService = ServiceRepository.getInstance().getEmployeeService();
}
employeeModel = new EmployeeModel();
if(employees == null){
this.employees = this.employeeService.getEmployees();
}
}
public void edit(RowEditEvent event) {
EmployeeModel employee = ((EmployeeModel) event.getObject());
EmployeeModel updatedEmployee = this.employeeService.updateEmployee(employee);
if(updatedEmployee != null){
FacesMessage msg = new FacesMessage("Employee Edited", employee.getFirstName());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
public void undoEdit(RowEditEvent event) {
}
public EmployeeModel getEmployeeModel() {
return employeeModel;
}
public void setEmployeeModel(EmployeeModel employeeModel) {
this.employeeModel = employeeModel;
}
public List<EmployeeModel> getEmployees() {
return employees;
}
public void setEmployees(List<EmployeeModel> employees) {
this.employees = employees;
}
}
答案 0 :(得分:0)
将您的链接和已停用的链接放在<p:cellEditor/>
<p:column id="cashbook" headerText="">
<p:cellEditor>
<f:facet name="output">
<div align="center">
<h:panelGroup id="cashbookPanel">
<p:commandLink title="Cashbook" update="employeeDTable" styleClass="ui-icon ui-icon-cart" />
</h:panelGroup>
</div>
</f:facet>
<f:facet name="input">
<div align="center">
<h:panelGroup id="cashbookPanel">
<p:commandLink disabled="true" title="Cashbook" update="employeeDTable" styleClass="ui-icon ui-icon-cart" />
</h:panelGroup>
</div>
</f:facet>
</p:cellEditor>
</p:column>