前端页面
<p:dataTable id="patchfiledatatable" var="patch" value="#{patchBean.files}" dynamic="true" emptyMessage="" paginator="true" rows="10" paginatorPosition="top">
<p:column >
<f:facet name="header">
<h:outputText value="删除" />
</f:facet>
<p:growl id="deleMeaage-dialog" showSummary="true" howDetail="true"/>
<p:commandLink id="delLink" action="#{patchBean.deletePatch}" update=":patchForm">
<f:setPropertyActionListener value="#{patch.path}" target="#{patchBean.delFilePath}" />
<h:outputText value="删除" />
</p:commandLink>
</p:column>
</p:dataTable>
后台代码
@ManagedBean(name = "patchBean")
@SessionScoped
public class TreeBean{
private List<PatchOutFile> files;
private String delFilePath;
public List<PatchOutFile> getFiles() {
return files;
}
public void setFiles(List<PatchOutFile> files) {
this.files = files;
}
public String getDelFilePath() {
return delFilePath;
}
public void setDelFilePath(String delFilePath) {
this.delFilePath = delFilePath;
}
//取得files内容(省略)
//删除不定文件
public void deletePatch(){
File delFile = new File(delFilePath);
FacesMessage msg = null;
try {
if(delFile.exists()){
boolean flag = delFile.delete();
System.out.println(flag);
if(flag){
files.clear();
this.getSubFiles(delFile.getParent());
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "删除成功", null);
}
}else{
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "该文件不存在", null);
}
FacesContext.getCurrentInstance().addMessage("patchForm:deleMeaage-dialog", msg);
} catch (Exception e) {
System.out.println("删除出现异常");
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "操作失败", null);
FacesContext.getCurrentInstance().addMessage("patchForm:deleMeaage-dialog", msg);
e.printStackTrace();
}
}
}
分享到:
相关推荐
primefaces 一个机遇JSF2 的免费框架 界面比较友好 是个人开发和小型网站开发的首选
什么是PrimeFaces? PrimeFaces是一套开源的JSF组件套装,共有100多个支持AJAX的JSF组件。另外一个TouchFaces模块提供了用于移动web应用开发的UI工具。PrimeFaces的主要目标是为JSF创建终级组件集。 Prime技术 ...
primefaces-5.0.jar
《primefaces cookbook》示例代码
primefaces-3.5.jar开发包
PrimeFaces是一个用于提高JSF Web应用程序开发效率的开源类库。 UI Components:PrimeFaces UI模块提供了拥有Rich Web用户体 验的各种JSF组件。PrimeFaces使用Yahoo UI库做为默认的客户端框架。PrimeFaces提供的...
primefaces 用于JSF开发,轻松实现许多组建功能
primefaces-5.2.jar
适合primefaces开发需要主题包,是在primefaces 网站的下载的,需要请下载,给1 分就行啊。
PrimeFaces是一个用于提高JSF Web应用程序开发效率的开源类库。 PrimeFaces Cookbook是关于PrimeFaces的第一本书籍。
需要用最新primefaces的可以下载
PrimeFaces是一个用于提高JSF Web应用程序开发效率的开源类库,具有丰富的UI界面组件,同时提供大量手机网页UI组件,程序包为开发网页的demo,可以使用tomcat8启,使你可以在demo的提示下使用UI组件轻松开发你的程序
Primefaces 框架包 是
PrimeFaces Blueprints.pdf高清带书签
primefaces guide 指南 jsf 快速入门
SpringBoot整合PrimeFaces demo案例
最近一直研究jsf2,相信这个对大家很有帮助,primefaces3.5的参考文档
PrimeFaces 是一款强大的jsf框架 csdn上没找到 在国外网站上找到了 过来分享下 PrimeFaces is a lightweight open source component suite for Java Server Faces JSF a Java based web application framework Java ...
primefaces showcase demo 完整代码 稍修改即可改成eclipse3.7下jboss as 7 运行
在tomcat 下运行,primefaces 3.0 showcase source 源代码