本文介绍了如何在ICEfaces中覆盖默认文件上传h:message的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ace:fileEntry组件上传文件成功上传后,我收到以下消息:
i am using the ace:fileEntry component to upload filesand after successful upload i get the message that:
'File Entry' uploaded successfully 'filename'.
我想覆盖此消息并显示其他消息(某种摘要,用于分析上载的文件),有什么想法吗?
and i want to override this message and display other message (some kind of a summary for parsing that uploaded file), any ideas how ?
这是我的代码:
<h:form>
<ace:fileEntry id="fileEntryComp"
label="File Entry"
relativePath="uploaded"
fileEntryListener="#{mybean.uploadFile}"/>
<h:commandButton value="Upload Excel File" />
<h:message for="fileEntryComp" />
</h:form>
推荐答案
您必须创建自己的消息并发送.它将覆盖默认消息.这是一种奇怪的行为,但可以正常工作.
You have to create your own message and send it. It will overwrite the default message. Its a strange behavior but it will work.
public void uploadFile(FileEntryEvent e) {
FileEntry fe = (FileEntry)e.getComponent();
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage msg = new FacesMessage();
msg.setServity(FacesMessage.SERVITY_INFO);
msg.setSummary("mysummary");
msg.setDetail("mydetail");
ctx.addMessage(fe.getClientId(),msg);
}
您可以查看展示柜: http: //comp-suite.icefaces.org/comp-suite/showcase.jsf?grp=aceMenu&exp=fileEntry
这篇关于如何在ICEfaces中覆盖默认文件上传h:message的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!