You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vishnu Vyasan Nelliparmbil <vi...@MUN.GOV.BH> on 2009/06/20 07:28:43 UTC
Doubt with using check box
Hi Friends,
I am new to web development and struts. I have a simple question.
I am using <logic:iterate> tag to iterate through a list of Employees
and display their details.
The list contains the Employee objects.
Now while displaying Employee details in a table, the row is ending with
a check box , so that the user can select employees. The check boxes are
created dynamically since they are inside the iterate tag.
Now how in Action I know that a specific employee is selected?
In action form I would get whether the check box is selected or not. But
how can I relate that to employees in list?
Thanks in Advance
vishnu
Re: Doubt with using check box
Posted by Girish Naik <gi...@gmail.com>.
You can look at *Map Backed
ActionForms*<http://struts.apache.org/1.x/userGuide/building_controller.html>Section
4.3.3
Regards,
---------------------------------------------------------
Girish Naik
Mobile:-+91-09740091638
girish.naik@gmail.com
P. J. O'Rourke<http://www.brainyquote.com/quotes/authors/p/p_j_orourke.html>
- "If government were a product, selling it would be illegal."
On Sun, Jun 21, 2009 at 10:26 AM, Vishnu Vyasan Nelliparmbil <
vishnu@mun.gov.bh> wrote:
>
> Can anybody help me on this issue?
>
>
>
>
> -----Original Message-----
> From: Vishnu Vyasan Nelliparmbil [mailto:vishnu@MUN.GOV.BH]
> Sent: 20 June 2009 13:21
> To: Struts Users Mailing List
> Subject: RE: Doubt with using check box
>
>
>
> Pawel , can you expalin with a example. I am totally new to struts.
>
> I tried with another way.
>
> Ie by adding a 'selected' field to the EmployeeBean.
>
> <logic:iterate id="EmployeeBean" name="EMPLOYEE" scope="session">
> <tr>
> <td> <bean:write name=" EmployeeBean" property="employee_name"
> /></td>
> <td> <bean:write name=" EmployeeBean" property="employee_salary"
> /></td>
> <td><html:checkbox name=" EmployeeBean" property="selected"
> onchange="checkEmployee();" > </html:checkbox>
> <tr>
> </logic:iterate>
>
> Now I am getting the values of selected as false in the Action. Even though
> I have selected it.
> I am using a action form for the some other elements in the same view.
>
> Could you guys can through some light on how to make this work?
>
>
> Regards
> Vishnu
>
>
>
> -----Original Message-----
> From: Paweł Wielgus [mailto:poulwiel@gmail.com]
> Sent: 20 June 2009 10:40
> To: Struts Users Mailing List
> Subject: Re: Doubt with using check box
>
> Hi Vishnu,
> on the html page you will have a list of checkboxes with the same name
> "selectedEmployees" and a value of an employee identificator. In the
> action create settet setSelectedEmloyees(String[] selectedEmployees),
> then in execute You can access this table of employee identificators.
> Just as a side note, i don't know what type of is your employee
> identificator, so i proposed String, but it can also be long.
>
> Best greetings,
> Pawel Wielgus.
>
> 2009/6/20, Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
> > Hi Friends,
> >
> > I am new to web development and struts. I have a simple question.
> >
> > I am using <logic:iterate> tag to iterate through a list of Employees
> > and display their details.
> > The list contains the Employee objects.
> > Now while displaying Employee details in a table, the row is ending with
> > a check box , so that the user can select employees. The check boxes are
> > created dynamically since they are inside the iterate tag.
> >
> > Now how in Action I know that a specific employee is selected?
> >
> > In action form I would get whether the check box is selected or not. But
> > how can I relate that to employees in list?
> >
> > Thanks in Advance
> > vishnu
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
RE: Doubt with using check box
Posted by Vishnu Vyasan Nelliparmbil <vi...@MUN.GOV.BH>.
Can anybody help me on this issue?
-----Original Message-----
From: Vishnu Vyasan Nelliparmbil [mailto:vishnu@MUN.GOV.BH]
Sent: 20 June 2009 13:21
To: Struts Users Mailing List
Subject: RE: Doubt with using check box
Pawel , can you expalin with a example. I am totally new to struts.
I tried with another way.
Ie by adding a 'selected' field to the EmployeeBean.
<logic:iterate id="EmployeeBean" name="EMPLOYEE" scope="session">
<tr>
<td> <bean:write name=" EmployeeBean" property="employee_name" /></td>
<td> <bean:write name=" EmployeeBean" property="employee_salary" /></td>
<td><html:checkbox name=" EmployeeBean" property="selected" onchange="checkEmployee();" > </html:checkbox>
<tr>
</logic:iterate>
Now I am getting the values of selected as false in the Action. Even though I have selected it.
I am using a action form for the some other elements in the same view.
Could you guys can through some light on how to make this work?
Regards
Vishnu
-----Original Message-----
From: Paweł Wielgus [mailto:poulwiel@gmail.com]
Sent: 20 June 2009 10:40
To: Struts Users Mailing List
Subject: Re: Doubt with using check box
Hi Vishnu,
on the html page you will have a list of checkboxes with the same name
"selectedEmployees" and a value of an employee identificator. In the
action create settet setSelectedEmloyees(String[] selectedEmployees),
then in execute You can access this table of employee identificators.
Just as a side note, i don't know what type of is your employee
identificator, so i proposed String, but it can also be long.
Best greetings,
Pawel Wielgus.
2009/6/20, Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
> Hi Friends,
>
> I am new to web development and struts. I have a simple question.
>
> I am using <logic:iterate> tag to iterate through a list of Employees
> and display their details.
> The list contains the Employee objects.
> Now while displaying Employee details in a table, the row is ending with
> a check box , so that the user can select employees. The check boxes are
> created dynamically since they are inside the iterate tag.
>
> Now how in Action I know that a specific employee is selected?
>
> In action form I would get whether the check box is selected or not. But
> how can I relate that to employees in list?
>
> Thanks in Advance
> vishnu
>
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Doubt with using check box
Posted by Paweł Wielgus <po...@gmail.com>.
Hi Vishnu,
in jsp add on every employee add such a checkbox
<logic:iterate name="employeeForm" property="employeeList" id="employee">
<html:multibox name="employeeForm" property="selectedEmployees">
<bean:write name="employee" property="login"/>
</html:multibox>
</logic:iterate>
and in EmployeeForm add field
private String[] selectedEmployees;
also don't forget to reset this field in reset method of that form.
Hope that helps,
Paweł Wielgus.
2009/6/20 Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
>
>
> Pawel , can you expalin with a example. I am totally new to struts.
>
> I tried with another way.
>
> Ie by adding a 'selected' field to the EmployeeBean.
>
> <logic:iterate id="EmployeeBean" name="EMPLOYEE" scope="session">
> <tr>
> <td> <bean:write name=" EmployeeBean" property="employee_name" /></td>
> <td> <bean:write name=" EmployeeBean" property="employee_salary" /></td>
> <td><html:checkbox name=" EmployeeBean" property="selected" onchange="checkEmployee();" > </html:checkbox>
> <tr>
> </logic:iterate>
>
> Now I am getting the values of selected as false in the Action. Even though I have selected it.
> I am using a action form for the some other elements in the same view.
>
> Could you guys can through some light on how to make this work?
>
>
> Regards
> Vishnu
>
>
>
> -----Original Message-----
> From: Paweł Wielgus [mailto:poulwiel@gmail.com]
> Sent: 20 June 2009 10:40
> To: Struts Users Mailing List
> Subject: Re: Doubt with using check box
>
> Hi Vishnu,
> on the html page you will have a list of checkboxes with the same name
> "selectedEmployees" and a value of an employee identificator. In the
> action create settet setSelectedEmloyees(String[] selectedEmployees),
> then in execute You can access this table of employee identificators.
> Just as a side note, i don't know what type of is your employee
> identificator, so i proposed String, but it can also be long.
>
> Best greetings,
> Pawel Wielgus.
>
> 2009/6/20, Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
>> Hi Friends,
>>
>> I am new to web development and struts. I have a simple question.
>>
>> I am using <logic:iterate> tag to iterate through a list of Employees
>> and display their details.
>> The list contains the Employee objects.
>> Now while displaying Employee details in a table, the row is ending with
>> a check box , so that the user can select employees. The check boxes are
>> created dynamically since they are inside the iterate tag.
>>
>> Now how in Action I know that a specific employee is selected?
>>
>> In action form I would get whether the check box is selected or not. But
>> how can I relate that to employees in list?
>>
>> Thanks in Advance
>> vishnu
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Doubt with using check box
Posted by Vishnu Vyasan Nelliparmbil <vi...@MUN.GOV.BH>.
Pawel , can you expalin with a example. I am totally new to struts.
I tried with another way.
Ie by adding a 'selected' field to the EmployeeBean.
<logic:iterate id="EmployeeBean" name="EMPLOYEE" scope="session">
<tr>
<td> <bean:write name=" EmployeeBean" property="employee_name" /></td>
<td> <bean:write name=" EmployeeBean" property="employee_salary" /></td>
<td><html:checkbox name=" EmployeeBean" property="selected" onchange="checkEmployee();" > </html:checkbox>
<tr>
</logic:iterate>
Now I am getting the values of selected as false in the Action. Even though I have selected it.
I am using a action form for the some other elements in the same view.
Could you guys can through some light on how to make this work?
Regards
Vishnu
-----Original Message-----
From: Paweł Wielgus [mailto:poulwiel@gmail.com]
Sent: 20 June 2009 10:40
To: Struts Users Mailing List
Subject: Re: Doubt with using check box
Hi Vishnu,
on the html page you will have a list of checkboxes with the same name
"selectedEmployees" and a value of an employee identificator. In the
action create settet setSelectedEmloyees(String[] selectedEmployees),
then in execute You can access this table of employee identificators.
Just as a side note, i don't know what type of is your employee
identificator, so i proposed String, but it can also be long.
Best greetings,
Pawel Wielgus.
2009/6/20, Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
> Hi Friends,
>
> I am new to web development and struts. I have a simple question.
>
> I am using <logic:iterate> tag to iterate through a list of Employees
> and display their details.
> The list contains the Employee objects.
> Now while displaying Employee details in a table, the row is ending with
> a check box , so that the user can select employees. The check boxes are
> created dynamically since they are inside the iterate tag.
>
> Now how in Action I know that a specific employee is selected?
>
> In action form I would get whether the check box is selected or not. But
> how can I relate that to employees in list?
>
> Thanks in Advance
> vishnu
>
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Doubt with using check box
Posted by Paweł Wielgus <po...@gmail.com>.
Hi Vishnu,
on the html page you will have a list of checkboxes with the same name
"selectedEmployees" and a value of an employee identificator. In the
action create settet setSelectedEmloyees(String[] selectedEmployees),
then in execute You can access this table of employee identificators.
Just as a side note, i don't know what type of is your employee
identificator, so i proposed String, but it can also be long.
Best greetings,
Pawel Wielgus.
2009/6/20, Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>:
> Hi Friends,
>
> I am new to web development and struts. I have a simple question.
>
> I am using <logic:iterate> tag to iterate through a list of Employees
> and display their details.
> The list contains the Employee objects.
> Now while displaying Employee details in a table, the row is ending with
> a check box , so that the user can select employees. The check boxes are
> created dynamically since they are inside the iterate tag.
>
> Now how in Action I know that a specific employee is selected?
>
> In action form I would get whether the check box is selected or not. But
> how can I relate that to employees in list?
>
> Thanks in Advance
> vishnu
>
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Doubt with using check box
Posted by Luis Ureña <lu...@gmail.com>.
Hi Vishnu
To do that, I use javaScript as follow:
First you must have an submit button with an event to fire that submit, like
this:
<html:button property="actualizar"
onclick="submitThis();">Update</html:button>
Second, you must write a javascript function that process the submit, like
this:
function submitThis()
var sectionSelected = 0;
try {
// this for determines wich radiobutton was selected
for (i=0; i < document.sectionListFrm.section.length; i++) {
if (document.sectionListFrm.section[i].checked) {
sectionSelected = document.sectionListFrm.section[i].value
break;
}
}
} catch (e) {
sectionSelected = 0;
}
document.sectionListFrm.section.value = sectionSelected;
As you can see, you must have a hidden form field to hold the
sectionSelected radio button.
Hope this help you,
Luis Ureña,
2009/6/19 Vishnu Vyasan Nelliparmbil <vi...@mun.gov.bh>
> Hi Friends,
>
> I am new to web development and struts. I have a simple question.
>
> I am using <logic:iterate> tag to iterate through a list of Employees
> and display their details.
> The list contains the Employee objects.
> Now while displaying Employee details in a table, the row is ending with
> a check box , so that the user can select employees. The check boxes are
> created dynamically since they are inside the iterate tag.
>
> Now how in Action I know that a specific employee is selected?
>
> In action form I would get whether the check box is selected or not. But
> how can I relate that to employees in list?
>
> Thanks in Advance
> vishnu
>
>
>
>
>
>
>
>
>
>
>
>