我有一个取消弹出窗口,其中包含用于确认的自定义确定按钮,并且我希望在执行过程中更新其上的进度信息。
弹出如下
<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>
我的submitAction方法如下
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);
}
这里的问题是刷新方法通常有效。我通过在弹出窗口上放置一个测试按钮来检查它并更新信息,但是当我将refresh方法放在submitAction方法中时,弹出窗口没有任何反应,因为执行继续。一旦submitAction结束执行,弹出窗口就会关闭。
我只想向用户展示进度。 任何其他方法也是受欢迎的。
感谢
答案 0 :(得分:1)
您无法通过调用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
答案 1 :(得分:-1)
您可以创建一个框架,例如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);
}