Hi,

I'm having a problem using a checkboxlist to update a list in my model and can't find any example of using checkboxlist on the web. Displaying the checkboxes works fine, but not saving their values to the model. And I'm not exactly clear on how the checkboxlist does the conversion from string to my defined type. Project uses spring 2, hibernate and JPA:

@Entity
public class Recipient {
        private Long id;
        private List<Profile> profiles = new ArrayList<Profile>();

        public List<Profile> getProfiles() {
                return profiles;
        }
...
@Entity
public class Profile {
        private Long id;
        private String name;
        
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        public Long getId() {
                return id;
        }

...

public class RecipientAction extends BaseAction implements Preparable {
    private List<Profile> allProfiles;
    private Recipient recipient;
    private Long  id;

    public String save() throws Exception {
        boolean isNew = (recipient.getId() == null);
        recipientManager.save(recipient);

        String key = (isNew) ? "recipient.added" : "recipient.updated";
        saveMessage(getText(key));

        if (!isNew) {
            return INPUT;
        } else {
            return SUCCESS;
        }
    }
...

recipientForm.jsp:

<s:checkboxlist list="allProfiles" listKey="id" listValue="name" label="Profiles" name="recipient.profiles"/>

When executing recipientManager.save(recipient); the application throws the exception:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.corsaire.contactn.model.Profile.id
...
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class

Any ideas as to what's wrong? Do I need to provide an explicit conversion from Strings to List<Profile>?

regards,
Stephen



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

Reply via email to