Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

View, View Controller, Model Controller, Model (VVCMCM) Pattern

, 18 Mar 2012
The MVC Pattern was first conceptualized assuming all the three actors were present at one place. Since Web Applications have both a client and a server this needs to be applied differently without technology bias.
VVCMCMSystem.zip
VVCMCMSystem
VVCMCM
VVCMCMSystem.suo
App_Data
bin
Model
ModelControllers
obj
Debug
Refactor
TempPE
VVCMCM.dll
VVCMCM.pdb
Properties
Scripts
JqGrid
i18n
JqueryUI
Themes
jqgrid
start
images
ui-bg_flat_55_999999_40x100.png
ui-bg_flat_75_aaaaaa_40x100.png
ui-bg_glass_45_0078ae_1x400.png
ui-bg_glass_55_f8da4e_1x400.png
ui-bg_glass_75_79c9ec_1x400.png
ui-bg_gloss-wave_45_e14f1c_500x100.png
ui-bg_gloss-wave_50_6eac2c_500x100.png
ui-bg_gloss-wave_75_2191c0_500x100.png
ui-bg_inset-hard_100_fcfdfd_1x100.png
ui-icons_0078ae_256x240.png
ui-icons_056b93_256x240.png
ui-icons_d8e7f3_256x240.png
ui-icons_e0fdff_256x240.png
ui-icons_f5e175_256x240.png
ui-icons_f7a50d_256x240.png
ui-icons_fcd113_256x240.png
ui-lightness
images
ui-bg_diagonals-thick_18_b81900_40x40.png
ui-bg_diagonals-thick_20_666666_40x40.png
ui-bg_flat_10_000000_40x100.png
ui-bg_glass_100_f6f6f6_1x400.png
ui-bg_glass_100_fdf5ce_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_gloss-wave_35_f6a828_500x100.png
ui-bg_highlight-soft_100_eeeeee_1x100.png
ui-bg_highlight-soft_75_ffe45c_1x100.png
ui-icons_222222_256x240.png
ui-icons_228ef1_256x240.png
ui-icons_ef8c08_256x240.png
ui-icons_ffd27a_256x240.png
ui-icons_ffffff_256x240.png
ViewControllers
ViewEvents
Views
VVCMCM.csproj.user
var EntityViewController =
{

    //
    ModelControllerName: 'VVCMCM.ModelControllers.Entity',

    Search: function()
    {
        //the this keyword is not working as expected
        //this.ModelControllerName);
        var queryString = '';
        var strShortName = '';
        var strLongName = '';
        var strSKU = '';

        //get the values from the form fields
        strShortName = $('input#txtShortName').val();
        strLongName = $('input#txtLongName').val();
        strSKU = $('input#txtSKU').val();

        //        queryString = Core.CreateQueryString('controller', EntityViewController.ModelControllerName,
        //                                        'action', 'search',
        //                                        'format', 'html',
        //                                        'txtShortName', strShortName,
        //                                        'txtLongName', strLongName,
        //                                        'txtSKU', strSKU
        //                                        );


        queryString = '?method=get' +
                      '&controller=' + EntityViewController.ModelControllerName +
                      '&action=Search' +
                      '&format=xml' +
                      '&' + $("form#searchForm").serialize();

        //enable this for viewing what is being sent
        //alert(queryString);


        var searchUrl = Core.ModelControllerUrl + queryString;

        $.get(searchUrl, function(data)
        {
            EntityViewController.SearchResult(data);
        });

    },

    SearchByPost: function()
    {
        //the this keyword is not working as expected
        //this.ModelControllerName);
        var queryString = '';
        var dataString = '';
        var strShortName = '';
        var strLongName = '';
        var strSKU = '';

        //get the values from the form fields
        strShortName = $('input#txtShortName').val();
        strLongName = $('input#txtLongName').val();
        strSKU = $('input#txtSKU').val();

        queryString = '?method=post' +
                      '&controller=' + EntityViewController.ModelControllerName +
                      '&action=Search';

        dataString = 'format=xml' +
                     '&' + $("form#searchForm").serialize();

        //enable this to understand what is being sent
        //alert(dataString);


        var searchUrl = Core.ModelControllerUrl + queryString;

          $.post(searchUrl, dataString, function(data)
          {
              EntityViewController.SearchResult(data);
          });

    },

    SearchResult: function(data)
    {
        //unload the grid if present
        $("#list1").GridUnload();
        
        $("#list1").jqGrid({
            datastr: data,
            datatype: "xmlstring",
            colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
            colModel: [
   		{ name: 'id', index: 'id', width: 75, sorttype: 'int' },
   		{ name: 'invdate', index: 'invdate', width: 90, sorttype: 'date', datefmt: 'Y-m-d' },
   		{ name: 'name', index: 'name', width: 100 },
   		{ name: 'amount', index: 'amount', width: 80, align: "right", sorttype:'float' },
   		{ name: 'tax', index: 'tax', width: 80, align: "right", sorttype: 'float' },
   		{ name: 'total', index: 'total', width: 80, align: "right", sorttype: 'float' },
   		{ name: 'note', index: 'note', width: 150, sortable: false }
   	],
            rowNum: 10,
            autowidth: true,
            rowList: [10, 20, 30],
            pager: $('#pager1'),
            sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
            caption: "XML Example"
        }).navGrid('#pager1', { edit: false, add: false, del: false });
    }
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Anton Pious Alfred
Architect Riversand Technologies Inc
India India
Head of Engineering at Riversand Technologies Inc.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 18 Mar 2012
Article Copyright 2012 by Anton Pious Alfred
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid