Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

Let me know if I can help

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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.082 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started