Zend Framework 2 - Rich Components - GUI - editable datagrid, datatable, lists, forms, dialogs, tree-views, autocomplete field - user-interface

Zend Framework 2 has implemented a lot of stuff for all the layers, but like nothing for GUI.
I am missings things like datagrids, dialogs, tree-views, autocomplete fields and all the stuff one has in JSF and Richfaces.
I thougt maybe extJS could be an alternative, but theres no production ready integration yet.
Why use ZF2 when I have to write code for hours and weeks for such simple things that should already be integrated in an enterprise ready framework ?
I spent very much time now for digging into ZF2 and I learned a lot.
But because of the missing View stuff in ZF2 I'm thinking of changing to another Framework now, after weeks of hard work.
Does someone have a better solution ?

Have a look at this module, you may find what you need :
https://github.com/mwillbanks/ZfcTwitterBootstrap
Also, I suggest you to have a look at the modules page :
http://modules.zendframework.com/

I don't like to answer my own questions, but I want to close this old one and maybe it helps someone else.
At the moment I am very happy with ZfcDatagrid by ThaDafinser.
https://github.com/ThaDafinser/ZfcDatagrid/commits/master
It didn't exist when I asked the question. And as you can see in this great module, it is a lot of work to create such a component for ZF2 and as you can see, it's not just a javascript being served. There's much much more logic behind with pagination, filtering, datasources, output formatting and much more.
You don't want to do this in your controller code, because you want to reuse the grid logic and every grid instance. And you don't want all that logic on client side, because of the same reason.

Related

YUI3 Datatable How to implement server side pagination.

I'm currently working on a school project where we need to display database info in a web UI.
I have a YUI3 Datatable with built in client side pagination. Now I would like to implement server side pagination due to the massive amount of data I will have to work with.
Are there any good solid tutorials on how to implement server side pagination in YUI3?
I've already gone through the API and the YUI2 tutorials I've come across have features no longer supported in YUI3..
No, not that I can find.
I've used this paginator with great success. But the documentation that did exist seems to have vanished both from the github repo and from http://blunderalong.com/yui/gallery/datatable-paginator/paginator_examples.html where it used to live. It may be worth pinging the author a message about it.
Like barnyr, I've used Todd Smith's paginator with great success. I agree that the closest you can get to a tutorial is by perusing Todd's comments in the code.
When I pinged Todd with a fix for a resizing problem, he responded that he had stopped working on it. I guess it's up to us to figure it out now. Also, he seemed to believe that YUI must have either picked up his code from the gallery or developed an equivalent solution; neither seems to be the case right now.
It is sad that blunderalong is gone -- it had lots of goodies -- but I have Todd's server-side pagination example fossilised in my repo:
https://github.com/selkovjr/bfs/blob/master/mojits/Samples/binders/index.js
And here is the server-side model that provides the data for it:
https://github.com/selkovjr/bfs/blob/master/mojits/Samples/models/samples.server.js
It is a bigger pile than you're asking for (the binder code also has row selection and inline cell editing), but at least it has the example you're looking for, almost unchanged.
We are still using YUI 2 which is really good large amounts of data.
Try http://yui.github.io/yui2/docs/yui_2.9.0_full/examples/datatable/dt_dynamicdata.html
and it might be good to do SQL sort for heavy loads which is cheaper.
You can try following examples
http://jafl.github.io/yui-modules/querybuilder/ for complete datatable implementation
or http://jafl.github.io/yui-modules/paginator/ for different pagination samples.
I have implemented paginator successfully using this example.

MVC 3, Entity Framework 4.x, Database First, Desperation

VS2010 Pro + SqlServer Express.
Having been dropped into ASP.NET MVC 3 with no guidance but the web (2 books on order), I can't even get off the ground.
The MVC itself I get. Not a problem.
PHP, Ruby, and even ghastly WebForms firmly tucked into my toolbelt, with a long history of C++ QT client-server development before that.
Tying ASP.NET MVC 3 to a database using EF4 ORM is killing me.
The goals:
Use database modeled by DBA. I can specify all naming conventions, but code first is not an option!
Import to EDMX. This will be regularly updated using VS tools from the DBA's DB, never edited directly.
Generate partial classes from EDMX, for use as model. This will regularly be updated using VS tools, never edited directly.
Use 'buddy' to extend above model class with code as the Controllers/Views need.
Intuitively use the resulting model, pass it to the view, retrieve posts into it for insert/save, etc...
I've seen and read so many blogs, forum posts, walkthroughs, and stack overflow posts regarding this very use case.
I even tried riding the magic unicorn, followed by the latest 4.2beta1 with DbContext generators.
But can't get off the ground.
I follow instructions, but just not understanding how to do anything with it.
What conventions does the 'buddy' require (if any)? How do I use it? How do I get data with it? How do I write data?
Every example looks different. MVC guides are always focused on the UI side. EF guides don't cover usage in the MVC.
These are basic questions, and I'm feeling like the most incompetent idiot in the WWW right now.
Is anyone out there currently using MVC3 & EF4.x in the way I describe above?
This video is a good starting resource. Its a video of a guy creating an app from scratch that uses entity and a sql database (though he makes the db in the video, its still good for seeing some basics in action). You can see how he pulls data from the database, displays it on the page, and saves changes back to the database.
The first question I would ask is why are you stuck on using EF as an ORM or even insisting an ORM at all? I'd choose tools to suit the job here, especially given the constraints of the data layer.
Buddy classes were a concept invented in a day when the main .NET ORMs had no code-first option as ORM-encumbered class instances really don't behave well under things like model binding. Nevermind you could not decorate them with the DataAnnotations one used to indicate fields were required. Typically, the technical requirement is to use [MetadataType] attributes to tie your buddies to your models and perhaps something like AutoMapper to map data to and fro.
All that said, as a guy who has a few apps with lots of buddies and lots of automapping going on, you might want to think otherwise -- it is a bit of a maintenance nightmare. I'm living it.
There are some really good getting-started videos and tutorials right on ASP.NET MVC's site. The "Model (Data)" section is Entity Framework focused and touches on hot/trending topics like Repositories and Units Of Work.

What new features would you like to see in Asp.net MVC 3?

Asp.net MVC 3 preview 1 was released at the end of last month. Are there any new features you are excited about or any features you would like to see before it is fully released?
Full support for Controllers with Generic Parameters
public GenericController<SomeType> : Controller
Generic controllers are quite possibly the greatest MVC timesaver if your doing a lot or business CRUD. There are so many similarities between the Add methods of almost every MVC project that it makes sense to abstract these operations out in a Controller that fits all scenarios.
Right now its a little hacky to create a generic controller. The MVC engine always gets the name wrong (GenericCo vs. Generic) and without full support plugin and libraries that interact with controllers just fall over when they encounter a generic one.
Make Dropdowns easier to work with
As a professional MVC tag watcher I've noticed that working with dropdowns is one of the most repeated questions on SO. The amount of Dropdown questions is a strong indication that something should be done to make it easier or less ... complex?
make checkbox list easy to work with
add T4MVC to the official release
add official helpers for OData
support one javascript library either MS Ajax or jQuery(preferably)
I wish they can add something to help developer to migrate their previous ASP.NET WebForms application.

Is WordPress MVC compliant? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Closed 7 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Some people consider WordPress a blogging platform, some think of it as a CMS, some refer to WordPress as a development framework. Whichever it is, the question still remains. Is WordPress MVC compliant?
I've read the forums and somebody asked about MVC about three years ago. There were some positive answers, and some negative ones. While nobody knows exactly what MVC is and everybody thinks of it in their own way, there's still a general concept that's present in all the discussions.
I have little experience with MVC frameworks and there doesn't seem to be anything about the framework itself. Most of the MVC is done by the programmer, am I right? Now, going back to WordPress, could we consider the core rewrite engine (WP_Rewrite) the controller? Queries & plugin logic as the model? And themes as the view? Or am I getting it all wrong?
Thanks ;)
Wordpress itself is not architected in MVC, but one can build very MVC oriented themes and plugins within the framework. There are several tools which can help:
WordPress MVC solutions:
Churro: # wordpress.org/extend/plugins/churro
Tina-MVC: # wordpress.org/extend/plugins/tina-mvc
Plugin Factory: # wordpress.org/extend/plugins/plugin-factory
MVCPress: http://mozey.wordpress.com/2007/01/22/mvcpress-screenshots/#comment-3634 (abandoned, but interesting ideas)
MVC threads on WordPress.org Ideas and Trac:
http://wordpress.org/extend/ideas/topic/mvc-plugin-framework
http://wordpress.org/extend/ideas/topic/complete-reestructuring
http://wordpress.org/extend/ideas/topic/rewrite-wordpress-using-mvc
http://wordpress.org/extend/ideas/topic/wordpress-theme-revamp (more on XSL than MVC)
http://core.trac.wordpress.org/ticket/12354 (on MVC in widgets)
Wordpress is kinda-sorta MVC. If anything it is a pull-type MVC layout, where the View 'pulls' data from the model. It does this in a very proceedural way, instead of using lots of different objects, but this actually makes the front end templates easier to write in a lot of ways.
This also gives the views some degree of controller logic (thus the kinda-sorta MVC).
Lets run this down:
Wordpress gets a URL. The wordpress core acts as a controller and determines what initial queries to run of the database, and by extension, what view should be loaded (category view, single post or page view, etc). It then packages that INTIAL query response and sends it to the view file.
That view file CAN be a strict display only file OR it can request additional information/queries beyond the built in one. This is the pull-type of the MVC, where the view pulls data from the model instead of the controller 'pushing' data from the model into the view.
Thus, when the view sees code to load a sidebar or widget area, it asks for that information. However, what widgets should be there is determined by the controller, which looks at the model for what widgets are in the sidebar, and then selects those that are set to show on the current page, and returns those to the view.
That each part of that isn't an object doesn't make this any less MVC. You can alter WP core without (necessarily) altering anything about a theme. Similarly, as long as you use built in functions like 'get_pages()' then the model and the database tables could change as long as those functions still returned the right data. So, the model is independent of the view, and the controller is independent as well (except when the view adds controller logic to do more than the core normally does).
While you COULD have a model object holding a number of methods and stuff like WPModel::get_pages('blah blah'), and contain everything that way, there is still fundamental separation of concerns.
View: template files
Controller: WP core
Model: the various functions that handle specific data handling.
As long as the names, arguments, etc, stay the same (or just have new ones added) then separation of concerns is maintained and one can be altered without disturbing the others.
It isn't a super-clean version of MVC, (especially when hooks get involved), but at a basic level it starts there.
And being proceedural about it isn't a bad thing IMO. A request from a website is pretty inherently proceedural: it is a process with a clear beginning and end, and just needs a procedure to process the request, get data, package it, then die. You can set up those steps with objects and object methods and OOP layouts (which would make some things easier) or you can just write alot of function calls and separate them out that way. Class members like private variables are lost that way but depending on the needs of the application... you might not care.
There is no one-grand-way to do development, and WP sits at like 20% of websites so it is doing something right. Probably something to do with not making people have to learn/memorize complex class hierarchies to get the database to answer the question 'what pages are child of page x?' and deal with that data. Could you make it that easy with OOP? yes, but if Joomla is any example of how hard it is to implement a complex custom website with OOP, then WP is FAR easier and quicker, and time is money.
As already mentioned in the comments, MVC is an architectural design pattern, not a specific framework, and no, Wordpress doesn't follow the MVC pattern.
There is a separation of views (templates) from the programming logic, but only in the frontend, not in the admin panel and a general separation of views and application logic is not inevitably MVC. An implementation of the MVC pattern usually assumes some kind of object oriented programming paradigm behind it and Wordpress is mainly implemented in a procedural way, with plain SQL queries in the PHP functions, therefore not having an actual model either.
One of the topics that periodically crops up in discussions as it relates to WordPress is the idea of WordPress and MVC.
But the thing is that MVC is not the silver bullet of web development that we try to make it out to be. Yes, it’s an awesome design pattern, and I personally think that it fits the web application model like a glove, but not every framework or platform implements that design pattern.
Case in point: WordPress is not MVC.
And that’s okay. I think we need to leave the desire of trying to shoehorn it into our projects aside especially when the pattern WordPress provides is not only sufficient, but works well when leveraged correctly.
“But I Love MVC!”
So do I! In fact, I spent the last year working on a project that more-or-less mimicked the MVC architecture.
A high-level example of MVC.
A high-level example of MVC.
For example:
Views were implemented using templates
Controllers were implemented by a combination of using function names like create, read, update, destroy, delete, and so on (even though these functions were hooked into the WordPress API
Models were functions also were called to validate and verify data prior to serializing the data. Again, this required that certain functions be hooked into WordPress to achieve the desired result.
Finally, a set of rewrite rules gave the application a clean set of predictable URLs in the format of /people/update/1 or /people/all.
What Pattern Does WordPress Implement?
WordPress implements the event-driven architecture (of which there are several variations such as the Observer Pattern).
In short, you can conceptually think of this as the following:
Things happen when WordPress is processing information.
You can register your own function to fire when these things happen.
Not too complicated, is it?
A high-level example of event-driven patterns
A high-level example of event-driven patterns
When you begin to think in terms of the paradigm in which it works rather than trying to make it work the way that you want it to work, it’s liberating. It helps to solve problems much more easily.
The bottom line is this: WordPress implements the event-driven design pattern, so even if you end up trying to implement MVC, you’re still going to have to utilize the hook system.
If you’re not careful, you can end up trying to craft the perfect architecture without actually getting your work done, and thus end up finding yourself so high up in the atmosphere of software that you’ve effectively become an architecture astronaut.
So You’re Saying Avoid Design Patterns?
Not at all! Design Patterns serve a purpose because, above all else, they basically give us solutions to previously and commonly solved problems. Use them!
But the point I’m trying to make is that we don’t need to try to force things to fit pattern just because we like the pattern. That’s not their purpose. Instead, leverage the primary pattern that your platform of choice implements – in our case, it’s an event-driven pattern – and then implement patterns where they fit (such as dependency injection or something like that).
Otherwise, it’s like trying to put your foot in a glove.
Courtesy (and totally copied :P) from : http://tommcfarlin.com/wordpress-and-mvc/
Just to update this with more recent information for people hitting this from search engines - the wp-mvc plugin http://wordpress.org/extend/plugins/wp-mvc/ goes a long way to creating a mvc framework for plugin development. You can find out more here: http://wpmvc.org/documentation/70/tutorial/
Just to add to the list of options, (I'm admittedly biased as the author,) swpMVC is a fully featured, lightweight MVC framework, inspired by Rails, Sinatra, Express, and FuelPHP. It's thoroughly documented, and while I have used and enjoyed wp-mvc, I wanted something where the models were able to populate views themselves, including form controls for interacting with said models.
I put this together largely to reduce the amount of controller code required to put together an app on top of WordPress, and the result is a very fast and effective framework that runs inside WordPress. The models are based on PHP Activerecord and 8 models are included for existing WordPress data types, including Post, PostMeta, User, UserMeta, Term, and a few more. Modeling data is very easy thanks to the activerecord library, and I've enjoyed working with this framework immensely thus far.
Also ships with underscore PHP and PHP Quick Profiler (as seen in FuelPHP.)
RokkoMVC is a micro MVC framework built especially for WordPress. The project is meant to simplify AJAX functionality in WordPress applications, as well as bringing in all the other benefits of using models, views, and controllers to your theme.
I had a bash recently at creating a plugin that makes use of a simple view-controller system, and quite liked the results, so I separated the template stuff out to its own repo. It offers object-based controllers, passing variables locally to PHP templates, template fragments (templates within templates) and components (template fragments with their own sub-controller). All in two tiny classes!
Of course, I wrote this code thinking that no other WP developer had considered the problem before ;-).
It's far from mvc, there is no kinda-sorta thing like some people say, it's either MVC or not... The fact that you write logic on the view level doesn't qualify it as a mvc framework. The reason people use it - it's easy to learn, you don't need to be hardcore php programmer, they're lazy.

Is AJAX easier with ZendX_JQuery or with Zend_Dojo?

The context is that I don't want to use Zend MVC - controllers, helpers, decorators etc - that's overkill for what I am writing.
I've scoured the jQuery site plugins section and these issues bother me most:
I have to search a lot for plugins - it is tedious.
I have to check dependencies with jQuery versions. Thankfully I decided to stick with only jQuery or noConflict() would have driven me crazy.
I have to hook-up all the id's and names of form elements across HTML+CSS+JQuery through Controllers, Views etc.
And all this because there is no other simpler PHP wrapper over jQuery plugins than ZendX_JQuery - and plugins is where the attractive scripts and effects are.
Writing a in-house replacement to ZendX_JQuery will be a huge task in itself. But if you have to wrap third party jQuery plugins in PHP and maintain the thing it is full time job in itself.
So I want to know if Zend_Dojo is much easier than ZendX_JQuery. I'm asking before trying out because I'd have to spend a couple more days installing, configuring and testing all the standard Dojo controls and then I can decide. All that's tedious for a rather simple app which may grow later on.
The alternative would be a "jQuery-inside" PHP widget library that is stable and will work for a year without being broken or upgraded.
Something like GWT or ZK or ASP.Net where you don't have to do low-level HTML+jQuery coding and hand-tweaking for every page with all the ajax controls and form elements.
Or should I just drop an MVC framework altogether and replace it with a custom set of scripts only using Zend components where necessary - like Zend_Validate, Zend_Form etc.
I've been working on desktop apps for some time and the switch to AJAX + MVC + Zend is proving a bit too unwieldy, especially given the abundance of design patterns in Zend MVC.
My recommendation would be to use neither ZendX_JQuery or Zend_Dojo. By the sounds of it, that's overkill for you as well. My thoughts may be coloured by the fact that I don't like to mix PHP and JavaScript code except where absolutely necessary - yes, it may be easier to let a component write your JavaScript for you, but it's never going to be as clean as you could write it yourself.
That way, you also maintain separation between behaviour and presentation - always a good thing, as it makes it easier to use the concepts of progressive enhancement.
I agree with Stephen Orr- I use neither jquery nor dojo (after trying both). I use Zend_Form filters / decorators heavily because client side validation has to be redone on the server side anyway. With some custom decorators, you can do it all in html/php.
I try and avoid ajax where possible, and use prototype / scriptaculous where it cannot be avoided. They are lightweight and provide handy shortcuts to use in other JS code.

Resources