How to make a better splash screen changing the message dinamically?
edilmar Jun 6, 2013 5:38 PMI have a test.xhtml like this:
<h:body>
<a4j:status name="statusSplash" onstart="#{rich:component('splash')}.show()" onstop="#{rich:component('splash')}.hide()" />
<h:form id="formCad">
<rich:popupPanel id="splash" modal="true" autosized="true" moveable="false" resizeable="false">
<f:facet name="header"><h:outputText value="Some title" /></f:facet>
<h:graphicImage value="/imagens/splash.gif" alt="Aguarde" />
<h:outputText value="#{t.msgSplash} ..." id="msgSplash"/>
</rich:popupPanel>
<a4j:poll id="pollSplash" enabled="#{t.pollEnabled}" interval="1000" execute="nenhum" render="pollSplash,splash,msgSplash"/>
<a4j:commandButton id="buttonSplash" value="Open Splash"
action="#{t.openSplash}" status="statusSplash"
execute="pollSplash"
/>
</h:form>
</h:body>
When the user press button, a4j:status shows the popupPanel. I would like to change dinamically the outputText (with t.msgSplash) while some "slow" process occurs in the server. Something like: "Processing step 1...", "Processing step 2...", ... "Processing step X...".
Then, I made TesteController.java like this, setting msgSplash = actual datetime, just to test the environment:
package control.testes;
import SubMacroUtils.FormatDate;
import java.io.Serializable;
import javax.inject.Named;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
@Named(value="t")
@ConversationScoped
public class TesteController implements Serializable {
private boolean pollEnabled;
private String msgSplash;
public boolean isPollEnabled() {
return pollEnabled;
}
public void setPollEnabled(boolean pollEnabled) {
this.pollEnabled = pollEnabled;
}
public String getMsgSplash() {
msgSplash = FormatDate.getDateTime();
System.out.println(msgSplash);
return msgSplash;
}
public void setMsgSplash(String msgSplash) {
this.msgSplash = msgSplash;
}
public String openSplash() {
try {
pollEnabled = true;
Thread.sleep(10000);
pollEnabled = false;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
However, popupPanel shows just the first setup of msgSplash datetime, and never more change it. The a4j:póll didn't help too.
Any ideas to solve this?