update outputtext from class

275 Views Asked by At

I have a RichFaces project on JSF 2.2 and I wanted to show status updates and messages to the user while processing their request. I wanted to use a a4j:outputpanel with a simple outputext for this. I added a system.out line and it shows up on my server console when but the text on the screen is not updated.

In my process class:

private void showAdvise(final String message) {
   System.out.println(">>>>>ComUI showAdvise: " + message);
   this.beidCardStatusBean.updateStatus(message);
}

On my jsf page: - I launch the proces with:

 <a style="font-size:150%;" onclick="startEID();" 
href="savePhoto.do?userId=#{detailUserBean.id}">#{UIMessages['button.loadPhoto']}</a>

<a:outputPanel id="eidPaneContainer" ajaxRendered="true">
  <rich:popupPanel header="EID" id="eidPane" width="100" height="80">
    <h:outputText id="eidStatus" value="#{beidCardStatusBean.getStatus()}" >
    </h:outputText>
  </rich:popupPanel>
</a:outputPanel>
1

There are 1 best solutions below

0
Makhiel On

In order to update the components the page has to send a request to the server, it doesn't happen automatically when something on the server changes. The easy solution is to use a poll, e.g.

<a4j:poll id="poll" interval="2000" enabled="#{bean.pollEnabled}" render="poll, popup" />

This will rerender the popup every 2 seconds. So in your case startEID needs to set pollEnabled and rerender the poll to start it.

PopupPanel might be a bit problematic when it comes to rerendering, try setting domElementAttachment="parent" if this doesn't work.