Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial rendering via FacesContext [duplicate]

Tags:

jsf

actually I got a inputText and some ajax Request to render a datatable when a keyup event appears.

mypage.xhmtl:

 <h:form id="form">

    <h:inputText id="number_in" value="#{bean.number}" redisplay="false" >
         <f:ajax event="keyup" render=":form:dataTable" />
    </h:inputText>

    <h:dataTable id="dataTable" ...>
    ...
    </h:dataTable>

 <h:form>

I don't want to render the dataTable from the jsf page anymore. I want to render the dataTable in a MangedBean by FacesContext when a listener method is invoked.

mypage.xhtml:

<h:form id="form">

    <h:inputText id="number_in" value="#{bean.number}" redisplay="false" >
         <f:ajax event="keyup" listener="#{bean.onKeyup}" />
    </h:inputText>

    <h:dataTable id="dataTable" ...>
    ...
    </h:dataTable>

mybean.java:

  @ManagedBean(name="bean")
  @SessionScoped
  public class Bean {
     ...
     public void onKeyUp(AjaxBehaviorEvent event) {
        //Here I want to render the dataTable
     }
     ...
  }

How can I achieve that?

like image 874
Paul Wasilewski Avatar asked Jan 25 '26 20:01

Paul Wasilewski


1 Answers

You can programmatically add render IDs to PartialViewContext#getRenderIds().

FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add("form:dataTable");

Note that this can contain only absolute client IDs and should not be prefixed with :.

like image 153
BalusC Avatar answered Jan 28 '26 11:01

BalusC