Hi,
Test1.jsp
<%@page import="java.sql.*"%> <%@taglib prefix="c" uri="/WEB-INF/c-rt.tld" %> <%@page import="java.util.HashMap"%> <%@page import="com.web.abc.integration.model.Domain"%> <%@page import="com.web.abc.integration.model.Category"%> <%@page import="com.web.abc.integration.dao.DomainDAO"%><head> </head> <body> <%! HashMap<Integer,Domain>domainmap; HashMap<Integer,Category>categorymap; DomainDAO bdao; Domain d;%> <% bdao=new DomainDAO(); bdao.getDBAcccess(); domainmap=bdao.getDomains(2); session.setAttribute("domainmap",domainmap); %> <div id="top1" style="width:500px;"> <form action="test2.jsp"> <table border="1"> <th>Table Containts</th> <c:forEach var="domain" items="${domainmap}"> <tr><td> <input type=checkbox name=selecteddomains value="${domain.value.domainName}"> <c:out value="${domain.value.domainName}" ></c:out> </td></tr> </c:forEach> </table> <input type="submit" value=">>"> </form> </div> <div id="top2"> <center> <table border=1 ><th>Total Selected Domains</th> <c:forEach var="domain" items="${domainlist}"> <tr><td> <input id="<c:out value="${domain.domainName}"/>" type=checkbox value="${domain.domainName}"> <c:out value="${domain.domainName}"></c:out> </td></tr> </c:forEach> </table> </center> </div> </body>
test2.jsp
<%@page import="java.sql.*"%> <%@taglib prefix="c" uri="/WEB-INF/c-rt.tld" %> <%@page import="java.util.HashMap"%> <%@page import="com.web.abc.integration.model.Domain"%> <%@page import="com.web.abc.integration.model.Category"%> <%@page import="com.web.abc.integration.dao.DomainDAO"%> <%@page import="java.util.ArrayList"%><head> </head> <body> <%! HashMap<Integer,Domain>domainmap; HashMap<Integer,Category>categorymap; DomainDAO bdao; Domain d; ArrayList<Domain>domainlist; %> <% bdao=new DomainDAO(); bdao.getDBAcccess(); domainmap=bdao.getDomains(2); session.setAttribute("domainmap",domainmap); String domainnames[]=request.getParameterValues("selecteddomains"); domainmap=(HashMap<Integer,Domain>)session.getAttribute("domainmap"); domainlist=(ArrayList<Domain>)session.getAttribute("domainlist"); if(domainlist==null){ domainlist=new ArrayList<Domain>(); } DomainDAO dDao=new DomainDAO(); dDao.setDomainmap(domainmap); for(String domainname:domainnames){ domainlist.add(dDao.getdomain(domainname)); //domainlist.remove(dDao.getdomain(domainname)); } session.setAttribute("domainlist",domainlist); %> <div id="top1" > <form action="test2.jsp"> <table border="1"> <th>Table Containts</th> <c:forEach var="domain" items="${domainmap}"> <tr><td> <input type=checkbox name=selecteddomains value="${domain.value.domainName}"> <c:out value="${domain.value.domainName}" ></c:out> </td></tr> </c:forEach> </table> <input type="submit" value=">>"> </form> </div> <div id="top2"> <center> <table border=1 ><th>Total Selected Domains</th> <c:forEach var="domain" items="${domainlist}"> <tr><td> <c:out value="${domain.domainName}"></c:out> </td></tr> </c:forEach> </table> </center> </div> </body>
My actual proble is as follows:
Above code is working, but i want some modifications in it. And i am not getting it.
when i click on some checkbox of table"Table Containts" and submit ">>" button, then in "Total Selected Domains" table , it is displaying checked checkboxes. But at same time , whatever the displaying in "Total selected Domains", only that checkboxes should be checked in "Table Containts" simultaneously., So basically i want to avoid duplicate selection of same checkboxes.
waiting for your reply.
Thank you for yor help in advance