controller functions do not work correctly if overloaded?

3 views
Skip to first unread message

chris

unread,
Jul 21, 2012, 11:54:11 PM7/21/12
to ronin...@googlegroups.com
Hi:

It looks like the default URL handler doesn't find controller methods that are overloaded:

class AddressBook extends RoninController {
  @Methods({GET})
  function newContact() {
    views.Contact(new model.Person())
  }

 @Methods({POST})
  function newContact(contact : Person) {
    addressBook.addContact(contact)
    redirect(Contact#view(contact)
  }
}

Also the target function doesn't generate a URL that contains the function parameters:
using(target(AddressBook#newContact(Person))) {

Bug, missing feature or incorrect use?

Gus Prevas

unread,
Jul 22, 2012, 9:23:11 AM7/22/12
to ronin...@googlegroups.com
Working as intended; Ronin doesn't support overloaded controller functions.  For the example below, you can use the signature with the Person argument, and check if it's null (which means it wasn't passed in via the URL).  You can also check the HTTP method directly on the request object, which should be available to you via a property on the base RoninController class.

Carson Gross

unread,
Jul 22, 2012, 11:42:03 AM7/22/12
to ronin...@googlegroups.com
Note that you can also use default parameter values to avoid method overloading.  (Wouldn't help in this case, since the only default value reference types can have is null for the time being.)

Cheers,
Carson

Chris Gow

unread,
Jul 22, 2012, 2:02:19 PM7/22/12
to ronin...@googlegroups.com
Actually after some thought I think I can accomplish what I want with a custom URL handler. I believe the handler can get a reference to the request and from there I can get the request method and do the controller lookup myself
Reply all
Reply to author
Forward
0 new messages