Joomla源代码解析(十九) JController
来源:互联网 发布:mac粘贴快捷键 编辑:程序博客网 时间:2024/05/16 08:34
同样 JController 是MVC中重要的起点,正式这个类决定的动作的下一步流向,我们来看看表格提交数据的典型的controller的代码:
function edit() { JRequest::setVar( 'view', 'hello' ); JRequest::setVar( 'layout', 'form' ); JRequest::setVar('hidemainmenu', 1); parent::display(); } /** * save a record (and redirect to main page) * @return void */ function save() { $model = $this->getModel('hello'); if ($model->store($post)) { $msg = JText::_( 'Greeting Saved!' ); } else { $msg = JText::_( 'Error Saving Greeting' ); } // Check the table in so it can be edited.... we are done with it anyway $link = 'index.php?option=com_hello'; $this->setRedirect($link, $msg); } /** * remove record(s) * @return void */ function remove() { $model = $this->getModel('hello'); if(!$model->delete()) { $msg = JText::_( 'Error: One or More Greetings Could not be Deleted' ); } else { $msg = JText::_( 'Greeting(s) Deleted' ); } $this->setRedirect( 'index.php?option=com_hello', $msg ); } /** * cancel editing a record * @return void */ function cancel() { $msg = JText::_( 'Operation Cancelled' ); $this->setRedirect( 'index.php?option=com_hello', $msg ); }
实际上 controller 跟提交的task参数,调用controller中的不同的函数,当然默认会调用display ,我觉得还需要记住的就是
getModel ,和setRedirect ,其余函数用到再看就可以了。
- Joomla源代码解析(十九) JController
- Joomla源代码解析(七) JFactory 类
- Joomla源代码解析(八) JDatabase 类
- Joomla源代码解析(九) JUser 类
- Joomla源代码解析(十一) JHtml 类
- Joomla源代码解析(十三) JText类
- Joomla源代码解析(十四) JRequest类
- Joomla源代码解析(十六) JTable是什么
- Joomla源代码解析(十七) JModel是什么
- Joomla源代码解析(十八) Jview
- joomla源代码探析续(二十九) JHTML 与JHTMLSelect 类的使用
- Joomla源代码解析(十) JPath JFile JFolder 类
- Joomla源代码解析(十二) JToolBarHelper JToolBar 类
- Joomla源代码解析(二十) MVC组件的执行
- Joomla源代码解析(二十二) 模块是如何被调用执行并渲染(下)
- Joomla源代码解析(六) JDocument 类的几个常用的方法
- Joomla源代码解析(十五) 组件是如何被调用并渲染的
- Joomla源代码解析(二十一) 模块是如何被调用执行并渲染?
- javaBean为什么要实现Serializable接口?
- windows xp sp3系统下载
- spring+ibatis 批处理
- spring配置文件中scope属性
- Spring下的Bean初始化和销毁两种方式
- Joomla源代码解析(十九) JController
- 谁是毁灭智能手机的掘墓者
- [转]暑期大学生博客分享大赛 - 2011 Android 成长篇
- Windows Phone开发之 Map控件
- spring 中属性scope 的prototype(有状态)和singleton(无状态)
- u-boot mkimage工具使用说明
- php中session的处理机制 (转)
- JUnit4 使用注解(元注释)进行测试
- activeMQ,spring的jmstemplate简单例子