click-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <>
Subject Re: "Wrong Number of Arguments" Error in Form.copyTo()
Date Sun, 19 Oct 2008 18:58:17 GMT
Hi Alvin,

Alvin Townsend wrote:
> java.lang.IllegalArgumentException: wrong number of arguments
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at
> 	at
> 	at
> 	at

This normally happens when an object is instantiated which does not have 
a default empty constructor.
When you specify a path for your field e.g. new 
TextField("address.price"), Form.copyTo will navigate the
object graph according to the path. Say you have the following:

  field = new TextField("address.price")

the copy logic will try and navigate to the Address from Client. But if 
Address is null on Client Click
attempts to create a new Address. But the only way this works is if 
Address has a default no arg constructor:

public class Address {
  public Address() {}

If your Address cannot have a no-arg constructor the best way to resolve 
this is to ensure your domain
objects are valid before invoking form.copyTo(). You could do this by 
overriding Form.copyTo:

public void onInit() {
    form.copyTo(client) {
        if (client.getAddress() == null) {

Does this help?

kind regards


View raw message