How do I send back the randomly selected checkboxes values back to servlet

Hello All,
Assume I have a table of N rows with two columns. I will have one checkbox on column-1 and zero or more on column-2. Column-1 may represent categories and column-2 represents associated things. Just like below:
Column 1 Column 2
Books HFSJ EJB Hibernate
Foods Pizza Steak
Electronics Computers HDTV others
Now user can select EJB and Hibernate of first row, HDTV of the third row, and no value from second row and submit
Now I'm looking at adding EJB and Hibernate to a list and add that list to a map with Books as Key. In the same way HDTV to a list and Electronics as the Key.
I tried to accomplish the above thing with the below code, but I actually ended up with a Map with three keys, Books, Foods and Electronics and for each corresponding key, all the elements in the list.
</tr>
<% for(int i=0;i<suiteNames.size();i++){tempSuiteName=(String)suiteNames.get(i); %>
<tr>
<td width="400">
<input type="checkbox" onklick="toggle(this,'<%=tempSuiteName%>')"/><%=tempSuiteName%>
</td>
<td width="400" id="<%=tempSuiteName%>" style="visibility:hidden">
<%
tempMode=new TreeSet();
modeNames=(ArrayList)modeMap.get((String)suiteNames.get(i)); for(int j=0;j<modeNames.size();j++){
tempModeName=(String)modeNames.get(j);
%>
<input type="checkbox" name="<%=tempModeName%>" onklick="<%tempMode.add(tempModeName);%>" /><%=tempModeName%>
<%}tempMap.put(tempSuiteName,tempMode); %>
</td>
</span>
</tr>
<%}%>
</table>
<%
if(tempMap.size()!=0)
session.setAttribute("map",tempMap);
%>
Can some one tell me why this code is not working as intended.
My jsp code is bit cluttering with lot of java code and I know its a bad idea. My primary task is to get this work and later I can look in tweaking the code.

Javascript(client side) can not call your java code(serverside) directly
You are mixing up Java/JSP with javascript.
You need to understand the JSP lifecycle
1 - All Java/JSP code runs. Produces an HTML page.
2 - Java stops running
3 - Page gets loaded in browser - javscript starts running from client side events.
You have your onclick events trying to run java code. Thats not gonna happen.
Instead what you need to do is split this code into two pieces
1 - render the table
2 - read parameters coming from a request.
A bit better formatted, with the unnecessary bits taken out:
<table>
<% for(int i=0;i<suiteNames.size();i++){
  tempSuiteName=(String)suiteNames.get(i);
  %>
     <tr>
     <td width="400">
          <input type="checkbox" onklick="toggle(this,'<%=tempSuiteName%>')"/><%=tempSuiteName%>
     </td>
     <td width="400" id="<%=tempSuiteName%>" style="visibility:hidden">
     <%
     modeNames=(ArrayList)modeMap.get((String)suiteNames.get(i));
     for(int j=0;j<modeNames.size();j++){
          tempModeName=(String)modeNames.get(j);
          %>
          <input type="checkbox" name="<%=tempModeName%>"" /><%=tempModeName%>
          <%}%>
     </td>
     </span>
     </tr>
     <%}%>
</table>{code}
Even better using JSTL for loops instead of scriptlet code:
{code}
<c:forEach var="suite" items="${suiteList}">
  <tr>
     <td width="400">
          <input type="checkbox" onklick="toggle(this,'${suite}')"/>${suite}
     </td>
     <td width="400" id="<%=tempSuiteName%>" style="visibility:hidden">
        <c:forEach var="mode" items="${modeMap[suite]}">
            <input type="checkbox" name="${mode}">" />${mode}
     </c:forEach>
</td>
</c:forEach>And at the server end, something like this:
for(int i=0;i<suiteNames.size();i++){
   tempSuiteName=(String)suiteNames.get(i);
   modeNames=(ArrayList)modeMap.get((String)suiteNames.get(i));
    tempMode=new TreeSet();
   for(int j=0;j<modeNames.size();j++){
     tempModeName=(String)modeNames.get(j);
     if (request.getParameter(tempModeName) != null){
       tempMode.add(tempModeName)
   tempMap.put(tempSuiteName,tempMode);
}If a checkbox is clicked, when you submit the form it will come through as a name/value pair.
If it is not checked, that parameter won't be there.
A better approach just occured to me
Another approach would be use checkbox name=[column1] and value=[column2]
<c:forEach var="suite" items="${suiteList}">
  <tr>
     <td width="400">
          <input type="checkbox" onklick="toggle(this,'${suite}')"/>${suite}
     </td>
     <td width="400" id="<%=tempSuiteName%>" style="visibility:hidden">
        <c:forEach var="mode" items="${modeMap[suite]}">
            <input type="checkbox" name="${suite}" value="${mode}">" />${mode}
     </c:forEach>
</td>
</c:forEach>
{code}
Then at the server end:
{code}
for(int i=0;i<suiteNames.size();i++){
   tempSuiteName=(String)suiteNames.get(i);
String[] selectedModes =   request.getParameters("tempSuiteName");
   for(int j=0;j<selectedModes.size();j++){
     tempModeName=selectedModes[j];
     tempMode.add(tempModeName);    
   tempMap.put(tempSuiteName,tempMode);
{code}
Hope this helps some,
evnafets                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How do i send an email to addressee and receive back a confirmation that the addressee received my email?

    how do i send an email to addressee and receive back a confirmation that the addressee received my email?

    Even if you find a way to send the request for a read confirmation with the email, you are dependent on the recipient's mail system and/or mail reading software to notice it and comply with it. Many do not do so, either because they cannot or because somebody has disabled (or not enabled) the feature.

  • How do you turn off the auto select behavior when working with shape layers?

    How do you turn off the auto select behavior when working with shape layers?
    I am using either of the path selection tools to select only some of the paths on the layer. I have the proper layer targeted. I have the selection too auto select option turned off.
    If another layer has a path in that area, that layer becomes auto targeted and I get the wrong path. Turning off the layer is the only way to avoid this but then I have to  turn on the layer back on between making my selection and transforming to use the other layer as guide. Is there any way to stop this auto select? Locking the other layer does not stop the auto select, just prevents editing.

    As far as i know the move tool options don't have any effect on the path selection tools.
    You might try clicking on one of the path points or on the path itself with one of path selection tools and if you want to select multiple points
    you can shift click with the Direct Selection Tool or Alt click to select the entire path.
    more path shortcuts:
    http://help.adobe.com/en_US/photoshop/cs/using/WSDA7A5830-33A2-4fde-AD86-AD9873DF9FB7a.htm l
    http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7391a.h tml

  • How can I pre-define the default selection in a SelectOneChoice?

    How can I pre-define the default selection in a SelectOneChoice?
    (1) Here's my JSF-code:
    <af:selectOneChoice label="#{res['usercreate.input.sex']}"
    value="#{bindings.Sex.inputValue}"
    binding="#{SelectListBean.sexlist}"
    readOnly="false" autoSubmit="false">
    <af:selectItem label="#{res['data.sex.women']}" value="1"/>
    <af:selectItem label="#{res['data.sex.man']}" value="2"/>
    </af:selectOneChoice>
    (2): manged bean: to set the default value to be the first in the list, my managed bean as follows:
    import oracle.adf.view.faces.component.core.input.CoreSelectOneChoice;
    public class MBSListBean {
    private CoreSelectOneChoice sexlist;
    public MBSListBean() {
    public void setSexlist(CoreSelectOneChoice sexlist) {
    this.sexlist = sexlist;
    this.sexlist.setValue(1);
    public CoreSelectOneChoice getSexlist() {
    return sexlist;
    (3) when i launch the page, it often gives me such warnings:
    WARNUNG: Could not find selected item matching value "1" in CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=_id7]
    how to solve the problem ?
    Thanks,
    wzzdx

    You could also set the default on your entity or viewobject, in the properties of your attribute.

  • I want to back up my 4S but I don't get the correct screen when I plug it into my Mac - Just iPhotos and iTunes (songs) pop up. How do I get to the screen where I can back up and restore?

    I want to back up my 4S but I don't get the correct screen when I plug it into my Mac - Just iPhotos and iTunes (songs) pop up. How do I get to the screen where I can back up and restore?

    Hi Spookola,
    I don't know how that could have happened. Go through the folders for the rolls and separate the 2005 rolls from the 2006 rolls, then import the 2006 rolls.

  • How do i get all the music that i purchased back on my ipod touch 3rd generation?

    how do i get all the music that i purchased back on my ipod touch 3rd generation?

    Back from where?
    Where did it go?
    It should all be on your computer and included in your regular backup copy of your computer.
    Sync it back.

  • How do I get off the settings screen and get back to the iPad desktop?

    I am a first time user. How do I get off the settings screen and get back to the desktop?
    Thanks

    Press the home button.
    It's the button on the face of the device.

  • Hi friends i am update my iphone 4 i have back up file but how show to itunes enter the password to unlock iphone back up file plz help me i forget my iphone back passoword

    hi friends i am update my iphone 4 i have back up file but how show to itunes enter the password to unlock iphone back up file plz help me i forget my iphone back passoword

    Then you won't be able to use that backup. You might as well delete it and start over.

  • I can't go beyond release 3.6 because it slows my system down to a crawl. When I back the upgrade out and go back to 3.6 my system is fine. Any suggestions?

    I can't go beyond release 3.6 because it slows my system down to a crawl. When I back the upgrade out and go back to 3.6 my system is fine. Any suggestions?

    Does that PC meet Firefox 4.0+ system requirements for hardware? <br />
    Firefox 4.0+ versions are considerably different from earlier versions. <br />
    http://www.mozilla.com/en-US/firefox/6.0/system-requirements/
    * Pentium 4 or newer processor that supports SSE2
    * 512MB of RAM
    * 200MB of hard drive space

  • Errors when in Month view and how do I show (highlight) the day selected?

    There are some annoying 'bugs' in my ical. When I are working in month view and I select a day in that month to copy or enter an item to there is no indication that ical has that day selected. When I paste some data to that day thinking I have it selected it, it may be in the correct day or in the previously selected day - surely this is an oversight on Apples part or am I missing something here?
    Also sometimes after pasting data to the correct day iCal will 'update' and then send the data back to the day I copied it from!!
    Any help appreciated.
    MAC OS 10.9  on a Mac Mini.

    Hi,
    You don't need to convert to a string and back again to do that.  Use TRUNC to get the right day, and date arithmetic to get the right time, like this:
    UPDATE  fc_gq_source_analysis
    SET     effective_date = TRUNC (sample_date, 'MONTH')
                                 + (sample_date - TRUNC (sample_date))
    WHERE   sample_type  = 'C'
    TRUNC (sample_date, 'MONTH')        is midnight on the 1st of the month that you want.
    sample_date - TRUNC (sample_date)   is the time that you want, expressed as a number of days (e.g., 9/24 of a day).

  • How do I send only the sound track from iMovie to Media browser?

    I need some wild sound for an iMovie 09 project I'm working on in Garageband (working on the soundtrack). I want to take some wild sound from a clip in iMovie and export it to the media browser so that I can use it in the project in Garageband. I detached the audio on the clip in iMovie and tried deleting the video, but it deletes the detached sound as well.
    Any tips, tricks, or solutions on sending just the sound from iMovie to the media browser would be much appreicated.
    thanks

    With the project open, from iMovie's menu select "Share > Export using QuickTime". For the Export option select "Sound to AIFF". Give it a name and select your Save location. As far as I know, you can't save to the Media Browser as this is contained in the project's package contents folder. So save it to a convenient location (such as your Desktop) and navigate to this from GarageBand. It's probably best if you firstly move the file to, say, your Music folder or iTunes before using it in GarageBand. Otherwise, the links may be lost if you later move it from the Desktop (whereas you are less likely to move it from Music or iTunes).
    John

  • How To Add InfoObject in the Data Selection Tab of InfoPackages in 2004s

    Hi Y'all!
    I would like to ask how to add an infoobject in the Data Selection Tab of the InfoPackage in 2004s.  It says its optional, this definintion of selection criteria for the infopackage.
    My apologies, I don't understand how this is done.  Surely, I would like, however, to understand how to add an infoobject in this data selection Tab of the InfoPackage in 2004s.
    Can any kind soul out there (gurus) please lend me your thoughts?
    Regards,
    Philips

    Hello Rajani!
    Thank you very mcuh for that!  I super appreciate it!  Can you prescribe how I can do this step by step please?  Where exactly in the DS can I locate this "field for selection" option in the DataSource?
    Regards!
    Philips

  • How to get pics in the iphoto app for iphone back onto my macbook pro

    I need to know how to get my pics that are stored on iphone in the "iphoto app for iPhone" back onto my macbook pro's iphoto. macbook was recently wiped out (i didn't back up) during Genius Bar repair

    See this support article  http://support.apple.com/kb/HT4083
    The safest way would be to share all photos that are in iPhoto albums to the Camera Roll. When you connect the iPhone to your Mac and open iPhoto you can download the contents of the Camera Roll just like from any camera.

  • How do I access all the information that has been backed up on icloud?

    I backed up my informaiton to icloud.  My ipad is no longer working (due to an accident).  How to I access all the data I stored on icloud from my regular PC?

    Welcome to the Apple Community.
    You can't, backups are for restoring an iOS device.

  • How to get to know the current selected service?

    Can anyone tell me how to get the current selected service in MHP? I tried to find one but no result. Can javax.tv.media.MediaSelectControl.getCurrentSelection() gives me the answer?

    servicecontext.getService()

Maybe you are looking for

  • Updating apps cannot connect to i tunes store

    ive had my i pad 2 since the release date and just latelly when prompted to update an app it tells me connot conect to itunes store, ive read alot online about different fixes, date, time ect? is this just a case of itunes being weird at the moment i

  • Problem in using Bapisdorder_Getdetailedlist

    Hi All, I am using Bapisdorder_Getdetailedlist to display sales order details. I have written following code. Bapisdorder_Getdetailedlist_Input salesOrderInfo = new Bapisdorder_Getdetailedlist_Input(); wdContext.nodeBapisdorder_Getdetailedlist_Input(

  • Errors when redeeming a digital copy and trying to transfer to ipod

    I redeemed a digital copy of a movie from Itunes and every time I try to transfer it to my Ipod I get the error message "{name of movie] can not be copied to ipod because it can not be played on the Ipod." I even contacted Itunes about it and they to

  • Windows 8.1 is compatible with boot camp?

    Hi, Can I install windows 8.1 on a Mac Book Pro Early 2011 with Boot Camp? Thanks

  • Question on simple HFM consolidation rule

    Hi All, Could anyone please explain what does the two funtions below do and how they are linked to each other? These funtions are used in Sub Consolidate example in HFM Manual. dPCon = HS.Node.PCon("") - I know that this function gets the percent of