marcossousaPJ 28 de jun. de 2006
ummm é só você criar um método que manipule esta lista aí no seu backing bean.
:okok:
java-CachacaPJ 28 de jun. de 2006
Marcos,
apesar da sua dica não estou conseguindo.
Vamos aos códigos:
[ FacesConfig ]
<managed-bean>
<managed-bean-name>funcaoList</managed-bean-name>
<managed-bean-class>br.com.simcaweb.web.FuncaoList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>rowsPerPage</property-name>
<value>5</value>
</managed-property>
<managed-property>
<property-name>funcaoManager</property-name>
<value>#{funcaoManager}</value>
</managed-property>
</managed-bean>
[ BackingBean ]
package br.com.simcaweb.web ;
import java.util.List ;
import javax.faces.component.UIData ;
import javax.faces.event.ActionEvent ;
import br.com.simcaweb.service.FuncaoManager ;
public class FuncaoList & # 123 ;
private FuncaoManager mgr = null ;
private int rowsPerPage = 5 ;
private UIData historyDataTable ;
private String valorPesquisado = & quot ; & quot ;;
private String criterioPesquisa = & quot ; & quot ;;
public UIData getHistoryDataTable & # 40 ; & # 41 ; & # 123 ;
return historyDataTable ;
& # 125 ;
public void setHistoryDataTable & # 40 ; UIData historyDataTable & # 41 ; & # 123 ;
this . historyDataTable = historyDataTable ;
& # 125 ;
public int getRowsPerPage & # 40 ; & # 41 ; & # 123 ;
return rowsPerPage ;
& # 125 ;
public void setRowsPerPage & # 40 ; int rowsPerPage & # 41 ; & # 123 ;
this . rowsPerPage = rowsPerPage ;
& # 125 ;
public boolean getShowNext & # 40 ; & # 41 ; & # 123 ;
return & # 40 ; historyDataTable . getFirst & # 40 ; & # 41 ; + rowsPerPage & # 41 ; & lt ; getFuncoes & # 40 ; & # 41 ;. size & # 40 ; & # 41 ;;
& # 125 ;
public boolean getShowPrevious & # 40 ; & # 41 ; & # 123 ;
return & # 40 ; historyDataTable . getFirst & # 40 ; & # 41 ; - rowsPerPage & # 41 ; & gt ; = 0 ;
& # 125 ;
public void next & # 40 ; ActionEvent actionEvent & # 41 ; & # 123 ;
int newFirst = historyDataTable . getFirst & # 40 ; & # 41 ; + rowsPerPage ;
if & # 40 ; newFirst & lt ; getFuncoes & # 40 ; & # 41 ;. size & # 40 ; & # 41 ; & # 41 ; & # 123 ;
historyDataTable . setFirst & # 40 ; newFirst & # 41 ;;
& # 125 ;
& # 125 ;
public void previous & # 40 ; ActionEvent actionEvent & # 41 ; & # 123 ;
int newFirst = historyDataTable . getFirst & # 40 ; & # 41 ; - rowsPerPage ;
if & # 40 ; newFirst & gt ; = 0 & # 41 ; & # 123 ;
historyDataTable . setFirst & # 40 ; newFirst & # 41 ;;
& # 125 ;
& # 125 ;
public void first & # 40 ; ActionEvent actionEvent & # 41 ; & # 123 ;
historyDataTable . setFirst & # 40 ; 0 & # 41 ;;
& # 125 ;
public void last & # 40 ; ActionEvent actionEvent & # 41 ; & # 123 ;
int newFirst = historyDataTable . getRowCount & # 40 ; & # 41 ; - rowsPerPage ;
if & # 40 ; newFirst & gt ; = 0 & # 41 ; & # 123 ;
historyDataTable . setFirst & # 40 ; newFirst & # 41 ;;
& # 125 ;
& # 125 ;
public String getValorPesquisado & # 40 ; & # 41 ; & # 123 ;
return valorPesquisado ;
& # 125 ;
public void setValorPesquisado & # 40 ; String valorPesquisado & # 41 ; & # 123 ;
this . valorPesquisado = valorPesquisado ;
& # 125 ;
public String getCriterioPesquisa & # 40 ; & # 41 ; & # 123 ;
return criterioPesquisa ;
& # 125 ;
public void setCriterioPesquisa & # 40 ; String criterioPesquisa & # 41 ; & # 123 ;
this . criterioPesquisa = criterioPesquisa ;
& # 125 ;
public void setFuncaoManager & # 40 ; FuncaoManager funcaoManager & # 41 ; & # 123 ;
this . mgr = funcaoManager ;
& # 125 ;
public List getFuncoes & # 40 ; & # 41 ; & # 123 ;
return mgr . getFuncoes & # 40 ; & # 41 ;;
& # 125 ;
public List getFuncoes & # 40 ; String a , String b & # 41 ; & # 123 ;
return null ;
& # 125 ;
public List getFuncoesByCriteria & # 40 ; & # 41 ; & # 123 ;
System . out . println & # 40 ; getValorPesquisado & # 40 ; & # 41 ; + & quot ; -& quot ; + getCriterioPesquisa & # 40 ; & # 41 ; & # 41 ;;
getFuncoes & # 40 ; valorPesquisado , criterioPesquisa & # 41 ;;
return null ;
& # 125 ;
& # 125 ;
[ JSP ]
& lt ; % @ include file =& quot ; / taglibs . jsp & quot ; %& gt ;
& lt ; f & #58;view>
& lt ; f & #58;loadBundle var="messages" basename="messages"/>
& lt ; title & gt ; & lt ; fmt & #58;message key="index.title"/>-<fmt:message key="funcaoList.title"/></title>
& lt ; h2 & gt ; & lt ; fmt & #58;message key="funcaoList.title"/></h2>
& lt ; h & #58;form id="funcaoList">
& lt ; fieldset & gt ;
& lt ; legend & gt ; & lt ; fmt & #58;message key="field.pesquisa"/>:</legend>
& lt ; h & #58;outputLabel for="valorPesquisado" value="#{messages['field.valor']}"/>:
& lt ; h & #58;inputText value="#{funcaoList.valorPesquisado}" id="valorPesquisado" required="false" size="40"/>
& lt ; select id =& quot ; criterioPesquisa & quot ; value =& quot ; #{funcaoList.criterioPesquisa}">
& lt ; option & gt ; exatamente & lt ; / option & gt ;
& lt ; option & gt ; começando por & lt ; / option & gt ;
& lt ; option & gt ; terminando por & lt ; / option & gt ;
& lt ; / select & gt ;
& lt ; h & #58;commandButton accesskey="P" value="#{messages['button.pesquisar']}" action="#{funcaoList.getFuncoesByCriteria}" id="find" immediate="true" styleClass="button"/>
& lt ; / fieldset & gt ;
& lt ; hr /& gt ;
& lt ; div align =& quot ; center & quot ; & gt ;
& lt ; h & #58;commandButton accesskey="I" value="#{messages['button.incluir']}" action="add" id="add" immediate="true" styleClass="button"/>
& lt ; h & #58;commandButton accesskey="r" value="#{messages['button.imprimir']}" action="#{funcaoForm.print}" id="print" immediate="true" styleClass="button"/>
& lt ; h & #58;commandButton accesskey="A" value="#{messages['button.atualizar']}" action="#{funcaoForm.requery}" id="requery" immediate="true" styleClass="button"/>
& lt ; / div & gt ;
& lt ; hr /& gt ;
& lt ; h & #58;dataTable var="funcao" value="#{funcaoList.funcoes}" binding="#{funcaoList.historyDataTable}" rows="#{funcaoList.rowsPerPage}" id="funcaoList" styleClass="list" rowClasses="odd,even">
& lt ; h & #58;column>
& lt ; f & #58;facet name="header"><h:outputText value="#{messages['field.id']}"/></f:facet>
& lt ; h & #58;commandLink action="#{funcaoForm.edit}" value="#{funcao.id}">
& lt ; f & #58;param name="id" value="#{funcao.id}"/>
& lt ; / h & #58;commandLink>
& lt ; / h & #58;column>
& lt ; h & #58;column>
& lt ; f & #58;facet name="header"><h:outputText value="#{messages['field.descricao']}"/></f:facet>
& lt ; h & #58;outputText value="#{funcao.descricao}"/>
& lt ; / h & #58;column>
& lt ; f & #58;facet name="footer">
& lt ; h & #58;panelGroup>
& lt ; h & #58;commandLink actionListener="#{funcaoList.first}" style="padding-right: 5px;">
& lt ; h & #58;outputText value="#{messages['button.primeiro']}"/>
& lt ; / h & #58;commandLink>
& lt ; h & #58;commandLink actionListener="#{funcaoList.previous}" rendered="#{funcaoList.showPrevious}" style="padding-right: 5px;">
& lt ; h & #58;outputText value="#{messages['button.anterior']}"/>
& lt ; / h & #58;commandLink>
& lt ; h & #58;commandLink actionListener="#{funcaoList.next}" rendered="#{funcaoList.showNext}" style="padding-right: 5px;">
& lt ; h & #58;outputText value="#{messages['button.proximo']}"/>
& lt ; / h & #58;commandLink>
& lt ; h & #58;commandLink actionListener="#{funcaoList.last}">
& lt ; h & #58;outputText value="#{messages['button.ultimo']}"/>
& lt ; / h & #58;commandLink>
& lt ; / h & #58;panelGroup>
& lt ; / f & #58;facet>
& lt ; / h & #58;dataTable>
& lt ; / h & #58;form>
& lt ; / f & #58;view>
Inclusive eu não to conseguindo ler os campos para pesquisa que eu seto na tela.
java-CachacaPJ 28 de jun. de 2006
E ai galera,
Alguma luz ?
marcossousaPJ 29 de jun. de 2006
Opa,
Acho que o teu problema está em não ter criado uma variável para armazenar suas funções… aí sempre que você executa o método e faz as operações, mas quando vai carregar, chama o metódo getFuncoes e ele simplemente, retorna na ordem default.
:okok: