Tenho o Seguinte cenario:
quando entro na tela guiaconsulta.jsf , ele carrega o meu bean e como estou usando um datatable com value cadguiaMbean.cadastropretador, quando carrega a pagina
ele dá getCadastropretador e carrega a minha lista
cadprestservico.buscacadprest();
Gostaria de carregasse o DataTable somente quando clicasse no meu commandLink
<p:commandLink immediate="true" action="#{cadguiaMbean.carregagridcadprest}">
<p:graphicImage value="../resources/images/buscar.png" onclick="dlg2.show();"/>
</p:commandLink>
Como agora são pouco registros, nao tem problema, mas se essa tabela futuramente tiver muitos registros posso ter problema de performace.
Alguem pode dar uma dica ??
****************************************
<p:commandLink immediate="true" action="#{cadguiaMbean.carregagridcadprest}">
<p:graphicImage value="../resources/images/buscar.png" onclick="dlg2.show();"/>
</p:commandLink>
<p:dialog id="modalDialog" header="#{msg.guiaconsulta_consultaprest}" widgetVar="dlg2" modal="true" height="490" width="600" >
<h:form id="form">
<p:dataTable id="idcadastropretador" var="cadastropretador" value="#{cadguiaMbean.cadastropretador}" paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15"
style=" font-size: 12px;"
>
<p:ajax event="rowSelect" update=":blah" listener="#{cadguiaMbean.onRowSelect}"/>
<p:column id="cod" filterBy="#{cadastropretador.codprest}"
headerText="Codigo"
filterMatchMode="contains"
styleClass="fonte">
<h:outputText value="#{cadastropretador.codprest}" styleClass="fonte"/>
</p:column>
<p:column id="name" filterBy="#{cadastropretador.nomeprest}"
headerText="Nome" style="width:370px"
filterMatchMode="contains"
filterStyle="max-width: 40px; min-width: 330px;"
styleClass="fonte">
<h:outputText value="#{cadastropretador.nomeprest}" styleClass="fonte" />
</p:column>
<p:column headerText="" styleClass="fonte">
<h:commandLink action="#{cadguiaMbean.selecionar(cadastropretador)}">
<p:graphicImage value="../resources/images/confirmarnew.png"/>
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
</p:dialog>
****************************************
Bean
@ManagedBean
@ViewScoped
public class CadguiaMbean extends ManagedBeanGenerico<Cadguia, CadguiaServico> implements Serializable {
@EJB
private CadguiaServico servico;
@EJB
private PrestespServico prestservico;
@EJB
private CadprestServico cadprestservico;
private List<SelectItem> itenscadprest;
private List<Cadprest> itenscadastroprest;
private Cadguia obj1 = new Cadguia();
private String vuser_autentica;
private String vnomeprestador;
private Integer itemlistaespecialidade;
private List<SelectItem> item;
private List<Cadprest> cadastropretador;
private Cadprest selectedCadprest;
public List<Cadprest> getCadastropretador() {
return cadprestservico.buscacadprest();
}