我有一个带有自定义确定按钮的取消弹出窗口进行确认,我想在执行过程中更新其进度信息。
弹出窗口如下
<af:popup id="confirmationPopupSend" binding="#{pageFlowScope.bean.confirmationPopup}" contentDelivery="immediate">
<af:dialog id="confirmationDialogSend" modal="true" title="Confirmation" type="cancel">
<f:facet name="buttonBar">
<af:commandButton id="confirmDialogButtonSend" text="OK" action="#{pageFlowScope.bean.submitAction}"/>
</f:facet>
<af:outputText value="Are you sure? This might take a while."/>
<af:outputText visible="#{pageFlowScope.bean.someProgress> 0}"
value="#{pageFlowScope.bean.someProgress}" />
</af:dialog>
</af:popup>
我的提交操作方法如下
public String submitAction()
{
for(some for condition){
//update the variable someProgress
refreshLoadingPopup();
}
}
和刷新方法
public String refreshLoadingPopup(){
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot root = context.getViewRoot();
UIComponent c = findComponent(root, "confirmationDialogSend")
AdfFacesContext.getCurrentInstance().addPartialTarget(c);
}
这里的问题是刷新方法通常有效。我通过在弹出窗口上放置一个测试按钮来检查它,它会更新信息,但是当我将刷新方法放入 submitAction 方法时,随着执行的继续,弹出窗口上没有任何反应。提交操作结束执行后,弹出窗口仍会关闭。
我只想向用户显示进度。任何其他方法也是受欢迎的。
谢谢
不能仅通过调用 refreshLoadingPopup
方法来更新弹出窗口。以下行仅标记要刷新的组件c
。
AdfFacesContext.getCurrentInstance().addPartialTarget(c);
在处理请求时(submitAction
方法中的循环正在执行),客户端将不会有响应,并且不会刷新组件c
。
您应该继续更新 for 循环中的 pageFlowScope.bean.someProgress
属性,并使客户端轮询该值,即每 0.5 秒轮询一次。
您可以使用 af:poll 组件来满足此要求。下面是一个示例,显示了如何使用 af:poll 组件: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/42-progressbarcolor-169184.pdf
您可以创建一个框架,例如 JFrame,然后在f.setVisible(false);
时创建另一个窗口,然后创建另一个 JFrame 或窗口
这是我第一次尝试帮助别人,希望这对你有帮助:D
如果你想要代码,请使用这个
static JFrame f = new JFrame();
static JFrame f2 = new JFrame();
public static void createDisplay() {
f.setVisible(true);
// DO INFORMATION SETTING CRAP HERE
}
然后创建另一个方法
public static void changeDisplay(){
f.setVisible(false);
f2.setVisible(true);
}