0

A button on page xyz.xhtml does invoke this code (using ajax).

FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nh = fc.getApplication().getNavigationHandler();
nh.handleNavigation(fc, null, "home");

home points to abc.xhtml. This page contains a table which should be refreshed but this does not happen. Any idea?

How can I refresh without using own JavaScript? I've got a workaround using onload attribute and JavaScript which reloads table using ajax. But this does "flatter" screen. This solution is not sophisticated.

I am using JSF 2, OpenFaces 3 and IE8.

Thank you in advance!

Thomas
  • 8,357
  • 15
  • 45
  • 81

1 Answers1

0

I don't understand why you're fiddling with the navigation handler like that. I'm not sure about the OpenFaces part since I've never used it, so here's just a basic JSF 2.x approach with <f:ajax> to give the basic idea of how it should actually be done:

<h:form>
    <h:commandButton value="refresh" action="#{bean.refresh}">
        <f:ajax render=":table" />
    </h:commandButton>
</h:form>

<h:dataTable id="table" value="#{bean.list}" var="item">
    ...
</h:dataTable>

with

public void refresh() {
    list = someService.list();
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • That's also not a requirement. All you need to know is just the table's (client) ID and that the button action reloads the data. – BalusC Jun 14 '11 at 13:04
  • even though it's not on the same page? i didn't know that. i'll try that. thanks. (i was able to solve my problem, it was a little bug within my code.) – Thomas Jun 14 '11 at 13:41
  • JS/Ajax operates fully on the HTML DOM tree at the client side. It knows absolutely nothing about how the server side view templates are structured and composed. All it gets and sees is one big HTML DOM tree. It's exactly the same which you see yourself when you open the page in the browser and do rightclick and choose *View Source*. You see, it's one and all HTML in the same "file". The ajax client IDs refer to exactly those HTML element IDs. – BalusC Jun 14 '11 at 13:45