action

Invoking Actions from Moq

北城余情 提交于 2020-01-01 06:43:13
问题 I've got a service with a method that takes two Action s, one for success and one for failure. Each Action takes a Result parameter that contains additional information... void AuthoriseUser(AuthDetails loginDetails, Action<AuthResult> onSuccess, Action<AuthResult> onFailure); I'm writing a unit test for a class that is dependant on that service, and I want to test that this class does the correct things in the onSuccess(...) and onFailure(...) callbacks. These are either private or anonymous

Struts 2 action variables not populated after interceptor's invocation.invoke()

假如想象 提交于 2020-01-01 05:36:06
问题 My Problem is that the action's variables are not being populated after it is triggered from the interceptor using invocation.invoke. What i know is that before using an interceptor , it worked properly (From a .jsp i submitted a form and an action is called and every variable was populated) Interceptor class: public String intercept(ActionInvocation invocation) throws Exception { final ActionContext context = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest

get current page url and change action

牧云@^-^@ 提交于 2020-01-01 05:07:08
问题 I need to give current page url and change action url. After that I want echo that in view file. I want do these in view file, not controller! Do you have any idea? 回答1: You can get current page url as follows: $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); // or using userAgent view helper: $uri = $this->userAgent()->getServerValue('request_uri'); The view helper $this->userAgent() returns an instance of Zend_Http_UserAgent that can provide you with many useful

get current page url and change action

﹥>﹥吖頭↗ 提交于 2020-01-01 05:07:05
问题 I need to give current page url and change action url. After that I want echo that in view file. I want do these in view file, not controller! Do you have any idea? 回答1: You can get current page url as follows: $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); // or using userAgent view helper: $uri = $this->userAgent()->getServerValue('request_uri'); The view helper $this->userAgent() returns an instance of Zend_Http_UserAgent that can provide you with many useful

the getSource() and getActionCommand()

不打扰是莪最后的温柔 提交于 2019-12-31 10:48:35
问题 What is getSource? and what does it return? and what is getActionCommand() and what does it return?? I am getting confused between these two can anyone give or differentiate them to me? what's the use of getSource and getActionCommand() in UI's? specifically TextField or JTextField? 回答1: Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component

the getSource() and getActionCommand()

随声附和 提交于 2019-12-31 10:48:12
问题 What is getSource? and what does it return? and what is getActionCommand() and what does it return?? I am getting confused between these two can anyone give or differentiate them to me? what's the use of getSource and getActionCommand() in UI's? specifically TextField or JTextField? 回答1: Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component

Struts2: how to store safety username and password from action to action

会有一股神秘感。 提交于 2019-12-31 05:05:13
问题 In my login page I log in through username and password (that I get from a jsp page), then I check LDAP and if the credentials are correct, then I continue the browsing to other pages. I would like to store somewhere username and password, because in some next pages, I may need them to make other stuff. I was thinking to store them in the session, but I'm scared that this can bring to security issue. Am I wrong? Maybe is it better to store them in the DB and query the DB the every times that

how to use allowhtml attribute for an action in mvc5

被刻印的时光 ゝ 提交于 2019-12-30 10:14:24
问题 I am developing an mvc 5 project and I want to use ckEditor for input data so in this editor I saved data after I could insert data but when dispalying it has an error See Imaage 回答1: You can apply AllowHtml attribute to the property which holds the markup in your view model class. public class CreatePost { public string PostTitle {set;get;} [AllowHtml] public string PostContent { set;get;} } And use this view model in your HttpPost action method and everything will work fine. [HttpPost]

Avoid “Use of unassigned local variable” error

怎甘沉沦 提交于 2019-12-30 10:08:20
问题 I have a two methods that are equivalent to this (pardon the contrived example): public void WithResource(Action<Resource> action) { using (var resource = GetResource()) { action(resource); } } public void Test() { int id; SomeObject someObject; WithResource((resource) => { id = 1; someObject = SomeClass.SomeStaticMethod(resource); }); Assert.IsNotNull(someObject); Assert.AreEqual(id, someObject.Id); } (There's some more logic in the WithResource call I'm trying to factor out.) I'm getting

Avoid “Use of unassigned local variable” error

99封情书 提交于 2019-12-30 10:07:09
问题 I have a two methods that are equivalent to this (pardon the contrived example): public void WithResource(Action<Resource> action) { using (var resource = GetResource()) { action(resource); } } public void Test() { int id; SomeObject someObject; WithResource((resource) => { id = 1; someObject = SomeClass.SomeStaticMethod(resource); }); Assert.IsNotNull(someObject); Assert.AreEqual(id, someObject.Id); } (There's some more logic in the WithResource call I'm trying to factor out.) I'm getting