You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ramachandran <ra...@summitworks.com> on 2004/02/02 10:38:00 UTC

Getting the CheckBox Collection Value in FormBean Class

Hi All,

             If any body know how to get the solution for getting the check
box collection value in the form bean class. If so mail your ideas.......

Thanx,
Ram


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


Re: Getting the CheckBox Collection Value in FormBean Class

Posted by Claire Wall <cl...@kurtosys.com>.
What is 'allreqcand'? I'm assuming that this is the name of your form bean.

When the form is submitted, whatever is the value of the check box will be
stored in the array (and only the checked ones will be submitted). So in the
example you gave, the values that will be stored in the array will be the
string 'check', which isnt very helpful. You should be able to determine
which boxes were checked by iterating through the array in your action like
so:

for(int i = 0; i < myform.getDeletereqs().length; i++)
{
    //log the values of the checkboxes so you can see if its working.
}

the most important thing first is to check that something is being submitted
to the array when boxes are selected. If you log the values to the log file
by looping through the array in your action then you can see what's going
on. The next step is to get something useful to be submitted to the array
(values of the checkboxes).




----- Original Message -----
From: "Ramachandran" <ra...@summitworks.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 02, 2004 10:11 AM
Subject: RE: Getting the CheckBox Collection Value in FormBean Class


> Yes Claire,
>                 I am doing like that only.This is my jsp,contains the
code.
> I am nested inside the iteration.
>
>
> FORM BEAN
> public String[] getDeletereqs() {
>         return this.deletereqs;
>     }
>
> public void setDeletereqs(String[] deletereqs) {
>         this.deletereqs=deletereqs;
>     }
>
> JSP
> <logic:iterate id="allrc" name="allreqcand">
>      <tr align="left">
>         <td>
>             <html:checkbox  name="allrc" property="deletereqs"
value="check"
> />
>         </td>
>       </tr>
> </logic:iterate>
>
> Then in the action, i want to check what r all the check boxes checked.
How
> can i do that one.
> Shall i use the request.getParametervalues();
>
>       Any othet option u know, how to perform in action.
>
> Mail your opinion.
>
>
>
>
> -----Original Message-----
> From: Claire Wall [mailto:claire.wall@kurtosys.com]
> Sent: Monday, February 02, 2004 3:21 PM
> To: Struts Users Mailing List
> Subject: Re: Getting the CheckBox Collection Value in FormBean Class
>
>
> Do you mean that you want to store checkbox values in a form bean? if
so...
>
>
> You can set up an empty String array in your form bean like this:
> String[] checkboxes = new String[]{};
>
>
> and then in your jsp page you can set the property of a checkbox to this
> array, like:
>
> <html:checkbox name="FormName" property="checkboxes" value="???"/>
>
>
> when the page is submitted, the checked box values are stored in the
array -
> you can then use them how you wish in your action. Note though that you
have
> to set the value of the checkbox if you are going to have anything
submitted
> to the array in the form.
>
>
> HTH
> claire :)
>
>
> ----- Original Message -----
> From: "Ramachandran" <ra...@summitworks.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, February 02, 2004 9:38 AM
> Subject: Getting the CheckBox Collection Value in FormBean Class
>
>
> > Hi All,
> >
> >              If any body know how to get the solution for getting the
> check
> > box collection value in the form bean class. If so mail your
ideas.......
> >
> > Thanx,
> > Ram
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
> ---------------------------------------------------------------------
> 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


CheckBox Collection Value in FormBean Class

Posted by Ramachandran <ra...@summitworks.com>.
Hi All,

             I am having list of check boxes in a page. My Scenario is, if i
checked a check box, then if i click the submit button, it should delete.
Then how can i relate the check box selection to the record which is to be
deleted....

       I am listing the records in JSP using logic:iterate. Inside the
iteration for dsipalying check boxes, i inserted <td><html:checkbox name=""
value="" property=""/>
       But how can i relate selection with the records to be deleted

Like what we done in yahoo and rediff...

Check Box        Req Id  Company Name   Contact Name
			1		x		y
			2		h		g





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


RE: Getting the CheckBox Collection Value in FormBean Class

Posted by Mohan Radhakrishnan <mr...@cellexchange.com>.
Ramachandran,

             The following is what we use. Read html:multibox doc.


			    <logic:iterate id="item" property="deletereqs" name="form">
				<tr  bgcolor="#EEF1F7" class="text_bold" height="20">
					<td>
						<html:multibox property="selectedDeletereqs">
							<bean:write name="item"/>
						</html:multibox>
					</td>
					<td>
						<bean:write name="item"/>
					</td>
				</tr>
			    </logic:iterate>

	In your form.

	private String[] selectedDeletereqs;

	private String[] deletereqs;

	public String[] getDeletereqs() {
	        return this.deletereqs;
	}

	public void setDeletereqs(String[] deletereqs) {
	        this.deletereqs=deletereqs;
	}

	public String[] getSelectedDeletereqs() {
	  return this.selectedDeletereqs;
	}

	public void setSelectedDeletereqs(String[] selectedDeletereqs) {
	  this.selectedDeletereqs= selectedDeletereqs;
	}

Mohan
-----Original Message-----
From: Ramachandran [mailto:ramachandran@summitworks.com]
Sent: Monday, February 02, 2004 3:42 PM
To: Struts Users Mailing List
Subject: RE: Getting the CheckBox Collection Value in FormBean Class


Yes Claire,
                I am doing like that only.This is my jsp,contains the code.
I am nested inside the iteration.


FORM BEAN
public String[] getDeletereqs() {
        return this.deletereqs;
    }

public void setDeletereqs(String[] deletereqs) {
        this.deletereqs=deletereqs;
    }

JSP
<logic:iterate id="allrc" name="allreqcand">
     	<tr align="left">
        <td>
            <html:checkbox  name="allrc" property="deletereqs" value="check"
/>
        </td>
      </tr>
</logic:iterate>

Then in the action, i want to check what r all the check boxes checked. How
can i do that one.
Shall i use the request.getParametervalues();

      Any othet option u know, how to perform in action.

Mail your opinion.




-----Original Message-----
From: Claire Wall [mailto:claire.wall@kurtosys.com]
Sent: Monday, February 02, 2004 3:21 PM
To: Struts Users Mailing List
Subject: Re: Getting the CheckBox Collection Value in FormBean Class


Do you mean that you want to store checkbox values in a form bean? if so...


You can set up an empty String array in your form bean like this:
String[] checkboxes = new String[]{};


and then in your jsp page you can set the property of a checkbox to this
array, like:

<html:checkbox name="FormName" property="checkboxes" value="???"/>


when the page is submitted, the checked box values are stored in the array -
you can then use them how you wish in your action. Note though that you have
to set the value of the checkbox if you are going to have anything submitted
to the array in the form.


HTH
claire :)


----- Original Message -----
From: "Ramachandran" <ra...@summitworks.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 02, 2004 9:38 AM
Subject: Getting the CheckBox Collection Value in FormBean Class


> Hi All,
>
>              If any body know how to get the solution for getting the
check
> box collection value in the form bean class. If so mail your ideas.......
>
> Thanx,
> Ram
>
>
> ---------------------------------------------------------------------
> 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



---------------------------------------------------------------------
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


RE: Getting the CheckBox Collection Value in FormBean Class

Posted by Ramachandran <ra...@summitworks.com>.
Yes Claire,
                I am doing like that only.This is my jsp,contains the code.
I am nested inside the iteration.


FORM BEAN
public String[] getDeletereqs() {
        return this.deletereqs;
    }

public void setDeletereqs(String[] deletereqs) {
        this.deletereqs=deletereqs;
    }

JSP
<logic:iterate id="allrc" name="allreqcand">
     	<tr align="left">
        <td>
            <html:checkbox  name="allrc" property="deletereqs" value="check"
/>
        </td>
      </tr>
</logic:iterate>

Then in the action, i want to check what r all the check boxes checked. How
can i do that one.
Shall i use the request.getParametervalues();

      Any othet option u know, how to perform in action.

Mail your opinion.




-----Original Message-----
From: Claire Wall [mailto:claire.wall@kurtosys.com]
Sent: Monday, February 02, 2004 3:21 PM
To: Struts Users Mailing List
Subject: Re: Getting the CheckBox Collection Value in FormBean Class


Do you mean that you want to store checkbox values in a form bean? if so...


You can set up an empty String array in your form bean like this:
String[] checkboxes = new String[]{};


and then in your jsp page you can set the property of a checkbox to this
array, like:

<html:checkbox name="FormName" property="checkboxes" value="???"/>


when the page is submitted, the checked box values are stored in the array -
you can then use them how you wish in your action. Note though that you have
to set the value of the checkbox if you are going to have anything submitted
to the array in the form.


HTH
claire :)


----- Original Message -----
From: "Ramachandran" <ra...@summitworks.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 02, 2004 9:38 AM
Subject: Getting the CheckBox Collection Value in FormBean Class


> Hi All,
>
>              If any body know how to get the solution for getting the
check
> box collection value in the form bean class. If so mail your ideas.......
>
> Thanx,
> Ram
>
>
> ---------------------------------------------------------------------
> 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



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


Re: Getting the CheckBox Collection Value in FormBean Class

Posted by Claire Wall <cl...@kurtosys.com>.
Do you mean that you want to store checkbox values in a form bean? if so...


You can set up an empty String array in your form bean like this:
String[] checkboxes = new String[]{};


and then in your jsp page you can set the property of a checkbox to this
array, like:

<html:checkbox name="FormName" property="checkboxes" value="???"/>


when the page is submitted, the checked box values are stored in the array -
you can then use them how you wish in your action. Note though that you have
to set the value of the checkbox if you are going to have anything submitted
to the array in the form.


HTH
claire :)


----- Original Message -----
From: "Ramachandran" <ra...@summitworks.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 02, 2004 9:38 AM
Subject: Getting the CheckBox Collection Value in FormBean Class


> Hi All,
>
>              If any body know how to get the solution for getting the
check
> box collection value in the form bean class. If so mail your ideas.......
>
> Thanx,
> Ram
>
>
> ---------------------------------------------------------------------
> 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