action

一步步编写简单的PHP的Framework(五)

允我心安 提交于 2019-12-10 16:28:42
上一次我讲到使用自动导入可以实现一个类的延迟加载,这一次我想讲一下配置文件。 不知道大家注意了没有,前几篇文章我都没有涉及到配置文件,可是在一个项目中,配置文件又是比不可少的。 现在假设将Route.php中的默认控制器和Action变为可配置的,怎么弄呢? 我们使用最简单的方式: <?php $defaultController = 'Index'; $defaultAction = 'index'; 然后在Route.php中include这个文件: <?php include APP_PATH . '/config.php'; $controller = empty($_GET['c']) ? $defaultController : trim($_GET['c']); //设置了默认的控制器 $action = empty($_GET['a']) ? $defaultAction : trim($_GET['a']); //设置了默认的Action 当然也可以使用这种方式: <?php return array( 'defaultController' => 'Index', 'defaultAction' => 'index' ); 还是在Route.php中include: <?php $config = include APP_PATH . '/config.php'

Java - JButton text disappears if actionPerformed defined afterwards

北城以北 提交于 2019-12-10 15:27:15
问题 This has been bugging me for a while. If I define setText on a JButton before defining setAction , the text disappears: JButton test = new JButton(); test.setText("test"); // Before - disappears! test.setAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { // do something } }); this.add(test); If it's after , no problems. JButton test = new JButton(); test.setAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { // do something } }); test.setText(

redux的原理及简单实现

…衆ロ難τιáo~ 提交于 2019-12-10 13:35:53
1、redux 抛开react,如果只是仅仅使用redux,就像如下示例: const initialState = { name: 'Jack', age: 27, gender: 'boy' }; function reducer(state = initialState, action) { switch(action.type) { case 'add': return { ...state, age: state.age + 1 }; default: return state; } } const store = createStore(reducer); store.subscribe(function() { console.log(store.getState()); }); store.dispatch({ type: 'add' }); 这里其实就是一个createStore函数,返回了dispatch、subscribe、getState这三个方法,如下就是redux的简单实现: function createStore(reducer, enhancer) { // createStore(reducer, applyMiddleware(thunk)); if (enhancer) { return enhancer(createStore)

Any way to exit outer function from within inner function?

前提是你 提交于 2019-12-10 13:22:21
问题 Within PHP, if I have one function that calls another function; is there any way to get the called function to exit out of the caller function without killing the entire script? For instance, let's say I have some code something like: <?php function funcA() { funcB(); echo 'Hello, we finished funcB'; } function funcB() { echo 'This is funcB'; } ?> <p>This is some text. After this text, I'm going to call funcA.</p> <p><?php funcA(); ?></p> <p>This is more text after funcA ran.</p>

Pls add captcha field to this DotNetNuke form and send results to email

只愿长相守 提交于 2019-12-10 12:35:48
问题 I have this form which I need the resulting data entered by user to be sent to my email address. But this form should work in DotNetNuke . I understand there's some kind of action that is missing here so please help. Also can please help me add the Captcha field before the user click on 'Send button'? Also pls help me make All field required to be entered by user so to be sure the user enters all information. I think that is all. Pls ask if you need clarification thanks </div> <ul > <li id=

Is it possible in playframework to override the default save action in the CRUD controller and redirect to list after

旧时模样 提交于 2019-12-10 10:57:46
问题 I'm using Play framework's great crud module. The thing is I would like to do some special processing and validation before my object gets saved. So I created a save action in my CRUD controller. So far so good. But now after the object is saved I would like to render the list of objects just like the CRUD module was doing before I overrode its save action. How would I go about doing this? Here is my controller: package controllers.admin; import java.util.List; import models.Category; import

Rails calling action from view

早过忘川 提交于 2019-12-10 10:14:02
问题 Hopefully have a simple question here but I cannot for the life of me seem to find the answer. Just started working with RoR but came from ASP MVC before. I am having an issue rendering partial views whose local variables are not necessarily tied to the variables of the main view. For instance, with a blog I am trying to render a sidebar that will link to the archive. def sidebar @blog_posts = Blog.all(:select => "created_at") @post_months = @blog_posts.group_by { |m| m.created_at.beginning

Closure actions should be defined on controller

让人想犯罪 __ 提交于 2019-12-10 09:26:53
问题 Ember 1.13.10 I wanted to try out the closure actions, so I defined the a route: import Ember from 'ember'; export default Ember.Route.extend({ actions: { doSave() { ... } } }); and the template: {{my-component onSave=(action 'doSave')}} But I get the error message: An action named 'doSave' was not found in (generated test.index controller). However it is defined on the route. Given the fact that Controllers are kind of deprecated in Ember I would expect that the action should be defined on

Dynamic JSF (2.0) commandButtons - set action with arguments

做~自己de王妃 提交于 2019-12-10 04:17:14
问题 I'm trying to add JSF <h:commandButtons> dynamically to my webpage, and so far I have them displaying, but I cannot set the action with parameters, like I could in a static page: action="#{bean.function(parameter)}" . (this is of course using EL-2.2) Looking around I find that I have to create a MethodExpression , but this is obscure to me and I haven't been able to find much information on this. If someone could shine a light through the fog and explain how this can be done, it would be

How to know that tableView started scrolling

半世苍凉 提交于 2019-12-10 03:12:37
问题 I have a doubt: is there any way to intercept a tableView scrolling to add it an action? For example my prototype cell background is red, touching up inside a cell its background color begin blue and scrolling the tableView background color return red. Is it possible to do this?! Thanks in advance. 回答1: UITableView inherits from UIScrollView and UITableViewDelegate extends UIScrollViewDelegate. Particularly you may be interested in scrollViewDidScroll method. So, in your UITableViewDelegate