我想在我的网站中显示处理旋转器。我在命令按钮
上使用以下简单的onclick事件<h:commandButton class="uploadButton" onclick="monitor();" value="Upload" update="msgsuccess" action="#{appUploadBean.uploadApp()}"/>
<p:outputPanel id="parentPanel" style="display:none">
<div id="uploadPForm:msgupload" class="ui-messages ui-widget" aria-live="polite" data-summary="data-summary" data-severity="info">
<div class="ui-messages-info ui-corner-all">
<a href="#" class="ui-messages-close" onclick="$(this).parent().slideUp();return false;">
<span class="ui-icon ui-icon-close" />
</a>
<h:graphicImage id="image" library="assets" name="images/ajax-loader.gif"></h:graphicImage>
<ul>
<li>
<span class="ui-messages-info-summary">Uploading Apk</span>
</li>
</ul>
</div>
</div>
</p:outputPanel>
--javascript
function monitor(){
console.log("monitor called");
var loading = document.getElementById("uploadPForm:parentPanel");
loading.style.display = "block";
return false;
}
现在的问题是spinner开始显示,只要我点击命令按钮。我想只在验证阶段成功后才显示旋转器,即在阶段3之后。
有办法做到这一点吗?
在支持bean AppUploadBean中,您将拥有属性:
Bean必须是viewscope(首选)或sessionscope
private boolean rendered;
public String uploadApp(){
...
rendered = true;
return "actualpage.xhtml?faces-redirect=true";
}
public boolean isRendered(){
return rendered
}
在xhtml: <h:form>
...
<p:commandButton class="uploadButton" value="Upload" update="msgsuccess" ajax="false" action="#{appUploadBean.uploadApp}"/>
<p:outputPanel id="parentPanel" rendered="#{appUploadBean.rendered}">
...
</p:outputPanel>
...
</h:form>