Product Logos BridgeIt Services Banner
Datatable checkbox  XML
Forum Index -> General Help
Author Message
kev231

Joined: 10/Aug/2007 00:00:00
Messages: 2
Offline


Hi,

I like to implement a datatable with checkboxes. After which, I like to use a 'delete all selected' command button for deleting the selected rows of the datatable.

anyone knows howto?

thanks
Sn0w

Joined: 28/Apr/2007 00:00:00
Messages: 26
Offline


We just added chechbox with valueChangeListener which sets value to table record ids list.

Code:
 
 <ice:column>
 							<f:facet name="header">
 								<ice:panelGroup>
 									<center><ice:outputText value="+"
 										style="color: white;" /></center>
 								</ice:panelGroup>
 							</f:facet>
 							<ice:selectBooleanCheckbox
 								valueChangeListener="#{contact.select}"
 								value="#{contact.selected}" />
 						</ice:column>
 
 

No one lives forever...
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


It's not difficult at all!
You just add a boolean value to your beans from the list rendered in the dataTable, and a column which includes just the <selectBooleanCheckbox value="#{row.checked}" ... /> where row is your iterating var (you don't need any listener in here).
Next, add a button "Delete all" and on it's listener traverse your list of beans and delete those which are selected.
Do you think it's difficult? If so ... I'll post an example ... but not right now :)
Cheers!
maCC

Joined: 26/Jun/2007 00:00:00
Messages: 23
Offline


Hai Edy, i have a lil bit problem. I have 100 data, and i'm using paginator to show only 20 data per page. How do I select all the 20 checkboxes that are currently shown on the page, not all 100 data?

Thanks for your help.
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hi there!
It's not really that difficult, but it's not trivial either. By best advice would be to do the following (I hope I don't mess the names, but I'm trying to answer fast and I don't have so much time right now):
In the bean treating the event you need (I guess you want something like Select All button or link)
1. bind the datatable to a HtmlDataTable field
2. bind the dataPaginator to a DataPaginator field
3. In the action listener method get the current page from the dataPaginator, get the number of rows per page from the dataTable (if it's not hardcoded) and calculate which beans are exactly in that interval. Then iterate through them and set the checked flag on true.
This should do it, in my understanding, but I didn't test, so give it a shot and let us know how it worked.

If it's not so clear ... let me know and I'll try to make a sample just for you .... :) !

Cheers!
maCC

Joined: 26/Jun/2007 00:00:00
Messages: 23
Offline


Thanks Edy. I'm trying it now
toashishk

Joined: 18/Apr/2007 00:00:00
Messages: 14
Offline


Hi edykory ,

Can we do this thing i.e. putting checkboxes in a data table with dyanmic number of columns, i.e. I am rendering data using <ice:columns> tag.


Regards,
Ashish
reenaelizabeth

Joined: 09/Apr/2008 00:00:00
Messages: 3
Offline


Hi,
Can u post a complete sample. i m in pressure
sawan1424

Joined: 08/Jun/2008 00:00:00
Messages: 21
Offline


I have the same problem.Can you tell how to delete the selected checkboxes from command button which is outside of datatable.
 Filename scriptdraft.jsp [Disk] Download
 Description This is the JSP page in which I include checkboxes.Plz help me?
 Filesize 7 Kbytes
 Downloaded:  526 time(s)

 Filename ScriptDraftBean.java [Disk] Download
 Description this is manage bean. I don't what I do in actionListener.
 Filesize 4 Kbytes
 Downloaded:  530 time(s)

RaulitoxD

Joined: 20/May/2010 11:19:45
Messages: 2
Offline


yo raulito digo:


private List<PrivilegioVO> listaP;

+++++++++++++++++++++


<ice:dataTable value="#{PrivilegioBean.listaP}" var="list"
id="dtPrivilegio" rows="1" varStatus="rowInfo" width="100%"
rowClasses="oddRow, evenRow"
rendered="#{not empty PrivilegioBean.lista}">


<ice:column>
<f:facet name="header">
<ice:outputText value="checks"
visible="#{PrivilegioBean.visListRol}" />
</f:facet>

<ice:outputText value="#{list.id}"
visible="#{PrivilegioBean.visListRol}" />

<ice:selectBooleanCheckbox value="#{list.hidden}" visible="#{PrivilegioBean.visListRol}" >
</ice:selectBooleanCheckbox>
</ice:column>
</ice:dataTable>



+++++++++++++++++++++++




public void agregar(ActionEvent ev) {
System.out.println("ENTRO AGREAR");

PrivilegioVO bean;
for (int i = 0; i < listaP.size(); i++) {
bean=(PrivilegioVO)listaP.get(i);
System.out.println(bean.getId() +" - "+bean.isHidden());
}

}




++++++++++++++++++++++++


public class PrivilegioVO implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2511402383112991844L;
private Long id;
private String accion;
private String nombre;
private String descripcion;
private String estado;
private String modulo;
private boolean hidden;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccion() {
return accion;
}
public void setAccion(String accion) {
this.accion = accion;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public String getEstado() {
return estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
public String getModulo() {
return modulo;
}
public void setModulo(String modulo) {
this.modulo = modulo;
}
public boolean isHidden() {
return hidden;
}
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
}



chriszhao

Joined: 11/May/2008 00:00:00
Messages: 2
Offline


Hey, you can use valueChangeListener to call the listenCheckbox of each item in the list. in your case:
valueChangeListener="#{script.listenCheckbox}"
chriszhao

Joined: 11/May/2008 00:00:00
Messages: 2
Offline


Hey, you can use valueChangeListener to call the listenCheckbox of each item in the list. in your case:
valueChangeListener="#{script.listenCheckbox}"

But as the other guy talked about that you may need to use valueBinding.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team