codeigniter check for user session in every controller

Another option is to create a base controller. Place the function in the base controller and then inherit from this. To achieve this in CodeIgniter, create a file called MY_Controller.php in the libraries folder of your application. class MY_Controller extends Controller { public function __construct() { parent::__construct(); } public function is_logged_in() { $user = $this->session->userdata(‘user_data’); … Read more

Angularjs: a Service that serves multiple $resource urls / data sources?

You can update service to return a hash of resources, not a single one: angular.module(‘myApp.services’, [‘ngResource’]). factory(“geoProvider”, function($resource) { return { states: $resource(‘../data/states.json’, {}, { query: { method: ‘GET’, params: {}, isArray: false } }), countries: $resource(‘../data/countries.json’, {}, { query: { method: ‘GET’, params: {}, isArray: false } }) }; }); You will be able … Read more

How to return an HTML page from a RESTful controller in Spring Boot?

When using @RestController like this: @RestController public class HomeController { @RequestMapping(“https://stackoverflow.com/”) public String welcome() { return “login”; } } This is the same as you do like this in a normal controller: @Controller public class HomeController { @RequestMapping(“https://stackoverflow.com/”) @ResponseBody public String welcome() { return “login”; } } Using @ResponseBody returns return “login”; as a String … Read more

Call Controller Method Which Return View With Ajax Call From Asp.net View Page

If you wants to refresh page: Controller: public ActionResult Index() { return View(); } public ViewResult Test() { ViewBag.Name = Request[“txtName”]; return View(); } Index.cshtml: @using (Html.BeginForm(“Test”, “Home”, FormMethod.Post )) { <input type=”submit” id=”btnSearch” class=”btn btn-warning” style=”height:35px;width:120px” value=”Search”/> <label>Name:</label><input type=”text” id=”txtName” name=”txtName” /> } Test.cshtml: @ViewBag.Name ============================================= If you don’t wants to refresh page: Controller: … Read more

How to return an object from a Spring MVC controller in response to AJAX request?

I need this list of employee in ajax In spring when you need object serialization, de-serialization and message conversion. in that case you need to annotate your controller handler method with @RequestBody and @ResponseBody. Where: @ResponseBody : will inform spring that try to convert its return value and write it to the http response automatically. … Read more

Spring forward with added parameters?

The simplest way is to add the data to the request. Since this is a forward, the same request is passed around to different handlers within the server. As example, let’s start with a simple setup of two controllers, one forwarding to the other: @Controller public class TestController { @RequestMapping(value=”/test”) public String showTestPage() { return … Read more

ASP.NET MVC Programmatically Get a List of Controllers

Using Jon’s suggestion of reflecting through the assembly, here is a snippet you may find useful: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web.Mvc; public class MvcHelper { private static List<Type> GetSubClasses<T>() { return Assembly.GetCallingAssembly().GetTypes().Where( type => type.IsSubclassOf(typeof(T))).ToList(); } public List<string> GetControllerNames() { List<string> controllerNames = new List<string>(); GetSubClasses<Controller>().ForEach( type => controllerNames.Add(type.Name)); return … Read more

Angular JS resizable div directive

This question is old, but for anybody looking for a solution, I built a simple directive to handle this, for vertical and horizontal resizers. Take a look at the Plunker angular.module(‘mc.resizer’, []).directive(‘resizer’, function($document) { return function($scope, $element, $attrs) { $element.on(‘mousedown’, function(event) { event.preventDefault(); $document.on(‘mousemove’, mousemove); $document.on(‘mouseup’, mouseup); }); function mousemove(event) { if ($attrs.resizer == ‘vertical’) … Read more