Pessoal, ao clicar em um botão, preciso que ele vá no banco de dados e alimente uma DataTable com os dados que ele trouxe.
Pretendo usar um ManagedBean. Aqui está parte do meu código:
management_reports.jsf
<f:view>
<h:form>
<table id="tableSearch">
<tr>
<td>
<input type="radio" id="rbtDayRel" name="search" checked>Por Dia: </input>
<h:inputText id="txtDayRel" onkeypress="mask(this,dateRange)" maxlength="10" />
</td>
<td>
<input type="radio" id="rbtMonthRel" name="search">Por Mês: </input>
<h:selectOneMenu id="comboMonth">
<f:selectItem itemValue="Escolha o Mês"/><f:selectItem itemValue="1"/><f:selectItem itemValue="2"/><f:selectItem itemValue="3"/><f:selectItem itemValue="4"/><f:selectItem itemValue="5"/><f:selectItem itemValue="6"/><f:selectItem itemValue="7"/><f:selectItem itemValue="8"/><f:selectItem itemValue="9"/><f:selectItem itemValue="10"/><f:selectItem itemValue="11"/><f:selectItem itemValue="12"/>
</h:selectOneMenu>
</td>
<td id="colInterval">
<input type="radio" id="rbtIntervalRel" name="search">Entre datas: </input>
<h:inputText id="dateOne" onkeypress="mask(this,dateRange)" maxlength="10" />
<h:outputText value="à"/>
<h:inputText id="dateTwo" onkeypress="mask(this,dateRange)" maxlength="10" />
</td>
<td>
<input type="radio" id="rbtAPRel" name="search">Por AP: </input>
<h:selectOneMenu id="comboAP">
<f:selectItem itemValue="Escolha o AP"/>
</h:selectOneMenu>
</td>
<td>
<input type="radio" id="rbtRegionRel" name="search">Por Região: </input>
<h:selectOneMenu id="comboRegion">
<f:selectItem itemValue="Escolha a Região"/>
</h:selectOneMenu>
</td>
<td id="colInterval">
<input type="button" id="btnOK" name="btnOK" value="OK" />
</td>
</tr>
</table>
</h:form>
</f:view>
</div>
<div id="rodapeRelGen">
<label class="resultRelGen">Número de Acessos: </label><label class="resultRelGen">0</label><br>
<label class="resultRelGen">Número de Usuários: </label><label class="resultRelGen">0</label>
</div>
<h:dataTable id="tableRelatorio" var="rel" value="{reportBean.lista}">
<h:column>
<f:facet name="header" >
<h:commandLink value="Data"></h:commandLink>
</f:facet>
<h:outputText value="" />
</h:column>
<h:column>
<f:facet name="header" >
<h:commandLink value="Horário"></h:commandLink>
</f:facet>
<h:outputText value="" />
</h:column>
<h:column>
<f:facet name="header" >
<h:commandLink value="Usuário"></h:commandLink>
</f:facet>
<h:outputText value="" />
</h:column>
<h:column>
<f:facet name="header" >
<h:commandLink value="AP"></h:commandLink>
</f:facet>
<h:outputText value="" />
</h:column>
</h:dataTable>
jReportBean.java
@ManagedBean(name = "reportBean")
@SessionScoped
public class JReportBean {
/*private Matriculado matriculado = new Matriculado();
private List<Matriculado> lista = new ArrayList<Matriculado>(); */
public JReportBean() {
}
/*public List<Matriculado> getListaFiltrada(ActionEvent event) {
lista = JAPInfoDBManager.getHistoricalConnections(matriculado);
return lista;
}*/
}
Ao clicar, preciso que ele alimente a tabela abaixo, como mostrado no primeiro código… alguem pode me ajudar ?
Desde já agradeço.