Questions tagged [action]

An Action is a response of the program on occurrence detected by the program that may be handled by the program events.

Many languages and frameworks use this noun as synonym of function, without return value, where its main purpose is to do something.

For example the .NET delegate Action represents a function without parameters and return value.

In the Unified Modeling Language (UML), an action is a named element that is the fundamental unit of executable functionality. The execution of an action represents some transformation or processing in the modeled system. An action execution represents the run-time behavior of executing an action within a specific behavior execution.

4938 questions
79
votes
8 answers

Creating delegates manually vs using Action/Func delegates

Today I was thinking about declaring this: private delegate double ChangeListAction(string param1, int number); but why not use this: private Func ChangeListAction; or if ChangeListAction would have no return value I could…
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
73
votes
9 answers

How do you use Func<> and Action<> when designing applications?

All the examples I can find about Func<> and Action<> are simple as in the one below where you see how they technically work but I would like to see them used in examples where they solve problems that previously could not be solved or could be…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
69
votes
6 answers

Rails: Multi-submit buttons in one Form

Say I have an Article model, and in the article 'new' view I have two buttons, "Publish" and "Save Draft". My question is how can I know which button is clicked in the controller. I already have a solution but I think there must be a better…
kinopyo
  • 1,667
  • 3
  • 19
  • 26
68
votes
4 answers

Invoke JSF managed bean action on page load

Is there a way to execute a JSF managed bean action when a page is loaded? If that's relevant, I'm currently using JSF 1.2.
DD.
  • 21,498
  • 52
  • 157
  • 246
66
votes
5 answers

SignalR + posting a message to a Hub via an action method

I am using the hub- feature of SignalR (https://github.com/SignalR/SignalR) to publish messages to all subscribed clients: public class NewsFeedHub : Hub public void Send(string channel, string content) { …
ollifant
  • 8,576
  • 10
  • 35
  • 45
65
votes
3 answers

return new EmptyResult() VS return NULL

in ASP.NET MVC when my action will not return anything I use return new EmptyResult() or return null is there any difference?
Artur Keyan
  • 7,643
  • 12
  • 52
  • 65
60
votes
6 answers

Default action to execute when pressing enter in a form

I've got a jsf 1.2 form with two buttons and several input fields. The first button discards the entered values and repopulates the page with values from a db, the second button saves the entered values. The problem occurs when the user presses…
Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
55
votes
4 answers

How to connect menu click with action in Qt Creator?

I am completely new to Qt. I started with a new Qt4 GUI Application. Using the designer, I have created a menu like so: File - Exit How do I get an action associated with the menu item? I found something called the 'Signals and slots editor' but…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
54
votes
2 answers

ASP.Net MVC and state - how to keep state between requests

As a fairly experienced ASP.Net developer just recently starting using MVC, I find myself struggling a bit to change my mindset from a traditional "server control and event handler" way of doing things, into the more dynamic MVC way of things. I…
TMan
  • 1,305
  • 1
  • 13
  • 17
53
votes
5 answers

Can I use params in Action or Func delegates?

When I'm trying to use params in an Action delegate... private Action WriteToLogCallBack; I received this design time error: Invalid token 'params' in class, struct, or interface member declaration Any help!
Homam
  • 23,263
  • 32
  • 111
  • 187
51
votes
11 answers

Passing parameters on button action:@selector

I want to pass the movie url from my dynamically generated button to MediaPlayer: [button addTarget:self action:@selector(buttonPressed:) withObject:[speakers_mp4 objectAtIndex:[indexPath row]] forControlEvents:UIControlEventTouchUpInside]; but…
Pascal Bayer
  • 2,615
  • 8
  • 33
  • 51
49
votes
3 answers

HTML form action and onsubmit issues

I want to run JavaScript user validation on some textbox entries. The problem I'm having is that my form has the action of going to a new page within our site, and the onsubmit attribute never runs the JavaScript function. Is there a better…
James Brown
  • 919
  • 3
  • 13
  • 22
49
votes
4 answers

How do I use two submit buttons, and differentiate between which one was used to submit the form?

Currently, I have an HTML form where the user will enter a title and text for an article. When it is time to submit, they are presented with two buttons. One is to 'save' their article without publishing it, and the other is to 'publish' the article…
fvgs
  • 21,412
  • 9
  • 33
  • 48
48
votes
10 answers

How can I disable logging in Ruby on Rails on a per-action basis?

I have a Rails application that has an action invoked frequently enough to be inconvenient when I am developing, as it results in a lot of extra log output I don't care about. How can I get rails not to log anything (controller, action, parameters,…
archbishop
  • 1,077
  • 1
  • 10
  • 15
48
votes
3 answers

Using Cookie in Asp.Net Mvc 4

I have web application in Asp.Net MVC4 and I want to use cookie for user's login and logout. So my actions as follows: Login Action [HttpPost] public ActionResult Login(string username, string pass) { if (ModelState.IsValid) …
Elvin Mammadov
  • 25,329
  • 11
  • 40
  • 82