我有点困惑。我尝试做一个简单的例子,我们可以从xhtml页面上传文件,并在上传文件时显示something.jpg。 而我这样做:JSF h:inputFiIe和f:ajax
<h:outputScript library="javascript" name="showProgres.js" />
<h:outputScript library="javascript" name="prototype-1.6.0.2.js"/>
<h:form id="form" prependId="false" enctype="multipart/form-data">
<h:panelGrid columns="2">
<h:inputFile id="upload1" value="#{demoBean.file1}">
<f:ajax onevent="com.corejsf.showProgres" render="@form" />
</h:inputFile>
<h:graphicImage id="pole" library="images" name="orange-barber-pole.gif"
style="display: none"/>
<h:commandButton action="#{demoBean.upload()}" value="upload"></h:commandButton>
</h:panelGrid>
</h:form>
而且在资源directorium我有showprogres.js
文件。随着showProgres
功能是这样的:
if(!com) var com = {};
if(!com.corejsf) {
com.corejsf = {
showProgres: function(data){
var inputId = data.source.id;
var progresBarid = inputId.substring(0,
inputId.length - "upload2".length) + "pole";
if(data.status == begin)
Element.show(progresBarid);
else if (data.status == success)
Element.hide(progresBarid);
}
}
};
当我开始在GlassFish结果样本是我始料未及的。像这样的东西(在整个xhtml页面没有错误):
这个XML文件似乎没有任何样式信息与它关联。文档树如下所示。
<partial-response id="j_id1">
<changes>
<update id="j_id1:javax.faces.ViewState:0">
<![CDATA[ -3528225672520671936:9111168294196781686 ]]>
</update>
</changes>
</partial-response>
有没有人知道会发生什么?我没有任何错误。没有Ajax的每一个都很好(上传作品)。
我很困惑:你会对''知道你的事件吗? “onevent”的参数应该是由''组件实际触发的事件名称。也许你打算把它附加到'commandButton'上? –
mabi
好吧,当我把它放在那里,我有同样的结果!你的意思是说我有渲染问题吗?也许没有正确的定义组件Id特别是如果我把coaxButton组件中的Ajax? – vmaric