Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 16:39 #13248

  • msantana
  • msantana's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
CHEF PLEASE, Let me know if you need more information in order to fix the issue.

JCOOK is no longer generating the component correctly in any of the versions (2.65 or 2.7.1) in order to stay in the Item view after saving.

I did try to generate the component in both versions. I did not work neither in JCOOK component Sandbox nor the downloaded file.

Then I wondered why if I new It was working the first time we downloaded the component. Then I compared the latest version generated with JCOOK and the initial version that I knew it was working.

Bellow are my findings:
I notice some changes on the controller file that are generated.

First version where it was working:
public function add()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		$this->_result = $result = parent::add();
		$model = $this->getModel();

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'default.add':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(

			
				));
				break;

			case 'modal.add':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(

			
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				));
				break;
		}
	}

New downloaded version that DOES NOT WORK:
	public function add()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		$this->_result = $result = parent::add();
		$model = $this->getModel();

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'default.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null

				));
				break;

			case 'modal.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null

				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				));
				break;
		}
	}


Here you would see that each case has something missing.

Also the SAVE function is different:
First version where it was working:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
			}
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );

		$this->_result = $result;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'asset.apply':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(
					'cid[]' => $model->getState('asset.id')
				));
				break;

			case 'asset.save':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.save2new':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(
					'cid[]' => null
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				));
				break;
		}
	}


New downloaded version that DOES NOT WORK:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
			}
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );

		$this->_result = $result;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				));
				break;
		}
	}

Here you can see also a difference in each Case value:
Also the redirect is sending it to 'com_hastorageapp.assets.default' (sending it back to the Assets collection view) instead of keeping it on 'com_hastorageapp.asset.asset' (Item view)

Also since it is sending to to the Collection view it is removing the item id:
First version downloaded:
'cid[]' => $model->getState('asset.id')
Latest version NOT WORKING:
'cid[]' => null


Talk to you

Miguel Santana
MS - Lyquix
The administrator has disabled public write access.

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 17:10 #13249

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Yes, indeed I have rewrited here recently.

This redirector is a mess, I should rewrite it all.

Well I can see the tasks aliases are missing.
I will have a look.
Coding is now a piece of cake
The administrator has disabled public write access.

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 17:24 #13250

  • msantana
  • msantana's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
Let me know if I can help

Miguel Santana
ps: you know how to contact me directly or private if necesary
MS - Lyquix
The administrator has disabled public write access.
The following user(s) said Thank You: admin

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 10 Jun 2015 08:23 #13251

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Fixed.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.089 seconds

Get Started