You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Reumann <ma...@reumann.net> on 2002/07/08 17:03:24 UTC

marking checkboxes checked from a List

I'm sure there is a good way to handle this in Struts but me being the
dumbass I thought I'd ask for help:

Picture a case where you display a list of "jobs" -
where next to each job name is a checkbox (Just using jobs for this
example). Each checkbox corresponding to the job will have a value
that is a String (jobAbbreviation). Displaying this list of jobs and
the value of the checkboxes isn't a problem ( populated from an
ArrayList of JobObjects ).

The problem is:

How do I mark the correct checkboxes based on an ArrayList of
Strings (jobAbbreivations)? In other words I have just a List of Strings
and I need to mark all the appropriate checkboxes that have the same
values as this List of abbreviations. ( I know an ugly way to do it
using java in the JSP page checking each value to see if it's in the
List but there must be a cleaner way ).

Thanks so much for any help.

-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: marking checkboxes checked from a List

Posted by Rahul Kumar Saxena <ra...@wipro.com>.
Inside JobObjects bean, add one attribute for checking if this job is
checked, say selectedFlag (Not a good name). Set the value of
selectedFlag to true for all the JobObjects which you want to show as
selected.This you can do in the action class which forwards to this JSP.
While creating the checkboxes, first check if selectedFlag for that
JobObjects is true then display the checkbox as selected.This can be
done using logic:equal tag.

*********************************************************
RAHUL K. SAXENA
Sr. Systems Engineer,
Wipro Technologies,
Ground Floor, Tower II,
72, Electronic City,
Hosur Main Road,
Bangalore-561 229, India.
Ph: 91-80-8520408/416(x-2026)
*********************************************************

-----Original Message-----
From: Rick Reumann [mailto:maillist@reumann.net] 
Sent: Monday, July 08, 2002 8:33 PM
To: Struts List
Cc: struts-atlanta@yahoogroups.com
Subject: marking checkboxes checked from a List


I'm sure there is a good way to handle this in Struts but me being the
dumbass I thought I'd ask for help:

Picture a case where you display a list of "jobs" -
where next to each job name is a checkbox (Just using jobs for this
example). Each checkbox corresponding to the job will have a value that
is a String (jobAbbreviation). Displaying this list of jobs and the
value of the checkboxes isn't a problem ( populated from an ArrayList of
JobObjects ).

The problem is:

How do I mark the correct checkboxes based on an ArrayList of Strings
(jobAbbreivations)? In other words I have just a List of Strings and I
need to mark all the appropriate checkboxes that have the same values as
this List of abbreviations. ( I know an ugly way to do it using java in
the JSP page checking each value to see if it's in the List but there
must be a cleaner way ).

Thanks so much for any help.

-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>