We have had this problem with Casper since his amputation. No going out for a long time, for the first week he was confined to a dog cage, now it has moved on to cage when there is no-one home and at night and has gone from access to only the kitchen to access inside the house but not outside. Occaisionally he attacks the catflap because its locked and he doesn't understand why he can't go out and play, but he was actually worse when it was kitchen only for wailing by the door to go into the hall.
Its a case of being cruel to be kind really, and he will use the tray, Casper was a toilet outside cat before and used it fine (although had some aiming problems, due to the sudden lack of one back leg!)