Hi All,
I've been wasting my time on one issue pertaining to <html:multibox> tag.
I'm writing a code which should generate multiple checkboxes dynamically on
a JSP page. The JSP should send the checked checkboxes value to the Action
class. But it's not sending any values. I've tried many approaches like
1)initialized all the elements in the String[] to "" in the reset() method
2)tried retrieving the checked values using String[] codes=
request.getParameterValues("denyCodes");
None of the above methods worked for me. I'm using Weblogic 8.1 and Struts
1.2.8. I've tried with Struts 1.1 too. Here's my code.
-------------------
public class DenyForm extends ActionForm {
    private String[] denyCodes= new String[80];
    public String[] getDenyCodes(){
        return denyCodes;
    }
    public void setDenyCodes(String[] denycodes){
        this.denyCodes = denycodes;
    }
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        for(int i=0;i<80;i++){
            denyCodes[i] = "";
        }
    }
}
------------------------denycodes.jsp page is like this,
<html:form action="deny">
    <table>
        <tr align="center">    <html:submit /></tr>
        <logic:iterate name="denialCodes" id="code">
            <tr>
                <html:multibox  property="denyCodes" >
                    <bean:write name="code" />
                </html:multibox><bean:write name="code"/>
            </tr>
        </logic:iterate>
    </table><br>
</html:form>
---------------------------------------Action Class is
public class DenyAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws
Exception{

        HttpSession session = request.getSession();
        DenyForm denyForm = (DenyForm)form;
        String[] codes = denyForm.getDenyCodes();
//            String[] codes = request.getParameterValues("denyCodes");
         log.debug("codes array length is:"+codes.length);
        session.setAttribute("denyCodes",codes);
        return mapping.findForward("success");
    }
}
--------------------------------------------------struts-config.xml entry is
like this

     <form-bean name="denyForm" type="tars.form.DenyForm" />

        <action path="/deny" type="tars.action.DenyAction" name="denyForm">
            <forward name="success" path="/query.jsp" />
        </action>
------------------------------------------------------------------

codes.length is always returning 0 as the length. I've added some debug
statements in the ActionForm's set method to see whether it's being called
or not. To my surprise it was never called. That's what baffling me. This is
really urgent. I would really appreciate if someone  could help me out.

Thanks,
Tarun.

Reply via email to