hi am a new joinee,
how to get values of selected checkboxes in a table?
please help me,
selected Lc code from UI, that LC code value should get into the table
plz help me out
this is my action class,

package webapp.control.nri;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
import java.util.ArrayList;
import java.util.List;

import webapp.model.user.LCMapping;
import webapp.model.user.User;

import webapp.config.WebConfig;
import webapp.manager.nri.PartnerManager;
import webapp.manager.user.UserManager;
import webapp.model.nri.Partners;
import webapp.util.Constants;
import webapp.util.WebAppValidator;

public class AddPartnerAction extends Action {

	private static final Log log = LogFactory.getLog(AddPartnerAction.class);

	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		DynaActionForm partnerForm = (DynaActionForm) form;
		
		// View partner details.
		String partnerIdStr = request.getParameter("view");
		String lcCode =  partnerForm.getString("lcCode");
		String code = partnerForm.getString("code");
		//lcCode = (String[]) partnerForm.get("LC Code");
		Integer partnerId = null;
		if(partnerIdStr != null && partnerIdStr.trim().length() > 0) {
			try {
				partnerId = Integer.valueOf(partnerIdStr);
				Partners partner = PartnerManager.getPartnerById(partnerId);
				//User user = UserManager.getUserListByLCCode(lcCode);
				partnerForm.set("partnerName",partner.getName());
				partnerForm.set("website",partner.getWebsite());
				partnerForm.set("contactPartsonName",partner.getConatctPaersonName());
				partnerForm.set("contactAddress",partner.getContactAddress());
				partnerForm.set("contactCountry",partner.getConatctAddressCountry());
				partnerForm.set("contactState",partner.getConatctAddressState());
				partnerForm.set("contactCity",partner.getConatctAddressCity());
				partnerForm.set("contactZipCode",partner.getConatctAddressZipCode());
				partnerForm.set("lgCode",partner.getLgCode());
				partnerForm.set("contactphoneCode",partner.getContactCode());
				partnerForm.set("contactPhoneNumber",partner.getConatctNumber());
				partnerForm.set("script",partner.getScript());
				partnerForm.set("link",partner.getLink());	
				
				//partnerForm.set("lcCode",user.getLcCode());
				
				
				
				return new ActionForward("/web/nri/addPartner.jsp");
			} catch (Exception e) {
				log.error("An error occured while saving partner data ::", e);
			}
			
		}
		
		
		// Add/update Partner details.
		Partners partner = new Partners();
		Partners checkPartner = null;
		boolean updateFlag = false;
		if(request.getParameter("submit") != null && request.getParameter("submit").trim().equalsIgnoreCase("Update")) {
			String idStr =  partnerForm.getString("idd");
			if(idStr != null && idStr.length() > 0) {
				Integer id = Integer.valueOf(idStr);
				partner = PartnerManager.getPartnerById(id);
				updateFlag = true;
			}			 
		}
		
		

		
		
		boolean validData = true;
		ActionMessages errors = new ActionMessages();
		
		String partnerName = partnerForm.getString("partnerName");
		if (partnerName == null || partnerName.trim().length() <= 0) {
			validData = false;
			errors.add("partnerName", new ActionMessage("Partner name can not be empty.", false));
		} else if(partnerName != null && partnerName.trim().length() > 30) {
			validData = false;
			errors.add("partnerName", new ActionMessage("Partner name can not more than 30 characters.", false));
		}
		
		String contactPartsonName = partnerForm.getString("contactPartsonName");
		if (contactPartsonName == null || contactPartsonName.length() <= 0) {
			validData = false;
			errors.add("contactPartsonName", new ActionMessage(" Contact Person  name can not be empty.", false));
		}
		String lgCode = partnerForm.getString("lgCode");
		if (lgCode == null || lgCode.length() <= 0) {
			validData = false;
			errors.add("lgCode", new ActionMessage(" LG Code can not be empty.", false));
		} else {
			
			// Adding partner first time
			if(!updateFlag) {
				checkPartner = PartnerManager.getPartnerByLgCode(lgCode);				
			} else if(updateFlag && !lgCode.equals(partner.getLgCode())) {
				// Updating Partner - Check iff lgcode is modified
				checkPartner = PartnerManager.getPartnerByLgCode(lgCode);
			}
			
			// IF partner is already exists for this lgcode
			if(checkPartner != null) {
				validData = false;
				errors.add("lgCode", new ActionMessage(" LG Code already exists.", false));
			}
			
		}
			
				if(lcCode != null) {
					validData = false;
					errors.add("lcCode", new ActionMessage("LC Code already exists.", false));
				}
				
			System.out.println("LC CODE : "+request.getParameterValues("lcCode"));

		String website = partnerForm.getString("website");
		if (website == null || website.length() <= 0) {
			validData = false;
			errors.add("website", new ActionMessage(" Website url can not be empty.", false));
		} else if (!website.matches(WebAppValidator.URL_PATTERN_RE)) {
			validData = false;
			errors.add("website", new ActionMessage(" Website url is an invalid url.", false));
		}
				

				
		// If data is valid
		if (validData) {
			try {
				String link = WebConfig.SERVERNAME + Constants.URL_NRI_ACCOUNT_OPEN + "?ptr=" + partnerForm.getString("lgCode").trim();
				partner.setName(partnerForm.getString("partnerName"));
				partner.setContactAddress(partnerForm.getString("contactAddress"));
				partner.setConatctAddressCountry(partnerForm.getString("contactCountry"));
				partner.setConatctAddressState(partnerForm.getString("contactState"));
				partner.setConatctAddressCity(partnerForm.getString("contactCity"));
				partner.setConatctAddressZipCode(partnerForm.getString("contactZipCode"));
				partner.setContactCode(partnerForm.getString("contactphoneCode"));
				partner.setConatctNumber(partnerForm.getString("contactPhoneNumber"));
				partner.setConatctPaersonName(partnerForm.getString("contactPartsonName"));
				partner.setLgCode(partnerForm.getString("lgCode"));
				partner.setWebsite(partnerForm.getString("website"));
				partner.setLink(link);
				partner.setScript(partnerForm.getString("script"));				
				if(request.getParameter("submit") != null && request.getParameter("submit").trim().equalsIgnoreCase("Update")) {					
					PartnerManager.updatePartner(partner);
				} else {
					partner.setNoOfLeads(0);
					PartnerManager.addPartner(partner);
				}				
			
				return new ActionForward(Constants.URL_PARTNERS);
			} catch (Exception e) {
				log.error("Error occured while save/updating Partner :: ", e);
				request.setAttribute("message", "Problem occured white adding partner.Please check all fields.");
			}
		} else {
			saveErrors(request, errors);			
			return new ActionForward("/web/nri/addPartner.jsp");
		}
	
		return mapping.findForward("addPartner");
	}
}

Hi there,

If I'm understanding you correctly. You can just use the 'getState()' method.
Like so:

yourCheckbox.getState();
//This will return a boolean value, i.e true or false

Hope this helped!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.