You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by EROL TEZCAN <st...@yahoo.com> on 2005/07/01 18:00:53 UTC
struts - checkbox kontrol
Hi,
When an Action (ListRecord.do) was invoked by a JSP , it lists all records from db like this.
name surname delete
-------------------------------------------------------------------
aaa1 bbbbb1 | + |
aaa2 bbbbb2 | - |
aaa3 bbbbb3 | + |
-------------------------------------------------------------------
_______ _________
|__aaa4__| |_ bbbbb4 _|
_______ ______
|__add__| |_delete_|
To add a new record to this list, I enter new datas like ( aaa4, bbbbb4 ) and press add button. Form submits to same action (ListRecord) and adds records without any problem.
Problem :
When I checked to some checkbox and submit form to same Action, it gives an error.
How can I control checked checkbox and delete them ?
What is the best way ?
Erol
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: struts - checkbox kontrol
Posted by Rafael Taboada <ka...@gmail.com>.
More information:
http://husted.com/struts/tips/007.html
--
Rafael Taboada
Software Engineer
Cell : +511-97753290
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: struts - checkbox control
Posted by EROL TEZCAN <st...@yahoo.com>.
Hi ,
Your example is very clear. It works fine.
Thanks a lot Rafael,
Erol
Rafael Taboada <ka...@gmail.com> wrote:
Hi, in ur ActionForm define:
String[] chkRecords; //with setter and getter
In ur jsp define checkbox with a multibox:
list: ArrayList that it has all the records in order to list in ur jsp
idRecord: id of each record in ur database
Finally in ur Action class:
String[] strRecords = myForm.getchkRecords();
for (int i = 0; i myDAO.deleteRecord(strRecords[i]);
}
My Actionclass extends DispatchAction and when I click delete button I call
a specific "delete" method. This code is inside this method
I hope it can help u
--
Rafael Taboada
Software Engineer
Cell : +511-97753290
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: struts - checkbox kontrol
Posted by Rafael Taboada <ka...@gmail.com>.
Hi, in ur ActionForm define:
String[] chkRecords; //with setter and getter
In ur jsp define checkbox with a multibox:
<html:multibox name="myForm" property="chkRecords">
<bean:write name="list" property="idRecord" />
</html:multibox>
list: ArrayList that it has all the records in order to list in ur jsp
idRecord: id of each record in ur database
Finally in ur Action class:
String[] strRecords = myForm.getchkRecords();
for (int i = 0; i<strRecords.length; i++) {
myDAO.deleteRecord(strRecords[i]);
}
My Actionclass extends DispatchAction and when I click delete button I call
a specific "delete" method. This code is inside this method
I hope it can help u
--
Rafael Taboada
Software Engineer
Cell : +511-97753290
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"