w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Trying to use simple authentication in Play Framework, but my action is called twice
Perhaps it's because you're using System.err to log, instead of the default logger in play? Regardless, for authentication, I'm using this module: https://github.com/joscha/play-authenticate

Categories : Java

Can I set cookies before returning an action in Play Framework 2?
I'm doing this only as exercise, and also to show that Play framework is very flexible and it doesn't limit you in any sense. I figured out how to do this purely from Play source code, it is very clean and easy to read. This is NOT the preferred way to work with cookies or indeed with HttpRequest object in Play. As Jatin suggested you should decode your cookies to proper models, pass those models to your services and then convert result of your services to play.api.mvc.Result, thus keeping your http and business logic layers separated. Here's the code( you can see that Headers object is not intended to be used this way): import play.api.http.HeaderNames.COOKIE val cookies = Cookies(request.headers.get(COOKIE)).cookies val myCookies = cookies + ("cookieName" -> Cookie("cookieName", "

Categories : Scala

Play Framework: Controller action runs every load
I would call routes-> /generateExcelReport from the button/link and make it return the file How to send a file to browser for downloading? How to download a file with Play Framework 2.0

Categories : Java

Play framework, call static assets from action
Found the solution, play has to be notified of a new assets folder (that will be packaged with the application). Add this in Project/Build.scala val main = play.Project(appName, appVersion, appDependencies).settings( playAssetsDirectories <+= baseDirectory / "name-of-new-assets-folder" )

Categories : Scala

Java + Play Framework 2 with nested action compositions in the same class
The only way I can see this working is to change the annotation, so you can provide (at class level) an optional list of methods to ignore or to be verified only by syntax (whichever suits better your application). In fact, it could be better to have 2 different annotations, one at class level and one at method level. Otherwise, I'm afraid it will always call the annotation twice, as it exists twice in the code.

Categories : Java

Instantiation of Play! Action - what language construction is that?
Your example is equivalent to this: val echo = Action.apply(request => Ok("Got request [" + request + "]")) So you're actually calling object Action's apply method and pass it an anonymous function. Be aware that in Scala, you can mostly interchange parentheses and braces, so e.g. if you have this function def f(a: Int) = a + 42 these calls are equivalent: f(23) f { 23 } The next thing that happens is that you can omit the name of the apply method. So if you have an object like this: object f { def apply(a: Int) = a + 42 } these calls are all equivalent: f.apply(23) f.apply { 23 } f(23) f { 23 } f apply 23 f apply { 23 }

Categories : Scala

IPAD : How to play video in fullscreen without User Action
Make sure the property mediaPlaybackRequiresUserAction of webview set to NO. adView.mediaPlaybackRequiresUserAction = NO; Check these links for more help Objective c - How to autoplay a youtube video in a UIWebView and Youtube video autoplay inside UIWebview

Categories : IOS

How to prevent rails from changing the path when the edit action is rendered from update action
The reason you were in /users/1 is the view is rendered by #update, not #edit. By default resource the path of #update is same as #show, with different request method GET and PUT. So, when #update renders HTML response, it's same as #show. I think the result is acceptable, no matter what path your are in the result is expected. As you already found, if using redirect, the @user instance will be changed to a branch new one thus losing errors and previous fillings. There is workaround on the path such as using session to pass instance variable, but I don't think it worth the effort. The current result is good enough. Add Manipulating active states is easy. I don't like current_page? which needs too much code. Use controller_path and action_name instead. if controller_path == 'users'

Categories : Ruby On Rails

Creating an action filter attribute that bypasses the actual execution of the action and returns a value for it
Yes, it is possible. You can set the result of the filter context provided to you when overriding OnActionExecuting in ActionFilterAttribute. using System.Web.Mvc; public sealed class SampleFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting( ActionExecutingContext filterContext ) { filterContext.Result = new RedirectResult( "http://google.com" ); } } In the source, you can see that setting the Result property of the filter context changes the flow. From System.Web.Mvc.ControllerActionInvoker: internal static ActionExecutedContext InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func<ActionExecutedContext> continuation) { filter.OnActionExecuting(preContext); if (preContext.Result != null)

Categories : Asp Net

Return partial view if action is ajax or child action universally
Well you're in luck because I wrote a TON of code to do something similar. This also takes into account if you want to return the model as a JSON object or a View. It also wraps all the Ajax calls into a wrapper response element Basically if you have a UI guy doing stuff, you NEVER need to know what he wants. Let him write the views, or make AJAX calls. This completely decouples the UI person from the C# developer (as long as he understands how to write MVC Views, he doesn't need to know at all how the controller works, just the model being passed). The ControllerBase class: public abstract class MyControllerBase : Controller { // could be moved to web.config private const _jsonDataType = "JsonDataType"; public bool IsAjaxRequest { get {

Categories : C#

How to get form submit button to do update action as opposed to create action
Generally you don't need template for edit form if nothing special. Just use create form and use form_for @instance. form_for will judge the instance and arrange form path automatically. If the instance is not persisted, it will point to #create. If the instance is a persisted object in db, it will point to #udpate automatically.

Categories : Ruby On Rails

How do I pass data from a controller action to child action in the layout template?
If you want to refer to it in the layout, you have to use ViewBag. But if you can refer to it directly in the view (could be in a section as well) you could simply have a model that would encapsulates the search query and the results. A shorten down example would like the following: public class SearchResponse { public List<SearchResults> Results { get; set; } public SearchQuery { get; set; } } public class SearchQuery{ public string Subject { get; set; } public string Location { get; set; } } So then, you would have stricly typed view of type SearchResponse EDIT In your case, I would simply call @Html.Action("Form", "Search", ViewBag.SearchQuery) and only set the ViewBag.SearchQuery into the Results(SearchFormViewModel searchModel) action, therefore passing in nu

Categories : C#

Defining different validations based on the action method which is called in a Struts2 action
In the action configuration via annotation you should use a parameter validateAnnotatedMethodOnly for validation interceptor, like in this example @Action(value="actionclassname", results = { @Result(name="input", location = "/actionclassname.jsp") },interceptorRefs = @InterceptorRef(value="defaultStack", params = {"validation.validateAnnotatedMethodOnly", "true"}))

Categories : Java

Invoking a service from runnable calls previous action before new action. How to prevent this?
I just copied and executed your code, and its working fine for me. I only added return START_NOT_STICKY; at the end of onStartCommand(). And here is my log: 08-01 11:09:33.840: I/MyService(1333): 0:BEGIN 08-01 11:09:33.840: I/MyService(1333): 0:RETRIEVE_SETTINGS_FROM_NET_SERVER 08-01 11:09:33.861: I/MyService(1333): 0:complete 08-01 11:09:34.051: I/MyService(1333): 1:BEGIN 08-01 11:09:34.051: I/MyService(1333): 1:RESTART_SERVICE_COMPONENT 08-01 11:09:34.051: I/MyService(1333): 1:complete I guess you're doing something wrong in the code that you have hide from us. like here: //create alarmmanager code here or here: //retrieve settings from internet server here... //parse values //apply new service scheduled interval Please check yourself, or show us the code so that we can see wher

Categories : Android

Tomcat giving Error : There is no Action mapped for action name ProgramOne in Struts 2
You have posted a question 'There is no Action mapped for action name getTwo' in struts2 the action getTwo mapped to class StrutsTwopack.ProgramTwo in namespace /program. If the error is true this means either class is wrong or namespace is wrong in the url. what should i do??? Post the SSCCE, or decide yourself which wrong version is better resolvable.

Categories : Java

No route matches {:action => "show" ...} while params[:action] returns "edit"
Check the server logs in your terminal window - you likely have an invalid link to a show page, in your edit view. edit: Oh I see, it's a routing issue. Because you have an extra variable in your routing (:menu as well as :id) you need to provide that extra variable when defining your form. Try the following (if menu is supposed to equal 'forum') = simple_form_for :forum, @page do |f| (leave the rest the same)

Categories : Ruby On Rails

Struts redirection from action to Jsp and back again to same action class giving null pointer exception
Yes. Unless you use that variable in the form, Struts doesn't send the value back. In order to send the values back, you need to set HiddenVariable in the jsp page In simple, if you have textbox like this When JSP page is generated, a Hidden variable is generated by struts and when you submit the form, the hidden variable data will be transformed and stored/mapped to Bean data. If you are not using Bean variable in the jsp page, Struts doesn't generate the hidden variable type for that, thus when it goes to Action class, it will create the new bean and the old bean data is not set.

Categories : Java

Qt - very simple drawing on toggled action
Like the warning message says, generally the only appropriate time to paint things with a QPainter is from inside the paintEvent() method. So the usual way to do what you want to do is this: 1) When you want to draw a line, set a member variable to remember that you want to do that (e.g. this->draw_the_line = true;) 2) After setting draw_the_line to its new value, call update() on the widget you want to have a line drawn on ... this will tell Qt to schedule a call to paintEvent() on that widget as soon as possible. 3) Re-implement the widget's paintEvent() method, something like this: void MyWidgetSubclass :: paintEvent(QPaintEvent * e) { TheWidgetSuperclass::paintEvent(e); // this will draw the widget's usual graphics // Plus your custom stuff on top, if appropriate if (th

Categories : C++

MVC4 POST model from an action to another action skipping view
Maybe is not the best approach, but you can put the model in hiddenfields TempData example: On redirecting Action: TempData["model"] = model; return RedirectToAction("DifferentAction"); On different Action var myModel = (model)TempData["model"] /* do register stuff */

Categories : Asp Net Mvc

There is no Action mapped for namespace [/] and action name [] associated with context path [/struts]
Add the following package in struts.xml <package name="default" namespace="/" extends="struts-default"> <action name="login" class="training.struts.action.LoginAction"> <result>login.jsp</result> </action> </package>

Categories : Eclipse

Updating p:commandButton action by ajax doesn't end up in right action being invoked
The action attribute is evaluated during the request of the actual form submit. As this is happening during a different request than the one on which you've changed it, and as your bean is request scoped, it will fail. The bean is namely reconstructed with all properties set to default. You need to put the bean in the view scope in order to get this construct to work. @ManagedBean @ViewScoped public class ProjectPageBean {} Alternatively, if the getPage() merely returns a String, rather use <p:button> instead. <p:button ... outcome="#{projectPageBean.page}" /> The outcome attribute is evaluated during rendering the HTML output, thus it will work just fine in such construct. See also: How to choose the right bean scope? Difference between h:button and h:commandButton

Categories : Ajax

@Url.Action or Html.Action missing directive or assembly in Razor
Sounds like you're either missing the web.config file in your views directory, or you're missing the System.Web.WebPages.Razor section which defines namespaces to be included (by default) within each view. Your views config should have the above node defining a namespaces node which includes things like System.Web.Mvc. For example, my ~/Views/web.config has the following section within <configuration>: <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" />

Categories : Asp Net Mvc

Struts 1 redirect from action to action with parameters as POST request
You can't, it is not a Struts problem. It is how HTTP is designed. When a browser is redirected, it perform a GET request. You cannot ask the browser to do a POST instead. The only way would be to add some Javascript to send the request. Or you can also ask Struts to do an internal redirection but it will be hidden to the client and the url will not change.

Categories : Java

ASP.NET MVC - RouteData set in filter action not bound to action method parameter
The filter is attached to the action (method). Hence by the time the filter is run, the values for the parameters have already been chosen. Imagine the situation if what you asked worked: [SomeFilter] public ViewResult SomeActionMethod() { // .... } public ViewResult SomeActionMethod(SomeClass someData) { // ..... } You reference http://mysite.com/mycontroller/SomeActionMethod with no query parameter. So then it should call the first action. But if your filter were to do what you wanted, after it ran, it should call the second action. But that one DOESN'T have the filter, so it should call the first. And round & round.

Categories : Asp Net Mvc

How to retrieve previous action name from the current action in apache oozie?
If you need this to get the error message use wf:lastErrorNode() <kill name="kill"> <message> Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}] </message> </kill>

Categories : Hadoop

undo action. delay ajax call for set time or until next action
You can try to encapsulate the actions and show use the pending actions which use can commit by clicking a button. This way they can any time remove the pending action. Another way is to create undo action (like if a block of text is deleted, keep the deleted text with position information) that can be executed later to bring system back to previous state. But if it is something like email sent or data saved to database things get complicated and queuing up pending changes is a better way. There is an undo/redo module for YUI library which you can explore.

Categories : Javascript

How to define a default Action for any http method in Play 2.1 (Scala)?
You should not try to figure out all possible bad access points to generate error messages. Instead, you can override the onHandlerNotFound method in the application's Global object. Adapted from Play's official documentation: ScalaGlobal import play.api._ import play.api.mvc._ import play.api.mvc.Results.__ object Global extends GlobalSettings { override def onHandlerNotFound(request: RequestHeader): Result = { // implement methodNotAllowed controller Action } }

Categories : Http

encrypt video file using action script 3 and play it from maim swf
You'll need to use a null net connection and net stream to prepare a video in "data generation mode". Then load encrypted bytes with a URLRequest, decrypt them, and append the bytes to a net stream. var nc = new NetConnection(null); var ns = new NetStream(nc); var encryptedBytes = .. get encrypted bytes from URLRequest ... var decryptedBytes = .. your decryption function .. ns.appendBytes(decryptedBytes); var video = new Video(); addChild(video); video.attachNetStream(ns); ns.play(null);

Categories : Actionscript

Simple Registration on Symfony 2 wrong action
did you set it to a password type? eg $builder->add('password', 'password) Or can do repeated field $builder->add('password', 'repeated', array( 'type' => 'password', )); When you build the form do you set action? $form = $this->createForm(new Type(), $type, array( 'action' => $this->generateUrl('your_route'), ));

Categories : PHP

Disabling default action (return false) even when action is set to .off
I would add class to the button when it is clicked once and remove class when process is completed plus a check also to ensure that button does not have class of disable. $('#register_submit').on('click', function() { if($(this).hasClass("disable")) { return false; } else { $(this).addClass("disable"); registerClick(); } }); function registerClick() { $.ajax( { type: "POST", url: "/ajax/register.ajax.php", data: $("#register_form").serialize(), success: function(data) { var result = jQuery.parseJSON(data); if (result.success) { alert('Account registered. You are now being transferred to Paypal for payment.'); window.location = result.success; } else if (

Categories : Jquery

How to make the Action Bar SearchView fill Entire action bar?
Got it @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.my_swipe_tabbed, menu); MenuItem searchViewItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) searchViewItem.getActionView(); searchView.setIconifiedByDefault(false); ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT); searchView.setLayoutParams(params); searchViewItem.expandActionView(); return true; } <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".MySwipeTabbedActivity" > <item a

Categories : Android

Unknown action [PostController@deletePost] using URL::action() in Laravel4
Looks like you need to set a route for the deletePost action. Assuming your url is admin/post/delete/$id, try adding this as a new line for your post group in routes.php: Route::get('delete/{any}', "PostController@deletePost"); Instead of using {{ action('PostController@deletePost', array('id' => $post->id)) }} to build your URL, you could use link_to_action() helper in your view to build the entire anchor including HTML tags/attributes/etc: {{ link_to_action('PostController@deletePost', 'Delete', $parameters = array($post->id), $attributes = array()) }}

Categories : PHP

Php Yii: parameter passing to action vs load model in action
I much prefer loading that single row the database. It's an optimization I wouldn't worry about until it becomes an issue. You can store the model in your controller to prevent running the same query multiple times: // Store model to not repeat query. private $model; protected function loadModel( $id = null ) { if($this->model===null) { if($id!==null) $this->model=SomeModel::model()->findByPk($id); } return $this->model; } It's a trick I learned here.

Categories : PHP

Using 'get' in an action for Grails controllers causes action to execute even when not called
GRAILS-9310 suggests that this is a known limitation which won't be changed, the workaround is not to name your actions get*. The root cause is If no explicit model is returned the controller's properties will be used as the model (Grails docs) When you define a getTest() method this means that the controller has a test property, and when you render the "home" view without an explicit model the controllers properties get enumerated to form the model map. The getTest() method will be called as part of this enumeration process. If you really need getTest to appear in the URL then you'll have to name the actual action something else and then define a custom URL mapping to direct the /controller/getTest URI to the renamed action.

Categories : Grails

What does action do in this context ""
It is passing a value to the PHP file, which the PHP file can then use in several ways. It can pass that value to a database, or just display it on the screen, or any number of things. In PHP it can be accessed by $_GET['action'].

Categories : PHP

Form submitting to old action after changing the action via jQuery
Maybe you should try to use prop instead of attr. var action = $('#update-schedule-form').prop('action'); $('#update-schedule-form').prop('action', action + '/1'); Check this answer for .prop() vs .attr()

Categories : PHP

Rails how to get query string from get action in post action?
You can add a hidden field to your form and set its value to params[:key]. Then it will be available in the params you get from the form. If you're using Simple Form: <%= simple_form_for @model do |f| %> ... <%= f.input :field_name, :as => :hidden, :input_html => { :value => params[:key] } %> <%= f.button :submit %> <% end %>

Categories : Ruby On Rails

CakePHP: calling an action with argument from another action within controller
Well, it looks like the form submission data from bleh() persists in print_pdf(), so it doesn't look like I need an argument to pass to print_pdf(). public function bleh() { // form submission is made $this->print_pdf(); // no argument } public function print_pdf() { if (check form submission) { $arg = $this->data[previous_form_data]; // some stuff $this->render(); } } This works well, but I'd still like to know if there's a way similar to my original approach.

Categories : Cakephp

PHP: 2 forms different action pages, only 1 form action works
You have to change your code like this : <form method="get" action="approve.php?id=<?php echo $row[0] ?>"> <p> <input type="submit" class="btn btn-primary" value="Approve" /> </p> </form>

Categories : PHP

Struts error: There is no Action mapped for namespace / and action name ***
Try <package name="default" extends="struts-default" namespace="/"> <action name="myAction" class="com.action.MyAction" > <result name="success">result.jsp</result> </action> </package> In JSP <a href="<s:url action="myAction"/>">click here</a> OR (@tom 's suggestion) <s:a action="myAction" >click here</s:a> Also, make sure that struts.xml configuration file is on the classpath

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.