Guguuu 27 de ago. de 2010
Bom isso conseguir resolver to com outro problema ... rsrsrs
link bom pra ajudar
http://lists.jboss.org/pipermail/richfaces-svn-commits/2008-December/011900.html
bom a solução do primeiro problema eh
private SimpleSelection selection ;
O novo problema eh q nao consigo, apos o click na linha da tabela atualizar um campo pode ser ou
o importante e q funcione..
estou usando o Ajax pra fazer mais nao to conseguindo
pq nao consigo botar um metodo no parametro "action" e no site de referencia a cima ta
um metodo normal void... agora chama o meu metodo nao sei pq.
codigo do site
public class ExtendedTableBean {
private String sortMode = "single" ;
private String selectionMode = "multi" ;
private HtmlExtendedDataTable table ;
private SimpleSelection selection ;
private List < Capital > selectedCapitals = new ArrayList < Capital > ();
private ExtendedTableDataModel < Capital > dataModel ;
private List < Capital > capitals = new ArrayList < Capital > ();
public void takeSelection () {
getSelectedCapitals (). clear ();
Iterator < Object > iterator = getSelection (). getKeys ();
while ( iterator . hasNext ()){
Object key = iterator . next ();
table . setRowKey ( key );
if ( table . isRowAvailable ()) {
getSelectedCapitals (). add (( Capital ) table . getRowData ());
}
}
}
public void resetSelection () {
getSelectedCapitals (). clear ();
}
public String getSortMode () {
return sortMode ;
}
@@ - 57 , 29 + 39 , 41 @@
public ExtendedTableBean () {
}
public ExtendedTableDataModel < Capital > getCapitalsDataModel () {
if ( dataModel == null ) {
dataModel = new ExtendedTableDataModel < Capital > ( new DataProvider < Capital > (){
public HtmlExtendedDataTable getTable () {
return table ;
}
private static final long serialVersionUID = 5054087821033164847L ;
public void setTable ( HtmlExtendedDataTable table ) {
this . table = table ;
}
public Capital getItemByKey ( Object key ) {
for ( Capital c : capitals ){
if ( key . equals ( getKey ( c ))){
return c ;
}
}
return null ;
}
public SimpleSelection getSelection () {
return selection ;
}
public List < Capital > getItemsByRange ( int firstRow , int endRow ) {
return capitals . subList ( firstRow , endRow );
}
public void setSelection ( SimpleSelection selection ) {
this . selection = selection ;
}
public Object getKey ( Capital item ) {
return item . getName ();
}
public List < Capital > getSelectedCapitals () {
return selectedCapitals ;
public int getRowCount () {
return capitals . size ();
}
});
}
return dataModel ;
}
this . selectedCapitals = selectedCapitals ;
public void setCapitals ( List < Capital > capitals ) {
this . capitals = capitals ;
}
}
jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml"
xmlns:ui = "http://java.sun.com/jsf/facelets"
xmlns:h = "http://java.sun.com/jsf/html"
xmlns:f = "http://java.sun.com/jsf/core"
xmlns:a4j = "http://richfaces.org/a4j"
xmlns:rich = "http://richfaces.org/rich" >
< ui:composition >
< h:form >
< h:panelGrid columns = "2" columnClasses = "top , top" >
< rich:extendedDataTable
value = "#{extendedTableBean.capitalsDataModel}" var = "cap" id = "table"
width = "580px" height = "400px"
sortMode = "#{extendedTableBean.sortMode}"
selectionMode = "#{extendedTableBean.selectionMode}"
tableState = "#{extendedTableBean.tableState}"
selection = "#{extendedTableBean.selection}" >
< rich:column sortable = "false" label = "Flag" >
< f:facet name = "header" >
< h:outputText value = "Flag" />
</ f:facet >
< h:graphicImage value = "#{cap.stateFlag}" />
</ rich:column >
< rich:column sortable = "true" sortBy = "#{cap.state}"
filterBy = "#{cap.state}" filterEvent = "onkeyup" width = "170px"
label = "State Name" >
< f:facet name = "header" >
< h:outputText value = "State Name" />
</ f:facet >
< h:outputText value = "#{cap.state}" />
</ rich:column >
< rich:column sortable = "true" sortBy = "#{cap.name}"
filterBy = "#{cap.name}" filterEvent = "onkeyup" width = "170px"
label = "State Capital" >
< f:facet name = "header" >
< h:outputText value = "State Capital" />
</ f:facet >
< h:outputText value = "#{cap.name}" />
</ rich:column >
< rich:column sortable = "false" label = "Time Zone" >
< f:facet name = "header" >
< h:outputText value = "Time Zone" />
</ f:facet >
< h:outputText value = "#{cap.timeZone}" />
</ rich:column >
< a4j:support reRender = "selectiontable"
action = "#{extendedTableBean.takeSelection}"
event = "onselectionchange" />
</ rich:extendedDataTable >
< h:panelGroup layout = "block" style = "width:250px" >
< rich:panel >
< f:facet name = "header" >
< h:outputText value = "Sort/Selection modes changing" />
</ f:facet >
< h:panelGrid columns = "2" >
< h:outputText value = "Sort Mode:" />
< h:selectOneMenu value = "#{extendedTableBean.sortMode}" >
< f:selectItem itemLabel = "Single" itemValue = "single" />
< f:selectItem itemLabel = "Multi" itemValue = "multi" />
< a4j:support event = "onchange" ajaxSingle = "true" reRender = "table" />
</ h:selectOneMenu >
< h:outputText value = "Selection Mode:" />
< h:selectOneMenu value = "#{extendedTableBean.selectionMode}" >
< a4j:support ajaxSingle = "true" event = "onchange" reRender = "table" />
< f:selectItem itemLabel = "Single" itemValue = "single" />
< f:selectItem itemLabel = "Multi" itemValue = "multi" />
< f:selectItem itemLabel = "None" itemValue = "none" />
</ h:selectOneMenu >
</ h:panelGrid >
</ rich:panel >
< rich:panel >
< f:facet name = "header" >
< h:outputText value = "Currently selected rows:" />
</ f:facet >
< rich:dataTable value = "#{extendedTableBean.selectedCapitals}"
var = "sel" id = "selectiontable" >
< rich:column >
< h:graphicImage value = "#{sel.stateFlag}" />
</ rich:column >
< rich:column >
< h:outputText value = "#{sel.state}" />
</ rich:column >
< rich:column >
< h:outputText value = "#{sel.name}" />
</ rich:column >
< rich:column >
< h:outputText value = "#{sel.timeZone}" />
</ rich:column >
</ rich:dataTable >
</ rich:panel >
</ h:panelGroup >
</ h:panelGrid >
</ h:form >
</ ui:composition >
</ html >
Guguuu 27 de ago. de 2010
ninguem? :shock:
Guguuu 30 de ago. de 2010
por favor me ajudemmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm!!!
Tiagocasemiro 5 de jan. de 2011
tenta usar um metodo String com o retorno um link mapeado no xml