[TYPO3-mvc] [Extbase] Calling errorAction() from other action

Claus Fassing claus at fassing.eu
Thu Sep 16 13:10:32 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 16.09.2010 11:37, schrieb Franz Koch:
> Hey,
> 
>> I check in the createAction the filesize from an uploaded file against
>> max. allowed filesize from TS settings.
>> If this failed I set a message
>> $this->flashMessageContainer->add('Wrong filesize !');
>> and call errorAction().
>> This is working, the view is recalling, but the message don't appear.
>>
>> Can I call errorAction() from other action and throwing a message ?
> 
> how do you call it? Do you redirect or forward? I noticed that extbase
> is not persisting flashMessages when redirecting (or something like that
> - can't remember exactly, but also had such a issue once).
> 

Hello Franz,

I just call
$this->errorAction();
and errorAction() itself use a forward.

I change it now to
$filesizeErrorMessage = 'The uploaded file is to large ! Allowed
filesize : ' . $settingsize . 'MB';
$filesizeError = new
Tx_Extbase_MVC_Controller_ArgumentError($filesizeErrorMessage, 1284476850);
$this->propertyMapper->getMappingResults()->addError($filesizeError,
'newOffer');
$this->errorAction();

Then, errorAction() is recall the previous action. There I put this :
$errors = $this->request->getErrors();
if($errors){
  foreach ($errors as $error){
$this->flashMessages->add($error->getPropertyName());
  }
}

This will prompt the error message. I'm not sure if this is the right
way at all. I guess it is better to use any Validator anyway.

I have some more experience. I set up a Validator class for the
aggregate root. I get the TS settings from $GLOBALS and can now check
the filesize. This work fine, except the message again.
If the check fail I used this to set the message
$this->addError('The uploaded file is to large !', 1284476850);
But this message do not appear, maybe I have to bind it on the right
field. I don't know. I only get as message the attribute name of my object.

Regards Claus


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMkfsnAAoJELsIv+audObfUe0H/R15K/h3v7sNVBX5Ua+++hmJ
Ga1T7nGvEIEE6sdHw6f0FT/M7NeuynaYycpT2qqNRZfrFvh9Eyirbzaw1+v+picp
ogVyEybhD8s5KmDtStZ1/bfUMTSYQ7gY/Y0OpQ19tCXNrcK3AAiI5Z1rTh4srHxI
9Sw37TvEXO/35mOOKNVORnR+laShxEdbz56fnSGYNM0wTMIJN2Km7MU8sdqABte1
vTIddzs4SLWA7ERXXyAS321FznzpQZku3L5TqsKumS4RnnNFJKllK/N94tAmIrLT
NUQ4aWJJmbaDMDe03RK+Tlk13f78b8biW1c+D9vw7hUQP4dCd1Eyp2WCbh4Wp7s=
=e+R7
-----END PGP SIGNATURE-----


More information about the TYPO3-project-typo3v4mvc mailing list