Operations in MVC

experts,
my requirement is to fire an event when click a button using MVC.
Can any of you can send sample code.
Thanks
Vijaykumar Reddy. S

Sample code.
In the View the code will be like this. If the
<htmlb:button id      = "dwnl"
              onClick = "download"
              text    = "Download to Excel"
              tooltip = "Download to Excel" />
In the DO_HANDLE_EVENT of the Corresponding controller the code will be like this.
METHOD do_handle_event.
  DATA: lr_event        TYPE REF TO if_htmlb_data.
* load htmlb_manager
  CLASS cl_htmlb_manager DEFINITION LOAD.
* try to get a normal event
  lr_event = cl_htmlb_manager=>get_event( request ).
*try to get extended event
  IF lr_event IS INITIAL.
    lr_event = cl_htmlb_manager=>get_event_ex( request ).
  ENDIF.
* check if system have send an event
  IF lr_event IS INITIAL.
    RETURN.
  ENDIF.
* Controller/View EVENT processing ....
  CASE lr_event->event_name.
    WHEN 'button'.
      CASE lr_event->event_id.
        WHEN 'dwnl'.
      ENDCASE.
   ENDCASE.
hope this helps you.
Amandeep
<i><b>Reward points for each  helpful answer.</b></i>

Similar Messages

  • How to achieve logical operator on [Authorize(Roles = ] in MVC

    For example, I need to make a controller accessible a user with two roles; role "Admin" and "Editor". How to achieve it.
       [Authorize(Roles = "Admins")]
        public class SampleController : BaseController
    How to do logical operator, such as AND and OR (maybe || and &&)
    Thanks!
      

    Hello klouapple,
    Please post your question to ASP.NET forum instead of here.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • MVC model in Web systems and applications

    MVC model in Web systems and applications
    Object-oriented design model is experience, MVC idea is a user interface for the original. This article discusses how the major application areas in the new Web design patterns and the use of MVC framework. The article first introduced the concept of design patterns and characteristics, and MVC architecture design concepts and analysis of the MVC framework contains several key models. Based on the characteristics of Web applications on how to use patterns and MVC framework made some design ideas.??
    1. Introduction
    1.1 design model
    Object-oriented technology and the emergence of software applications has greatly enhanced the trusted and software quality. Object-oriented programming than previous models to various programming simple and efficient, but the object-oriented design methodology than the previous design methods to complex and much more skill, a good design should be both on the issue of gender, but also to take full account of the problems and needs sufficient interoperability. In the past 10 years, people in the object-oriented technology and the practical application of research to explore certain issues in relation to the creation of a number of good solutions, the so-called object-oriented design patterns. Object-oriented technology is one of the purposes of enhancing the software trusted, and to design model, design programmes in important positions from a deeper sense of meaning and essence embodies trusted. There are many people in the design model definition, which cited Christopher Alexander is the largest design model definition : Each design model is a tripartite rule, which expresses a contextual environment (Context), a problem and a solution. Design models generally following basic elements : model name, the purpose solution effect 1995-1998 code and related design models. There are several classifications design patterns can be divided into a model based on the purpose (Creational), structural type (Structural) and the type of behaviour (Behavioral) three. It is mainly used in the creation of a model-based object model-based structure to deal primarily with the category or combination of objects, used to describe behavior-based model is the main target for the category or how stress and how to allocate responsibilities. Design patterns can be divided into categories based on the scope and target mode model type model dealing with the relationship between the categories and sub-categories, these relations through the establishment of succession in Translation moment to be finalized, are static. Model is targeted at addressing the relationship between the moment of change these relations in the operation, more dynamic. Model features : through the experience acquired in a structured format to write down, avoid encountering the same problems on the first design, exist in different abstract level, in continuous improvement, can be trusted artificial product for the design and best practice in the world to be combined to address larger issues.
    1.2 MVC framework
    MVC was first used in a user interface Smalltalk-80 China. M representative models Model, representatives maps View V, C representatives controller Controller. MVC trusted code with the aim of increasing the rate of data reduction expressed, the data describing the operation and application coupled degrees. Also makes software Keweihuxing, restorative, expansionary, flexibility and packaging of greatly enhanced. Single-user applications are usually incident-driven user interface to the organizational structure. Staff development tool with an interface painting of a user interface interface code based on user input and then prepare to implement the corresponding moves, many interactive development environment encouraged to do so, because it emphasizes first and then a functional interface. Some software design model is the strategy that will be fixed before the code into the regular system of the final. Result is that the procedures and organizations around the user interface elements in the user interface elements of those moves, data storage, applications and functions of the code is used to indicate the way intertwined. In single-user system code structure can be so, because the system will not demand frequent changes. But for a large system such as large Web systems, or e-commerce systems to be applied. Model by incorporating data from a variety of access and control data can be separated to improve distributed system design. MVC design pattern is composed of three parts. Model is the application object, no user interface. Type in the screen showing that it represents the flow of data users. Controller user interface definition response to user input, the users responsible for the action against the Model into operation. Model View data updated to reflect the adoption of data changes.
    2. MVC design pattern,
    An MVC framework for the design of the system includes many models, but with MVC is most closely related to the following three models : Observer, Cambridge and Strategy.
    2.1 Observer models
    MVC through the use of purchase / notification form and the separation of the Model View. View to ensure that their content accurately reflected Model and state. Once Model content changes, there must be a mechanism to allow notification to the relevant Model View, View can be made relevant at the appropriate time updating of data. This design is also more general problems can be solved, the target separation, making a change to the target audience affect others, which targets those who do not know the details of the object being affected. This is described as Observer in the design model. Model type : Observer model is the object-oriented model, it is behaviour-based model. Model purposes : definition of hierarchical dependence relations between objects, or when a target value of the state change, all its dependent relationship with the object are notified and automatically updated. There are a variety of data may show a way, in different ways and may also show. When a way through a changed data, then the other should be able to show immediately that the data change and do accordingly.
    Effect :
    1. Abstract coupling. I only know that it has a target audience of some observers, the observers met each abstract Observer category simple interface, does not know their specific affiliation categories. This makes the coupling between goals and observers smallest and abstract.
    2. Support radio communications. Needless to notify designated observers goals, how to deal with the observer informed decisions.
    3. Possible accidents updated. We update logic, avoiding mistakes updated.
    2.2 Faculty model
    MVC is an important feature of View can nest. Nest can be used for any type of combination of local maps available, but also management of type nest. This thinking reflects the type and mix of components will be equal treatment design. This object-oriented design ideas in the area of Cambridge has been described as a design model. Model types : Cambridge model is the object-oriented model, it is also the structure type model. Model purpose : to target portfolio into tree structures to express "part-whole" level structure. Prepared for the use and combination of individual target audiences with the use of consistency.
    Effect :
    1. Definition of a target portfolio includes simple objects and the structure of the category level. Simple objects may be complex combinations of objects, and can be targeted portfolio mix. This customer-code used in the target areas can use simple combinations target.
    2. Simplify customer-code. Needless to know their customers - a mix of target audiences is a simple target or can use these items in a consistent manner.
    3. Easier to add new types of components. New components can easily be changed to a combination of customer-targeted codes.
    2.3 Strategy model
    Another important characteristic is the MVC can not change the View of changes View response to user input. This often requires a change in response to the logic of the system is very important. MVC to respond to the logic involved in the Controller. Controller of a category level structure could easily change to the original Controller appropriate, a new Controller. View Controller son used to achieve a specific example of such a response strategy. To achieve different response strategy, as long as examples of the use of different types of replacement will Controller. Also in the running time by changing the View Controller for users to change View of response strategies. This View-Controller relationship was described as an example of Strategy design pattern. Model types : Strategy model is the object-oriented model, it is behaviour-based model. Model purposes : definition of a series of algorithms, and their packaging, and ensure that they can replace each other, making algorithms can independently use its customer-change.
    Effect :
    1. Strategy category levels for Context definition of the relevant algorithms can be trusted or behaviour.
    2. Alternative methods of succession. If the direct successor Context, with different acts will be added Context act, the realization of which would algorithm mixed up with Context, Context hard to preserve and expand, but can not dynamically changing algorithms. Will be enclosed in a separate Strategy category algorithms to enable algorithm independent Context change easily cut over expansion.
    3. Can provide the same acts different date.
    4. Strategy-must understand what customers between different.
    5. Context and Strategy communications between costs.
    6. An increase in the number of targets.
    3. MVC in Web application system
    Now some of the distributed systems such as Web-based B2B e-commerce system, suitable for use MVC framework. Through analysis from the perspective of high-level applications can be a target divided into three categories. Category is shown for the target audience consists of a group of commercial rules and data, there is a category that is receiving requests to control commercial target to complete the request. These applications often need to change is shown, such as web style, color, but also need to demonstrate the contents of the display. And the business rules and data to be relatively stable. Therefore, said that the frequent need to change the View objects that the business rules and data model to be relatively stable target, and that the control of the Controller is the most stable. When the system is usually issued after the View objects by artists, designers or HTML/JSP system managers to manage. Controller target applications development personnel from the development and implementation of rules for commercial and business development personnel from the target data, database managers and experts in the field of common completed. Show in Web?? or customers - control logic can be Servlet or JSP, dynamically generated Html. Generally used Servlet better than using JSP. JSP will be better with the Html code of separate codes for page designers and developers of separation efficiency. Servlet and JSP can complete all complete functions, actually JSP eventually converted into a Servlet. And control of the target system exists in every level, the coordination of cross-layer moves. Contain business rules and data objects exist in the EJB layer (EJB-centred model) or Web?? (Web-centred model).
    3.1 View in the Web application system
    View of the system shows that it fully exist in Web??. General by JSP, Java Bean and Custom Tag. JSP can generate dynamic web content using Java Custom Tag easier Bean, but it can show the logic of packaging, and more conducive to modular trusted. Some well-designed in a number of JSP Custom Tag can even be used in different system duplication. Model for control of JSP and Java Bean objects. JSP through Java Bean objects to retrieve the data model, the Model and Controller object is responsible for updating the data on Java Bean. In general, can we devise all possible screen that users can see all the elements of the system. Based on these elements, to identify the public part of passive components and dynamics. Can consider the use of templates means to separate the content generated JSP public, also need to change their generation Html or JSP from a JSP templates to dynamically introduce these different parts (include methods). Another issue to consider is screen option, when dealing with End users request template automatically available to show that the concern that users must know what is the screen components. So can consider all screens on the definition of a centralized document, such as a document or text document java. Taking into account the possibility of changes in future document definition screens, the best use of text documents such as a XML document, so future changes to the recompilation. According to the URL and user input parameters to shine upon the results of a screen, of course, likely to be made on the basis of the outcome of the implementation of actions to choose different results screen. Therefore, the need for a request for matching resources with document (XML), if a URL request several different results, it must specify in the document need to control the flow (a controller object), as well as the corresponding screen different flows.
    3.2 Model in the Web application system
    Model objects represent business rules and business data exist in EJB layer and Web??. In J2EE norms, the system needs some data stored in the database, such as user account information (account model), the company's data (company model), some not recorded in the database. If a user browsing the current catalogue (catalog model), the contents of his shopping (shopping cart model). Which one of these models exist in the data according to their life cycle and scope to decide. In Web?? a HttpSession and ServletContext and Java Bean objects to store data in the EJB layer is a data storage and logic EJB to. Web?? the Java Bean objects stored in the model layer model of the EJB object data copy. Because there are many different EJB tier model targets, so Web?? through a ModelManager to control the EJB layer object model in ModelManger background model can be used for packaging methods. In the EJB layer and the rules have all the data into EJB model is inappropriate. If the database can visit the Dao object model into objects. Dao can be encapsulated and the specific details of the database in the world, if we can write a different table, a number of databases, or even multiple databases. If the orders can be a model for OrderDAO, it may have to deal with Order table, table and OrderItemLines OrderStatus table. Value can also consider the use of targets. Value can be a target of securing long-range targets, because every time the remote object attributes could be a long-range redeployment process will consume network resources. EJB objects in the distance can be used instead target. In the distance, one-time items to be targeted instead of the value of all attributes.
    3.3 Controller in Web application system
    Coordination with the Model View Controller object to the request of users into the system to identify incidents. In Web?? generally a MainServlet (or Main.jsp), and receiving all requests, it can use screen flow management devices (ScreenFlowManger) decided next screen. There is a general request processors RequestProcessor contains all requests are needed to be done to deal with logic, such as the request translated into system events (RequestToEvent). Acting processors usually also includes a request for ClientControlWebImpl, it is logical to deal with the EJB layer in Web?? Acting. In EJB layer, a layer for EJB tier Web ClientController provide the CD visit. Another StateMachine used to create and delete ejb handle Web?? sent to the incident. Controller Another important function is synchronous View and Model data. ModelManger contained in a ModelUpdateManger, it puts events into a Model System assembly that all the needs of synchronous Model, and then notify Listeners do synchronous operation.
    4. Concluding remarks
    In recent years, with the Internet technology development and the emergence of new business models, the Web is based on a large number of applications. On how to design these systems architecture, and gradually there has been some convergence of opinion, the most important point is that its structure should be rational in the open. Demand than ever faster development of technology and design concepts, systems for the future, the cost of upgrading the smallest, research software systems architecture still very useful and necessary.

    Bravo. And your point is?

  • The timeout period elapsed prior to completion of the operation or the server is not responding

    the timeout period elapsed prior to completion of the operation or the server is not responding.
    The error shows while executing a (select query) telerik report in MVC.

    Hello,
    Did you set the CommandTimeOut property of the SQL Command when you call the connection string to SQL Server?
    If your select query is complex or the data is larger, please try to specify connectiontimeout property to maximum integer value.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • The operation could not be performed because OLE DB provider "OraOLEDB.Oracle" for linked server ...

    Our setup is that we have two databases; a SQL Server 2008 database and an Oracle database (11g). I've got the oracle MTS stuff installed and the Oracle MTS Recovery Service is running. I have DTC configured to allow distributed transactions. All access to the Oracle tables takes place via views in the SQL Server database that go against Oracle tables in the linked server.
    (With regard to DTC config: Checked-> Network DTC Access, Allow Remote Clients, Allow Inbound, Allow Outbound, Mutual Authentication (tried all 3 options), Enable XA Transactions and Enable SNA LU 6.2 Transactions. DTC logs in as NT AUTHORITY\NetworkService)
    Our app is an ASP.NET MVC 4.0 app that calls into a number of WCF services to perform database work. Currently the web app and the WCF service share the same app pool (not sure if it's relevant, but just in case...)
    Some of our services are transactional, others are not.
    Each WCF service that is transactional has the following attribute on its interface:
    [ServiceContract(SessionMode=SessionMode.Required)]
    and the following attribute on the method signatures in the interface:
    [TransactionFlow(TransactionFlowOption.Allowed)]
    and the following attribute on every method implementations:
    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
    In my data access layer, all the transactional methods are set up as follows:
    using (IDbConnection conn = DbTools.GetConnection(_configStr, _connStr))
    using (IDbCommand cmd = DbTools.GetCommand(conn, "SET XACT_ABORT ON"))
    cmd.ExecuteNonQuery();
    using (IDbCommand cmd = DbTools.GetCommand(conn, sql))
    ... Perform actual database work ...
    Services that are transactional call transactional DAL code. The idea was to keep the stuff that needs to be transactional (a few cases) separate from the stuff that doesn't need to be transactional (~95% of the cases).
    There ought not be cases where transactional and non-transactional WCF methods are called from within a transaction (though I haven't verified this and this may be the cause of my problems. I'm not sure, which is part of why I'm asking here.)
    As I mentioned before, in most cases, this all works fine.
    Periodically, and I cannot identify what initiates it, I start getting errors. And once they start, pretty much everything starts failing for a while. Eventually things start working again. Not sure why... This is all in a test environment with a single user.
    Sometimes the error is:
    Unable to start a nested transaction for OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLSERVERNAME". A nested transaction was required because the XACT_ABORT option was set to OFF.
    This message, I'm guessing is happening when I have non-transactional stuff within transactions, as I'm not setting XACT_ABORT in the non-transactional code (that's totally doable, if that will fix my issue).
    Most often, however, the error is this:
    System.Data.SqlClient.SqlException (0x80131904): The operation could not be performed because OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLSERVERNAME" was unable to begin a distributed transaction.
    Now, originally we only had transactions on SQL Server tables and that all worked fine. It wasn't until we added transaction support for some of the Oracle tables that things started failing. I know the Oracle transactions work. And as I said, most of the time, everything is just hunky dorey and then sometimes it starts failing and keeps failing for a while until it decides to stop failing and then it all works again.
    I noticed that our transactions didn't seem to have a DistributedIdentifier set, so I added the EnsureDistributed() method from this blog post: http://www.make-awesome.com/2010/04/forcibly-creating-a-distributed-net-transaction/
    Instead of a hardcoded Guid (which seemed to cause a lot of problems), I have it generating a new Guid for each transaction and that seems to work, but it has not fixed my problem. I'm wondering if the lack of a DistribuedIdentifier is indicative of some other underlying problem. I've never dealt with an environment quite like this before, so I'm not sure what is "normal".
    I've also noticed that the DistributedIdentifier doesn't get passed to WCF. From the client, I have a DistributedIdentifier and a LocalIdentifier in Transaction.Current.TransactionInformation. In the WCF server, however there is only a LocalIdentifier set and it is a different Guid from the client side (which makes sense, but I would have expected the DistributedIdentifier to go across).
    So I changed the wait the code above works and instead, on the WCF side, I call a method that calls Transaction.Current.EnlistDurable() with the DummyEnlistmentNotification class from the link above (though with a unique Guid for each transaction instead of the hardcoded guid in the link). I now havea  DistributedIdentifier on the server-side, but it still doesn't fix the problem.
    It appears that when I'm in the midst of transactions failing, even after I shut down IIS, I'm unable to get the DTC service to shutdown and restart. If I go into Component Services and change the security settings, for example, and hit Apply or OK, after a bit of a wait I get a dialgo that says, "Failed ot restart the MS DTC serivce. Please examine the eventlog for further details."
    In the eventlog I get a series of events:
    1 (from MSDTC): "The MS DTC service is stopping"
    2 (From MSSQL$SQLEXPRESS): "The connection has been lost with Microsoft Distributed Transaction Coordinator (MS DTC). Recovery of any in-doubt distributed transactions
    involving Microsoft Distributed Transaction Coordinator (MS DTC) will begin once the connection is re-established. This is an informational
    message only. No user action is required."
    -- Folowed by these 3 identical messages
    3 (from MSDTC Client 2): 'MSDTC encountered an error (HR=0x80000171) while attempting to establish a secure connection with system GCOVA38.'
    4 (from MSDTC Client 2): 'MSDTC encountered an error (HR=0x80000171) while attempting to establish a secure connection with system GCOVA38.'
    5 (from MSDTC Client 2): 'MSDTC encountered an error (HR=0x80000171) while attempting to establish a secure connection with system GCOVA38.'
    6 (From MSDTC 2): MSDTC started with the following settings: Security Configuration (OFF = 0 and ON = 1):
    Allow Remote Administrator = 0,
    Network Clients = 1,
    Trasaction Manager Communication:
    Allow Inbound Transactions = 1,
    Allow Outbound Transactions = 1,
    Transaction Internet Protocol (TIP) = 0,
    Enable XA Transactions = 1,
    Enable SNA LU 6.2 Transactions = 1,
    MSDTC Communications Security = Mutual Authentication Required, Account = NT AUTHORITY\NetworkService,
    Firewall Exclusion Detected = 0
    Transaction Bridge Installed = 0
    Filtering Duplicate Events = 1
    This makes me wonder if there's something maybe holding a transaction open somewhere?

    The statement executed from the sql server. (Installed version sql server 2008 64 bit standard edition SP1 and oracle 11g 64 bit client), DTS enabled
    Below is the actual sql statement issued
    SET XACT_ABORT ON
    BEGIN TRAN
    insert into XXX..EUINTGR.UPLOAD_LWP ([ALTID]
              ,[GRANT_FROM],[GRANT_TO],[NO_OF_DAYS],[LEAVENAME],[LEAVEREASON],[FROMHALFTAG]
              ,[TOHALFTAG] ,[UNIT_USER],[UPLOAD_REF_NO],[STATUS],[LOGINID],[AVAILTYPE],[LV_REV_ENTRY])
              values('IS2755','2010-06-01',
    '2010-06-01','.5',     'LWOP'     ,'PERSONAL'     ,'F',     'F',     'EUINTGR',
    '20101',1,1,0,'ENTRY')
    rollback TRAN
    OLE DB provider "ORAOLEDB.ORACLE" for linked server "XXX" returned message "New transaction cannot enlist in the specified transaction coordinator. ".
    Msg 7391, Level 16, State 2, Line 3
    The operation could not be performed because OLE DB provider "ORAOLEDB.ORACLE" for linked server "XXX" was unable to begin a distributed transaction.
    Able to execute the above statement successfully without using transaction.We need to run the statement with transaction.

  • MVC - Organizing models and managing GUI windows

    I'm having difficulty organizing my MVC models and basically controlling the whole application in general. My application works, but all the controlling logic is being dumped into the main class (Main.java). Here's a simple example of the problem I'm having:
    Objectives
    1) Display a list of Companies; i.e. Sun, Microsoft, Adobe, etc. (JFrame with a JList)
    2) The user select a Company and it pops up a new dialog with a list of Employees. (JDialog with a JList)
    Here are the classes I came up with:
    Models:
    1) CompanyListModel
    2) EmployeeListModel
    Listeners:
    1) CompanyListener
    Views:
    1) CompanyListFrame
    2) EmployeeListDialog
    Domain Objects:
    1) Company
    2) Employee
    And then there's the main application class. To implement the above objective, I've been using my main class to control the GUI.
    Here's an example of how I've implemented it.
    public class Main implements CompanyListener {
        /** Creates a new instance of Main */
        public Main() {
            CompanyListModel companyModel = new CompanyListModel();
            companyModel.addCompanyListener(this);
            CompanyListFrame gui = new CompanyListFrame(companyModel);
        // A company was selected.  Open a new dialog and display the employees
        public void companySelected(CompanyModel companyModel) {
            Company company = companyModel.getCompany();
            EmployeeListModel employeeModel = new EmployeeListModel(company));
            EmployeeListDialog = new EmployeeListDialog(employeeModel);
        public static void main(String[] args) {
            new Main();
    }My program is similiar design wise to the above, but contains many more classes. I'm still using my main class to control GUI logic (popping up new windows and creating models, etc). Thus, my main class implements like 5 different listeners. I'm sure this is a really poor design choice, I just don't know how else to implement it.
    I should not nest models... correct? I was thinking about nesting the models, i.e. CompanyListModel contains an EmployeeListModel, but then the CompanyListModel will need to spawn the EmployeeListDialog when a Company is selected, right? Thus, I'd be mixing the view with the model.
    Please provide some advice! :( Thanks!

    I'm sorry, I read your reply about 3 times and I've
    spent the last 20 minutes trying to implement it.
    I'm just not sure how the controllers are involved.
    Could you possibly provide source code for the
    controllers (and any part of the models / views that
    communicate with the controller)?No source code. Read about the MVC pattern.
    I feel like this is a wasted effort. I'm the sole
    entry level programmer at my company and I have only
    one year real wold experience . I work with about 10
    other senior level (microsoft) programmers and none
    of them code in this fashion. All of our
    applications are desktop applications using C#,
    C/C++, or scripting languages.What's a wasted effort? You posting a question? Me posting a response? You writing Java? You trying to think about how to do this properly?
    So why are you using Java if you're in a Microsoft shop? How's this working out with your co-workers?
    I feel like if I worked on a project with one of
    them, they would criticize me for using MVC and
    "complicating" such a simple issue.That's usually because Microsoft likes tying a particular text box to a column in a table. If you change the textbox value you change the database. Nice and easy, right?
    In trying to implement this solution, my workspace
    now has a huge load of classes for something so
    simple:
    Company
    CompanyFrame
    CompanyListController
    CompanyListListener
    CompanyListModel
    CompanyListPanel
    Employee
    EmployeeListDialog
    EmployeeListModel
    EmployeeListPanel
    Main
    11 classes and I left out the Emp Controller and
    Listener to simplify the example. The more classes
    that you have, the slower the application startup
    time. Moving the Views to JPanels as you suggested
    seemed smart but it wound up making it more
    difficult. I'm using NetBeans and Matisse and I
    don't believe you can use another JPanel class in the
    GUI editor unless you make it a bean.
    Traditionally, I would have implemented as follows.
    I would have completed it in 5 minutes and it would
    be much easier to understand what's going on:
    Company
    CompanyFrame - contains a list of companies
    Employee
    EmployeeListDialog - contains a list of employees
    Main
    Of course doing it this way I'd be mixing data with
    the view, but is that always a bad thing or is it
    only bad for large scale applications? Should MVC
    not be used for small modules like this?For small modules that are nothing more the CRUD operations, it might be that a simpler approach is fine. (PS - CRUD stands for Create/Read/Update/Delete, standard relational operations on tables. I'm not commenting on you or your code.)
    It only becomes a problem when that "simple" CRUD application decides to branch into something bigger. The approach of mingling view and data can become problematic then.
    It's still possible to have a clean application for small apps. I think most Microsoft programmers do it that way because the wizards and stuff they're used only allow it to be done that way.
    The reasons why I'm going away from my old "academic"
    programming practices is:
    1) I want to become a better programmer of course!Kudos to you. At least you're still thinking about it.
    2) There's alot of database queries in this
    application so I wanted to separate that from the GUI
    as much as possible. Thus, each model knows how to
    query the database and it's all done on separate
    threads.That's good motivation, too.
    I'd really like to do this right. If you could
    provide source that would be great. Also, are there
    any good books on desktop GUI development geared
    towards Java (or even C#)?I don't write for the desktop, so I'm not much help.
    I already purchased the e-book Desktop Java Live,
    which is great but they don't go into detail about
    MVC and instead use Model-Presenter which has been
    retired (according to Fowlers website). I found that
    section fairly confusing so I figured I'd start with
    MVC since it's more widespread (?).If you're reading Martin Fowler you're doing well.
    Thank you.I'm sorry that I'm not more helpful.
    %

  • Collections in MVC architecture

    My question concerns the use of collections of entities in a database-access MVC architecture. An example similar to my situation would be a Corporation, which (among other attributes) has a collection of Departments, which (among other attributes) has a collection of Projects, which (among other attributes) has a collection of Employees.
    Sometimes, I may want information such as all the Employees in the corporation, which would necessarily involve retrieving all the entities from the database. Other times, I may only want the employees in a certain Department, in which case I wouldn't want to waste the time population all the Department beans with Project and Employee information.
    Basically, I'm not sure how to best go about populating Javabeans that contain other Javabeans containing other Javabeans. Obviously, when I go to retrieve a Corporation bean, I don't always want all the Departments, Projects, and Employees. However, it seems like it would be using a lot of redundant code to have one factory that returns just the Department base information (without it's Employees), one factory that returns all the Departments and their Projects (but not the Employees), one factory that returns all the Employees for a given Project (but not ALL the Projects and their Employees), and so on.
    I've read plenty of MVC tutorials (and even taken a course in it), but I've never really seen a basic situation such as this addressed. What is the best way to go at this situation? Does anyone know of any tutorials/examples that are similar to this situation?

    First let's say your post reminded me my previouse Project where i faced exactly this topic.( not a problem may say ) :)
    That's it orr94 ! No MVC related topic, says about these. this may be referenced in your experience of Programming and System Design, with the knowledge of OOP, implementing DBs, Performance issues, and so on...
    Simply i can tell you, by my experience, try to feel ( and then find ) what your system is supposed to do? and how it does that?
    In a situation when you should give many reports, collecting your information, and the main part is GIVING THE LISTS OF REPORTS, just try to load all of your data. ( here first time spends much time, but after that no time is needed for DB operations. you every time read from your objects ( makin' them Updatable )
    But if number of the times you should gather this information, is such small that it dosn't actualy needed to read more than wanted.
    So see that there is NO GENERAL ANSWER to this question. ( i found it on that project, spending a month to find any answers. )
    YOU SHOULD FIND YOUR ANSWER. try feeling your system by real-time TESTS, that would make you sure about a solution.
    P.S. Now as a tip
    Create a Database Logic Bean which all related methods go in for CRUD operations on entities, then as friends said, try puttin some flags for reading entities ( e.g in your constructors which use DB bean methods )
    and then try different approaches readin the data, see which makes sense to your system.
    As the last point, what chintat said ( A Getter() which reads the from db that lists ) is not a good solution, where each call to that getter(), where it'd be many calles, attemps to access db!!! you should read once, then getter() returns a reference ( maybe readonly ) to that list.
    I think the question is when to read, where YOU SHOUD FIND THE ANSWER. ;)
    nice post, i hope it helps. ;)
    Behrad

  • Re: MVC abuse

    It's possible we're talking about two separate things. However, the Model-Controller-View paradigm specifically allows for the maximum amount of flexibility. Model in this case generally means the data model, or the data source.
    For example, let's take a typical eBusiness portal-slash-web site. Normally you have a series of web pages (the HTML output, and the forms) representing the view aspects, some sort of business logic (the Servlets and other class files) representing the controller, and the database itself as the model. Say, a human resources application that determines your available sick days and vacation days.
    If the system was designed according to MVC principles, then you should be able to swap any one of these three components without affecting the other two. Let's say in theory that two years down the road, your boss decides they can't afford to pay the Microsoft Tax, and rather than conducting business through a web browser, he wants to switch to a desktop Java application. You should then be able to code a swing component (view) that calls the existing business logic (controller) and database access (model) code. Similarly, if you decide to change the database from say Sybase to Oracle, then all you need to do is change the database access (model) aspect.
    In your example, the advantage of a MVC architecture would be that all you need to do is change the business logic in order to add new operations. Or alternatively, if you changed the model, the controller and the view should effortlessly recognize the changes in the model without any intervention on your part. Realistically, especially when it comes to web pages, at least two if not all three components probably need to be changed, which is why most people don't bother following the philosophy closely.
    I do stress it's possible we're talking about two different MVCs; we do have different definitions of "model" for example. But in theory, if your application was MVC-compliant, then you should never have any maintenance pains - it's so well designed and modular that changes made to one component don't break the others.

    I hope I have not annoyed everybody yet.
    I would like to try to explain myself one more time as I still have not figured out the answer for myself.
    For the sake of argument lets separate Model component in two layers and call them Logic and Flow.
    Logic consists of pure business logic methods/information and includes cached, SQL statements, calculating the result (in whatever type), etc.
    Flow ties multiple Logic pieces together into one invocation block.
    Lets say form validation is a separate notion. Broken down this way the Model component would look as follows (l: means logic, f: means flow)
    l: process session, load information
    f: if OK invoke registration logic. Get username from 3rd party token, business ID from session manager and password from user form
    l: create account
    f: if not OK return to form JSP, if OK set up purchasing parameters (price, etc.) and proceed to purchasing; to identify payment attributes use payment reference table from MySQL DB, business ID from session management, date of birth, etc.
    l: add purchase record to the database together
    f: if not OK forward to error JSP, otherwise update account tokens
    In the above example, Logic components do not change almost ever. However Flow can depend on systems involved in the particular task and has to be flexible if the directives do not form just one-two complete Model elements.
    So, Logic elements can (and have to) be compiled Java classes deployable as JAR units. Flow elements have to be lights weight scriptable as we do not want to have a separate Action class for every marketing request and we do not want to break the flow into multiple HTTP requests where it is not needed.
    Either because I do not understand these systems yet good enough or for whatever other reason I do not see any reasonably easy way to implement such business logic flexibility in Struts or in JavaServer Faces.
    PS Please forgive a little clumsy example. I did not have time for more sophisticated one but I do have similar real life examples.
    PPS I in no way imply that MVC is a bad concept. I am just trying to figure out whether it applies for a certain class of problems (flexible and restructurable business requiements)

  • Shine J2EE Appplication Framework - A New MVC -JWMS-Ajax Framework

    Hi Dears
    Shine is a Java-J2EE Application Framework/JWMS(Java Web Model Service)Framework/MVC Framework/Service Oriented Framework. Shine Includes Ajax Libs/Server API/J2EE Architecture. Shine Supported JSF/Spring/AspectJ/Struts/Hibernate/...
    You can use Shine Framework for Implement ERP Web Based Application, Web Based Operating System, WFM Web Based Application, CRM Web Based Application, HRM Web Based Application, BPR Web Based Application, Or ... Web Based Application, Shine Registered in Source Forge.
    This Framework is a Java Service Oriented Framework for Web Based Project. This Framework include:
    * MVC (Model View Controller)
    * Ajax
    * Service Oriented Scope
    * JWMS (Java Web Model Service)
    Shine Framework is a Java Web Model Service Framework.
    Shine Framework is very easy, stable. You can use other Framework by Shine Framework:
    *Hibernate
    *Struts
    *Spring
    *And Other Framework
    JWMS And Shine J2EE Framework ?
    JWMS is a J2EE Architecture for implement Service Oriented Web-Based Appliction you can get more information about this and Shine J2EE Application Framework by -> J2EE And Service Oriented Programming :
    http://j2sos.googlegroups.com/web/J2EE_And_Service_Oriented_Programming+(English).doc?gda=VCp-YWkAAABaK1bFJn7XMhSpdkjvrT6Pd5MA3H6uh5taxEUxR6gwSUWwa05VcrqgHRSC0l_xcf_5FoxLEBXNbyq4-bBifvraWOZGQE6LgzeTU5Q6eFny4M-fIZvKNC5H8bRWhAn1psCECKgQbmraGdxlZulaYnsh
    Or
    http://j2sos.googlegroups.com
    Report: http://sourceforge.net/tracker/?group_id=244136
    Forum: http://sourceforge.net/forum/?group_id=244136
    News: http://sourceforge.net/news/?group_id=244136
    Wiki: http://shine-app.wiki.sourceforge.net/space/pagelist
    Rank: http://sourceforge.net/project/stats/rank_history.php?group_id=244136&ugn=shine-app
    Shine J2EE Framework Rank in Sourceforge is 14!
    Shine J2EE Framework: http://sourceforge.net/projects/shine-app/
    Site: www.J2SOS.org
    Special Thanks Oracle! For this Part! Your Site is very Active about J2EE - Java!
    This paper is no image paper !!!!!!!!!!!!!!!!!!!
    J2EE and Service Oriented Programming
    Authored by: AmirSam Bahador
    Level:
    Advanced
    Contents:
    Introduction
    - The purpose of compilation this essay
    Chapter 1: Basic concepts of J2EE
    - Servlet and JSP
    - MVC
    - MVC or JWMS? That is the problem? Perhaps both!
    Chapter 2: Basic concepts of Shine Framework
    - What is "Shine Framework�?
    - The components of Shine Framework
    - Implimentation of an application by Shine Framework
    Chapter 3: The objects of Shine Framework
    - The types of objects in Shine Framework
    Chapter 4: Engineering & Communication items
    - The communication of Shine Framework with the other
    existing Frameworks
    - The major purpose of Shine Framework
    Introduction
    The purpose of compilation of the this paper
    A few years ago, when I was the software architect of a big project with J2EE, I advised some of the modern tools of that time to the project manager. He acknowledged it. Therefore, we began deploying our Enterprise on Java platform. However, we encounterd with many problems, as we got ahead the project. Our tools were included Struts Framework, Spring Framework & Hibernate.
    I convinced that MVC architecture is the best option to develop macro projects! However, I believe it now, as well. Couldn't it be more completed? In developed Enterprise projects, an advanced architecture is required to divide the project, technically. The project was successfully finished after one year, but my mind was busy with it for a long time!
    Then, I began implementing an Application Framework and registered it in Sourceforge.net as an Open Source Framework. I developed some Enterprise projects & some other J2EE frameworks, as well. I achieved a good result! The velocity of implemention & developing projects increased up to 50%. Subsequently, by cooperation of my elected students who had worked with Application Framework, I established an organization, named J2SOS, to protect & develop this Application Framework.
    Fortunately, my students were so skilled that each took a chief task in big J2EE projects.
    Their experiences had a practical affect on development of Application Framework as well as the organization.
    Therefore, it is required to write down my & my yesterday students (my today co-workers) experiences. This was the outset to write the present paper!
    Chapter 1
    The basic concepts of J2EE
    Purposes
    In this chapter, we do our best to introduce J2EE basic concepts.
    Servlet & JSP
    If you ahve ever worked with JSP & Servlet, you know that Servlet is so proper for processing functions but there are particular problems with it in displaying functions.
    JSP is applied reverse to Servlet. Thus, what is the solution? To apply both JSP and Servlet together!
    What is MVC?
    MVC is an easy way to use JSP & Servlet together. In MVC architecture, the request will be processed by a Class (Servlet) and the appropriate response will be showen by JSP.
    n the above Servlet Class, the validation operation, etc will be done.
    Nowadays, there are numerous Frameworks which will assist you to use MVC Framework architecture. Struts Framework is the most well-known one.
    MVC or JWMS ? That is the problem! Perhaps both!
    MVC is a powerful architecture, but it is required an advanced architecture to implement developed projects.
    Today, web applications are well developed which complicatethe work for programmers & developers.
    To clarify it, see Google site! Google Web Application enjoys numerous services, each have a special service for the users.
    For Instance, Gmail service, E-Mail or by SearchEngine, the users can search for websites, pictures, etc.
    These services have certaily close communication with each other.
    If the services do not use a particular architecture, the Google will encounter with various problems.
    In Service Oriented architecture, each part of the program is a service programme. For example, E-Mail service, SearchEngine service, etc.
    for get full this paper plz goto : J2EE And Service Oriented Programming
    in :
    http://groups.google.com/group/j2sos
    Or
    http://j2sos.googlegroups.com/web/J2EE_And_Service_Oriented_Programming+(English).doc?gda=-C13JmkAAABaK1bFJn7XMhSpdkjvrT6PLb1WFhhPKkBftsH3LvtvGEWwa05VcrqgHRSC0l_xcf_5FoxLEBXNbyq4-bBifvraWOZGQE6LgzeTU5Q6eFny4M-fIZvKNC5H8bRWhAn1psCECKgQbmraGdxlZulaYnsh

    iabstudio have been engaged in a persistent Usenet and webboard spamming and astroturfing operation since the beginning of this month. Google has the scoop at http://groups.google.com/groups?q=www.iabstudio.com&hl=en&lr=&c2coff=1&scoring=d&start=0&sa=N&filter=0 note in particular the same IP address is used to post both their spam from iabstudio themselves and from people who claim to be satisfied users. If you do not like spamming and dishonest, don't use the product.

  • Implementation of MVC

    hello
    Ive read about the Model-View-Control Architecture and understood it ,theoretically atleast!! Ive found huge coding fr explaining the concept. Thus I am unable to visualise this pattern in terms of coding. Can someone please explain it to me with a simple example and some method abstractions in there..
    Thanks a ton (in advance)
    Priyank

    ok..i think ill give u a brief idea of what i am
    implementing..thn itll be easier fr u to visualise my
    condition..(n yea its swings only!!)
    I have different functionalities like add search edit
    update delete tht is to be performed on some data.No surprise there - these are standard CRUD operations on relational tables.
    Ive designed these GUIs. ive done some
    layerwork..like implemented the DTO,Service,DAO layerOK. Does that mean you've written code? What does "design" mean to you? A sketch of the UI?
    Want a great example of what yours should look like? Download and run SQL Squirrel. It's a beautiful UI for databases, all in Swing.
    My DAO layer interacts with db...Yes, that's what DAOs do.
    ( I DONT knw abt RMI programming) RMI isn't necessary in the DAO.
    i use flow of control divided amongst
    these layers. ex:: Ive displayed my search results in
    frm of a table..which works on MVC..i want to extend
    the same to my main coding....example...
    ADD feature::
    Model = all the fields the user may enter
    View = my user design
    Control = Operations being performed on my ui in sync
    with model+ some setter methods
    Nw first of all i want to confirm my understanding
    with this example and how do i implement this feat
    with MVC...give me some tips so tht i can code it
    Thanks..
    PriyankTips? Go download SQL Squirrel and use that.
    If you must code it, make yours as good as SQL Squirrel. That'll be a nice, educational job.
    Stop worrying about making the perfect MVC implementation. Get something working and see what you can do to make it better once it's running.
    %

  • MVC JSP and Servlets

    I'm creating JSP pages to represent the view of the site and servlets to get the request and decide which JSP page to load next.
    When the servlet recibes a request it generally has to query the database to get some data and then show it back to the client. To do this the servlet calls other object that is responsible to query the database and fill a ResultSet.
    My question is: what is better, to load a Vector with special objects containing the data in the ResultSet and then return this vector to the jsp page for it to use it, or may a return directly the ResultSet to the jsp page? With the first option I have to cycle in the resultSet to load the vector and then cycle through the vector to show the results. With the second option I cycle only once, but I isolate from the database (column names, order in which the things are returned...)
    I hope anybody can give me an opinion.
    Thanks

    There are a few things wrong with this:
    1) MVC -> The View should have no Model work init.
    For the MVC pattern, the database is Model. Use
    a
    a ResultSet in JSP, and now your View is lockedto
    a
    database with a specific column format.
    Huh? I think that's backwards. The View willalmost
    always require Model data unless it is a staticpage.
    The Model, however, should be agnostic about what
    t View technology it serves. (The Controllerbridges
    the two). Also, I would call the database the
    Persistence or Integration tier, a separateconcept
    from the Model, though intimately coupled to it.I meant the work of the model (gathering the data to
    a presentable form) is moved to the View. Yes, the
    View needs to know the Model to be able to display
    its data. But the Model should handle the data
    collection.
    Fair enough. I might have read it backwards as well.
    >>
    2) Any web application (or any application in
    general) wether it uses MVC or not, should still
    follow a 3 tier approach: Persistance (Data),Domain
    (logic), Presentation (View, output) (note, thisis
    different then MVC.) By moving the ResultSet inthe
    JSP you would be dragging the Persistancemechanism
    up two layers. Generally, a layer should only
    see
    the layer just below it (Presentation seesDomain.
    Domain sees Persistance. Persistance never sees
    s Domain or Presentation. Domain never sees
    Presentation. Presentation never seesPersistance).
    >
    I agree that Persistence and View should not seeeach
    other. However, Model and Persistence must. How
    else do you write a DAO? Or even use a mapperlike
    Hibernate?First the Model doesn't fit into just one of the
    three tiers (Persistance Domain and Presentation).
    The Model of MVC is both the Domain logic and the
    e Persistance mechanism.
    To me, at least, Domain logic = model. The terms I have normally read is either "business tier" or "model domain". "Patterns of Enterprise Application Architecture", M. Fowler. Though, I will concede that this tier has the least well defined set of terms.
    But for the three tier architecture: the domain sees
    the persistance. You always see one layer down. So
    Domain sees the persistance and pulls the data into
    the model. So a DAO would be part of the Domain, the
    logic of collecting the data from the database to be
    used in the application (in the correct object graph
    and all that). The persistance though, doesn't see
    the domain.
    Hmm, I'm not sure which direction 'down' is. And even if 'down' meant towards the back-end or away from it, what about the controller? It parses view requests and delegates them to the model. The results are then normally returned to the controller for dispatch to a view. So, the controller seems to have its fingers in all the tiers except integration and persistence, at least to me. I think of the controller as the 'middle man' between model and view that lets the model be agnostic to the view. The view and controller will to some extent always be coupled. However, the model theoretically exists on its own.
    Half of me thinks that I have a different view on
    where the Domain and Persistance border is. I
    thought the DAO or the Data Mapper would be in the
    Domain, whereas you seem to be saying they are in the
    Persistance layer?
    That's interesting. I don't know if there is an absolute answer. We are dealing with the O/R boundary, and the DAO straddles the boundary. However, one could, at least theoretically, change persistence strategies. What would change? Not your model objects, but your persistence tier objects. Though, again, the definition is nebulous.
    3) From a Practical matter:
    In many DBs, if you close the connection fromwhich
    the ResultSet was derived, the ResultSet is
    closed
    and you get errors if you try to access it. Ifyou
    don't close the connection in the Servlet beforeyour
    JSP, then you have to do it in the JSP. Thatmeans
    even more DB bleed through to the JSP, and theM->V.
    Or, you could just not close the Connection and
    d allow it to hang around and create memory
    leaks.
    >
    Yepper.
    4) Also practical:
    To use the ResultSet in JSP is going to require
    scriptlet code. This is ugly and hard to manageand
    update later. You have to wrap your code in
    try{}catch(SQLException e) {} finally {}, so
    the
    code is even uglier and harder to manage(especially
    if you end up not touching the thing for monthsand
    forget what you had done - or god forbid someoneelse
    has to keep up your code). You could make acustom
    tag to handle it, which makes the JSP easier toread,
    but does further damage of spreading the dataaccess
    code all over the application.
    Definitely!
    5) Practical:
    When you do this sort of thing, then later
    decide
    to
    change the way the database is set up, digging
    all
    the places affected by the simple renaming of a
    column, or refactoring of which columns are inwhich
    tables becomes a heavy effort. Keep it all in a
    DataAccessObject, and changes in DB becomestrivial
    to keep track of in your code. It is all in one
    place, and can be tested off line. Harder stillis
    if you change persistance from a database to anXML
    library, or some directory lookup or something.You
    would have to completely refactor your Servlet
    and
    your JSP. Put it in a DataAccessObject and allyou
    have to do is switch out the DAO instance. The
    change is transparent to the Servlet and the JSPas
    long as you maintain an interface.
    Just keep in mind that for the vast majority of
    projects, the RDBMS technology is rarely switched.I
    generally program to interfaces in my Model, butmy
    Persistence tier is always so tightly coupled thatI
    simply use POJO's without an interface.
    6) Practical:
    I have elluded to this several times, but I will
    state it specifically. When you isolate the
    persistance and data access to its own layer
    then
    you
    can swap out the presentation (the View and the
    Controller) when testing all your persistance
    operations. This means the data is independent
    of
    the container. You can run it out of theServlet/JSP
    environment and it will behave EXACTLY as it
    will
    inside the JSP environment. You can designrobust
    tests, debug, redesign, re-edit, etc... muchquicker.
    Then, when all done, plug it into your web app
    p without worry.
    Great point.
    Of course, Numbers 3 -> 6 are the reasons why
    following 1->2 (MVC and the 3 Tier architecture)are
    such good ideas.- Saish
    BTW, please take all the above just in the interest of having a good discussion. I have been wrong many times before! ;^)
    - Saish

  • How to run update operation from MBO

    I need to update the data from MBO update operation.
    but can you guide me for input how to set the personalised key.
    Regard
    Ali

    You have to set the PKs from program. Follow the below steps:
    Create a new key on the screen where custom menu item is created. Click on screen > Keys>Add. Ex. key name "CustomKey".
    From the properties of the menu item created, map the PK with the key created (ie.CustomKey ).
    Write the below code inside custombeforesubmit method inside custom,js file
    hwc.customBeforeSubmit = function(screenKey, actionName, dataMessageToSend) {
         if(screenKey =="Details_Screen" &&      actionName=="menuItemCallbackTimeSheetMBOCallUpdateQuery " ){
           var myNewValue1 = new MessageValue();
           myNewValue1.setKey("CustomKey");
           myNewValue1.setValue(""+value);//Value you got from screen
           myNewValue1.setType("TEXT");
           var mvc = dataMessageToSend.getValues();
           if( mvc ) {
           mvc.add( myNewValue1.getKey(), myNewValue1 );
    Midhun VP

  • MVC data exchange patterns

    Hi,
    I've been reading about the Model - View - Controller pattern in Java, but can't seem to find the thing I need. My application has a GUI that contains several JComponents in the form of classes,most of which extend JPanel. As far as I understand the MVC in Java, graphical components have underlying models that hold the data that the component visualizes. When extending JPanel, I have created a 'model' object for each of my different panels. Those classes are simple information-holders with mostly get/set methods and little else. One JPanel paints some Java2D graphics that I want to be able to export as image when the user chooses that option from a menu. The menu is contained in the main GUI class, and so is the component with the drawing. I am looking for a good way to do this, some sort of standard pattern. My own ideas so far are these:
    1. Pass a reference of the GUI to the menu, so the menu can access the component where the image is and get it itself. (really ugly way but will probably work).
    2.The menu notifies its listener- the GUI -that the user pressed something. The GUI calls the get-methods, collects whatever is needed, and does whatever is needed(saves the file in a certain format in my case). (keeps the menu a purely view-element, but makes the main GUI class deal with the reset of the work.
    3.Have some sort of controller that fetches the data and saves the file. With this one the problem is where is the controller? Does the menu have a reference to it, or only the main GUI? So far I don't have a specific controller-class, because the whole design looks like a bunch of smaller MVC's into a bigger one(all the models for the components are properties of a bigger model class that is responsible for creating them), and I just didn't know where to place that controller.
    I'd very much like to hear your thoughts about those three options, and suggestions for how to do it the 'right way'.

    bee2525 wrote:
    Hi,
    I've been reading about the Model - View - Controller pattern in Java, but can't seem to find the thing I need. My application has a GUI that contains several JComponents in the form of classes,most of which extend JPanel. As far as I understand the MVC in Java, graphical components have underlying models that hold the data that the component visualizes. When extending JPanel, I have created a 'model' object for each of my different panels. Those classes are simple information-holders with mostly get/set methods and little else. One JPanel paints some Java2D graphics that I want to be able to export as image when the user chooses that option from a menu. The menu is contained in the main GUI class, and so is the component with the drawing. I am looking for a good way to do this, some sort of standard pattern. My own ideas so far are these:
    1. Pass a reference of the GUI to the menu, so the menu can access the component where the image is and get it itself. (really ugly way but will probably work).
    2.The menu notifies its listener- the GUI -that the user pressed something. The GUI calls the get-methods, collects whatever is needed, and does whatever is needed(saves the file in a certain format in my case). (keeps the menu a purely view-element, but makes the main GUI class deal with the reset of the work.
    3.Have some sort of controller that fetches the data and saves the file. With this one the problem is where is the controller? Does the menu have a reference to it, or only the main GUI? So far I don't have a specific controller-class, because the whole design looks like a bunch of smaller MVC's into a bigger one(all the models for the components are properties of a bigger model class that is responsible for creating them), and I just didn't know where to place that controller.
    I'd very much like to hear your thoughts about those three options, and suggestions for how to do it the 'right way'.<caveat-emptor disclaimer="I'm *NOT* an OOP design guru. Several of my collegues leave-me-for-dead when it comes to designing/architecting for intangible, cross-cutting, non-functional concerns." />
    They're all "not _too_ bad" as far as I'm concerned.
    Option 1 is inflexible, but it does have the advantage of simplicity.
    Option 2 is almost infinitely more flexible than 1... except I cringle (a bit) at the phrase "the GUI ... does whatever is needed"... Dude, GUI's don't do stuff... they just display stuff, that's why they're called "user interfaces"... so there's got to be a better way.
    Option 3 trys to address the code-smell inherent in option 2... but all it's really done is moved the logic from one place it doesn't belong to some other place it doesn't belong.
    Option 4 ... Hmmmm... So let's see here... The business at hand is retrieving, displaying, ?editing?, and saving pictures, right? These "operations" might be grouped together under the banner: "picture management". Picture management would (IMHO) be best done by public class PictureManagerV1 implements PictureManager.
    What I'm trying to say is that MVC is NOT the whole picture... often there are other "layers" involved.... especially a business layer.
    The general steps are:
    1. the controler creates the business layer
    2. the controler asks the business layer to "initialise" the model.
    3. the controler creates the view, passing it a reference to the business layer.
    4. the view interpolates user-requests into business requests, and presents the replies.
    So what we've done is basically to "split the controler" into two.
    Part A: is specific to this app... it knows "a bit" about everything... the business layer, the specific view, and (almost inevitably) this specific model.
    Part B: is the "business layer" which ecapsulates the business operations. It does NOT know about this specific view (though it knows that there is a view)... and therefore theoretically may be reused "out of the box" to provide "business level services" in any application.
    To achieve this "reusability" the "rule" is that you only cross the line between controler and business via an interface (at minimum).
    The controler basically just "sets everything up" and then stands back and watches it play until the end of the game, when it's responsible for cleaning up...
    The view asks the business layer to perform a service. When the view needs to be updated as a result of changes to the model then it's the business layers responsibility to "call back" the view... which it could do via a passed-in "event" interface... or it you could go-the-whole-hog and use a "subscription" pattern.
    +-----------+
    | Controler | creates     +----------------+ uses       +--------------+
    | + main    |------------>| Business       |----------->| DAO          |
    +-----------+             | + transactions |            | + operations |
              |               +----------------+            +--------------+
              |                  ^          | notifies          | persists
              |                  | uses     |                   V
              | creates       +--------+    |         +-------------------+
              +-------------->| View   |<---+         | Model (DTOs)      |
                              | + show |              | + get/set         |
                              +--------+              +-------------------+Likewise the business layer could "inject" listeners into the model itself, but that presumes that model is "smart", and I personally prefer a "dumb" model... just a graph of simple data transfer objects (the bean, the whole bean, and nothing but the bean) with "the smarts" all ripped-out and stuffed in the "bottom" of the business layer... which naturally leads us to recognising yet another distinct layer, the Data Access layer, which exposes the "raw" CRUD operations: create, read, update, delete (and I personally add locate / find to that list) this alleviating the business layer from the concerns of dealing with the details inherent in what-ever data-storage mechanism (like flat-file vs LDAP vs distributed heirarchical-mash-relation database management system) we happen to be using... and again "the divorce is consumated" with the rule: allways cross this line via an interface.
    Petty much all the above ideas are stolen from gurus, who gave them willingly... but the above is my take on what I've read and practiced over the past few years... it's most probably flawed, possibly seriously... but it seems to work OK for me thus far, but bewarned that I have not yet even attempted to apply these ideas on "full scale industrial size application".
    Cheers. Keith.

  • Create MVC Framework UI to load others MVC application and those should display their view in Framework UI Layout and work independently

    Hi,
    How it is possible to develop a UI Framework/ MVC UI Framework which will loads the others MVC Application. The Framework will show the views of loaded MVC app into UI Framework view. At the same time the Framework UI will show the default view of each loaded
    MVC app(Module). If user click on any MVC Module on the UI then that MVC module should update itself by calling its own controller and others MVC app view should not disturb due to this operation. The UI Framework layout need to facilitate somehow to show
    the default view of each MVC somehow in different DIV. All MVC App will work independently and having communication with UI Framework only. HTML5, CSS3 and MVC 5 can be used
    Can anyone please suggest how to proceed on this?

    That's a strange request, but anyway, the MVC section is at the link below,
    http://forums.asp.net/1146.aspx/1?MVC

  • Where to put data validation & DB access in MVC designed app ?

    Hi,
    I write a stand alone app, because the user interface might required lots of changes in the future, I want to apply the MVC paradigm in the user interface design to improve maintainability.
    Where should I put the routine to perform data validation and read/write database ?
    Any advice would be greatly appreciated.
    Setya

    Like the tutorial says, you mustn't perform blocking or non-running operations in the GUI event thread.

Maybe you are looking for