Hi Ken-

struts.xml has this definition of EmployeeAction where results populate
editEmployee.jsp
        <action name="delete"
class="org.apache.struts2.showcase.action.EmployeeAction" method="delete">
            <result name="error">/empmanager/editEmployee.jsp</result>
            <result
type="redirect">edit-${currentEmployee.empId}.action</result>
        </action>

looking at the results jsp
/empmanager/editEmployee.jsp has a checkbox defined as
<s:checkbox fieldValue="true" label="Married"
name="currentEmployee.married"/>

The EmployeeAction is defined as
package org.apache.struts2.showcase.action;
public class EmployeeAction extends AbstractCRUDAction implements Preparable
{
 private Employee currentEmployee;

whereas Employee is defined as
package org.apache.struts2.showcase.model;
public class Employee implements IdEntity {
    private boolean married; //checkbox

so the individual checkbox works fine for setting booleans
http://struts.apache.org/2.0.11/docs/checkbox.html

For handling a list of checkboxes you may want to implement with
checkboxlist?
http://struts.apache.org/2.0.11/docs/checkboxlist.html

M--
----- Original Message -----
From: "Hoying, Ken" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Friday, November 30, 2007 8:45 AM
Subject: [S2] Checkboxes


I am having a difficult time getting checkboxes to work in the following
scenario and am not sure what I am doing wrong.  Any help or guidance
would be greatly appreciated.

I have table which displays several rows.  In the first column of each
row, I have a check box to select that row.  I am keeping track of user
selections so when they return to the page, the checkboxes are
prepopulated with their previous selections.


My Action contains the following:

public Long[] getSelectedContracts()
{
return setSelectedContracts.toArray(new Long[0]);
} // end getSelectedContracts

/**
* This setter takes the provided String[] of selected contract
ids.
*/
public void setSelectedContracts(Long[] palngSelectedContracts)
      {

setSelectedContracts.addAll(Arrays.asList(palngSelectedContracts));
} // end setSelectedContracts

My JSP contains the following:

<s:checkbox name="selectedContracts"
fieldValue="${contract.npcContractId}"/>






-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to