You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Prashant Samant <Pr...@mphasis.com> on 2003/08/02 12:03:06 UTC

getting value of html:multibox

Hello everybody,
I want to get the value of the checkbox which i have clicked.
For that i am building the following JSP page
....
<html:form action="/returnsUpdateAction">
<html:multibox name="vTRReturnsUpdateForm" property="statusCheckBox" value="prashant"/>
<html:link action="returnsUpdateAction?statusId=1009">some image</html:link>
</html:form>

When i click the link, the framework calls the Action class(Shown below) but print blank on the console.
But if i use <html:submit>,than everything works fine.
How can i retrieve the value of checkbox by clicking on the link.

My struts confif file is as follows

<action path="/returnsUpdateAction" 
    	type="com.mphasis.mvtrproto.returns.VTRReturnsUpdateAction" 
    	name="vTRReturnsUpdateForm" 
    	scope="request">
    
    <forward   name="STATUSCHANGED" path="/changesReturnStatusSuccess.jsp" /> 
     <exception key="global.error.invalidLogin" path="/a.jsp" 
	scope="request" type="java.lang.SQLException"/>
    </action>
    
    
     <!-- For Acception and Rejecting Returns-->
       	<form-bean name="vTRReturnsUpdateForm" type="org.apache.struts.validator.DynaValidatorForm">
       	     <form-property name="statusCheckBox" type="java.lang.String[]" /> 
   	</form-bean>
   	
   	
   My Action class is as follows
   
   public class VTRReturnsUpdateAction extends Action
   {
   	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
   	{
   		try
   		{
   			String returnId[] = (String[])((DynaActionForm)form).get("statusCheckBox");
   			System.out.println("Value is "+returnId[0]);
   			
   			return mapping.findForward("STATUSCHANGED");
   		}
   		catch(Exception e)
   		{
   			e.printStackTrace();
   			throw e;
   		}
   
   	}
}

Best Regards,
Prashant S.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: getting value of html:multibox

Posted by Alex Shneyderman <al...@law.columbia.edu>.
If you are just linking, then you are not submitting your form, that
contains your checkbox. You need to rethikn your design. The only way
your checkbox vaulue gets to the server thru you submitting the form,
clicking the link does not do it, unless your link has some javascript
that goes something like:
   myForm.submit ();return false;

Alex.

> -----Original Message-----
> From: Prashant Samant [mailto:Prashant.Samant@mphasis.com]
> Sent: Saturday, August 02, 2003 6:03 AM
> To: Struts Users Mailing List (E-mail)
> Subject: getting value of html:multibox
> 
> Hello everybody,
> I want to get the value of the checkbox which i have clicked.
> For that i am building the following JSP page
> ....
> <html:form action="/returnsUpdateAction">
> <html:multibox name="vTRReturnsUpdateForm" property="statusCheckBox"
> value="prashant"/>
> <html:link action="returnsUpdateAction?statusId=1009">some
> image</html:link>
> </html:form>
> 
> When i click the link, the framework calls the Action class(Shown
below)
> but print blank on the console.
> But if i use <html:submit>,than everything works fine.
> How can i retrieve the value of checkbox by clicking on the link.
> 
> My struts confif file is as follows
> 
> <action path="/returnsUpdateAction"
>     	type="com.mphasis.mvtrproto.returns.VTRReturnsUpdateAction"
>     	name="vTRReturnsUpdateForm"
>     	scope="request">
> 
>     <forward   name="STATUSCHANGED"
path="/changesReturnStatusSuccess.jsp"
> />
>      <exception key="global.error.invalidLogin" path="/a.jsp"
> 	scope="request" type="java.lang.SQLException"/>
>     </action>
> 
> 
>      <!-- For Acception and Rejecting Returns-->
>        	<form-bean name="vTRReturnsUpdateForm"
> type="org.apache.struts.validator.DynaValidatorForm">
>        	     <form-property name="statusCheckBox"
> type="java.lang.String[]" />
>    	</form-bean>
> 
> 
>    My Action class is as follows
> 
>    public class VTRReturnsUpdateAction extends Action
>    {
>    	public ActionForward execute(ActionMapping mapping,ActionForm
> form,HttpServletRequest request,HttpServletResponse response)throws
> Exception
>    	{
>    		try
>    		{
>    			String returnId[] =
> (String[])((DynaActionForm)form).get("statusCheckBox");
>    			System.out.println("Value is "+returnId[0]);
> 
>    			return mapping.findForward("STATUSCHANGED");
>    		}
>    		catch(Exception e)
>    		{
>    			e.printStackTrace();
>    			throw e;
>    		}
> 
>    	}
> }
> 
> Best Regards,
> Prashant S.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org