ฉันกำลังพยายามเปิดใช้งานปุ่มคำสั่งหลังจากแถบความคืบหน้าเสร็จสมบูรณ์ แต่เมื่อฉันโหลดเพจ ปุ่มคำสั่งถูกเปิดใช้งานแล้ว นอกเหนือจากนี้ก็ยังทำงานได้ดี
ฉันได้ทำการวิจัยและปัญหาที่คล้ายกันแล้ว: commandButton ไม่ทำงานเมื่อปิดการใช้งาน=“true ” ในตอนแรก แต่วิธีแก้ปัญหาไม่ได้ผลสำหรับฉัน
ฉันทำอะไรผิด? มีบางอย่างที่ฉันขาดหายไปหรือไม่?
นี่คือดัชนี.xhtml
<p:growl id="growl" />
<h3>Deskarga</h3>
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:commandButton value="Start" type="button"
onclick="pbAjax.start();startButton2.disable();"
widgetVar="startButton2" />
<p:commandButton value="Cancel"
actionListener="#{progressBean.cancel}"
oncomplete="pbAjax.cancel();startButton2.enable();" />
<p:progressBar widgetVar="pbAjax" ajax="true" rendered="true"
value="#{progressBean.progress}" labelTemplate="{value}%"
styleClass="animated" interval="250">
<p:ajax event="complete" listener="#{progressBean.onComplete}"
update="messages"
oncomplete="startButton2.enable();#{progressBean.setDisabled(false)};"/>
</p:progressBar>
<p:separator id="separator2" />
<p:commandButton value="Parseatu" widgetVar="parserButton" ajax="true"
disabled="#{progressBean.disabled}" actionListener="#{progressBean.parseatu()}"
update="growl" />
</h:form>
และนี่คือ bean ที่มีการจัดการขอบเขตเซสชัน:
public class ProgressBean implements Serializable {
private boolean disabled= true;
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled= disabled;
}
}