Skip to main content

Posts

Showing posts with the label mvc

Multiple models vs single model

I have a question about MVC. Particularly about models. Suppose that I have a category table in my database. Now I would like to get results both for a single category for detailed view and multiple categories for a listing. Also I may need to query a number of categories for different purposes.

ACL implementation

First question Please, could you explain me how simpliest ACL could be implemented in MVC. Here is the first approach of using Acl in Controller... <?php class MyController extends Controller { public function myMethod() { //It is just abstract code $acl = new Acl(); $acl->setController('MyController'); $acl->setMethod('myMethod'); $acl->getRole(); if (!$acl->allowed()) die("You're not allowed to do it!"); ... } } ?> It is very bad approach, and it's minus is that we have to add Acl piece of code into each controller's method, but we don't need any additional dependencies! Next approach is to make all controller's methods private and add ACL code into controller's __call method. <?php class MyController extends Controller { private function myMethod() { ... } public function __call($name, $params) { //It is just abstract code $acl = new Acl();

How can you organize the code for a game to fit the MVC pattern?

I'm a freshman in college going for my computer science degree... I've programmed plenty the last several years but just lately I've been getting more into theoretical ideas about organizing code, design patterns, differences in languages, etc. I have a Java class, so I've dropped my C++ research/development and moved into Java and JOGL (Java OpenGL). It's wonderful! But that's beside the point. I want to make a small role-playing game, but this question really applies to any sort of game. How do you organize the game objects in a way that is structured, like the Model-View-Controller pattern? It looks to be an amazing pattern, very widely used and makes a lot of sense, but I'm having trouble figuring out how to implement it. For instance, I need to keep track of a GL object for drawing to the screen. I have to have classes that implement MouseListener, MouseMotionListener, MouseWheelListener, and KeyListener (or one class, an all-in-one input manage

issue with URL validation MVC razor and JQuery

I am working on MVC Razor. I face an issue to validate URL validation. I need to do URL validation before inserting in temp DB. I got a reference of http://www.regxlib.com/Search.aspx?k=&c=2&m=-1&ps=20 and found one nice validation pattern, (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])? While i work in MVC view, it gives me error so i have change it to (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@@?^=%&amp;:/~\+#]*[\w\-\@@?^=%&amp;/~\+#])? i.e. @@ instead of @ when it runs and if i see the console, i got the original one, so i think it is okay for me to do @@ instead of @ But in console i got an error can anyone tell me what is wrong with this, so got the error, "invalid range in character class"

issue with URL validation MVC razor and JQuery

I am working on MVC Razor. I face an issue to validate URL validation. I need to do URL validation before inserting in temp DB. I got a reference of http://www.regxlib.com/Search.aspx?k=&c=2&m=-1&ps=20 and found one nice validation pattern, (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])? While i work in MVC view, it gives me error so i have change it to (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@@?^=%&amp;:/~\+#]*[\w\-\@@?^=%&amp;/~\+#])? i.e. @@ instead of @ when it runs and if i see the console, i got the original one, so i think it is okay for me to do @@ instead of @ But in console i got an error can anyone tell me what is wrong with this, so got the error, "invalid range in character class"

How to enable navigation buttons of jQuery grid in mvc3 and assign buttons to specific links?

I have read some topic regarding with my question but there code doesn't work for me. Honestly, I'm not good in jQuery. I have this working views and controller, but it has a lot disadvantages that is why I switch to using jQuery grid. Working code (not using jQuery grid): @using Custom.Helpers @model IEnumerable<Models.DeviceMVC> @{ ViewBag.Title = "List"; } <div id="page-title"> <h2>Device list</h2> <div id="Optiontab"> @Html.ActionLink("Create New", "Create") </div> </div> <table id="table-list"> <tr> <th> Branch </th> <th> Name </th> <th> Login id </th> <th> Serial number </th> <th> Brand </th> <th> Model

MVC 3: Communicating between partial view and view via JavaScript

I have a page that lists users (List.vbhtml), and each user has an 'Edit' link. The edit link makes an Ajax request: @Ajax.ActionLink("Edit", "Edit", "Player", New With {.id = currentItem.PlayerId}, New AjaxOptions() with { .UpdateTargetId="edit"}) The Edit method in my controller returns a partial view (_Edit) which contains a form. After the form has been submitted, I want to hide the edit form (not a problem), and then reload the list of users. This is what I am struggling with. How do I let the parent view (List.vbhtml) know I should reload the list (which would be done using a Ajax Get request)? I can't do this from the Edit partial view, because the Edit partial view shouldn't know about the List view, only the other way around (List view knows about the partial view). My current solution is to raise a custom event when the edit is complete in _Edit.vbhtml, and capture it in List.vbhtml: $(document).trigger('Pe