For example the delete-link was clicked twice or from different users. While the first click will correctly remove my object the second one will fail (as it is outdated) before my deleteAction is Called. How can I prevent this?
/**
* action delete
*
* @param $upload
* @dontvalidate $upload
* @return void
*/
public function deleteAction(Tx_MyExt_Domain_Model_Upload $upload) {
$this->uploadRepository->remove($upload);
$this->flashMessageContainer->add('Your Upload was removed.');
$this->redirect('list');
}
I get an Exception:
The value must be of type “Tx_MyExt_Domain_Model_Download”, but was of type “NULL”.
Doing something inside the action doesn’t help, because it fails before…
I’m assuming you have some fluid markup that looks like:
Which says: pass the
uploadObjectToDeleteobject to the delete action when the user clicks on this link. And when the user clicks on that link the ExtBasePropertyMapperuses the arguments sent with the link to locate theuploadObjectToDeletein the database to hand it off to your controller and the delete action.After the first click, that delete action successfully deletes the object from the database and the page is reloaded when you redirect to the list action. However, this time the
uploadObjectToDeleteobject is null. So, for the second click, when thePropertyMappertries to locate anuploadargument for the delete action there is no object to look for. And since theuploadargument is required (i.e. can’t benull), you get an exception.Option 1
Change your list action so that it doesn’t show these links when the
uploadObjectToDeleteobject isnull. This is probably the best option.Option 2
Change your delete action to accept
nullarguments:But this option doesn’t make sense. Why would you allow your user to try and delete an object that is already null?
These are just suggestions.