How to delegate from controller to busines/database layer in web MVC?

Hello all,
I'm building a web application using MVC , DAO patterns by following the FrontController and DAO J2EE patterns listed here: http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
I have two FrontControllers (http://java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html),
1) Displays item details
2) Edit item details
The FrontController is currently making calls to the DAO layer to get the item details. This code is duplicated in both FrontControllers.
I want to extract this duplicated code and put it in a class, so that both of the FrontControllers will get the data from this class.
In both DisplayItemController and EditItemController (FrontControllers) I have
    private void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //Code to validate item id
        if(itemId> 0){
            DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
            ItemDAO itemDAO = daoFactory.getItemDAO();
            ItemTO item = itemDAO.getItemById(ItemId);
            request.setAttribute("item",item);
        String requestForwardPage = ApplicationResource.ITEM_DISPLAY_PAGE; //ITEM_EDIT_PAGE
        dispatch(request,response, requestForwardPage);
    }Is there a design pattern that allows moving the above common logic to a different class?
I appreciate any help.

yawmark wrote:
appy77 wrote:
Thanks for your reply, I know that there should be a model layer in MVC , but what type of classes are in the Model layer?
[http://java.sun.com/developer/technicalArticles/javase/mvc/]
[http://static.springframework.org/docs/Spring-MVC-step-by-step/]
~Ok thanks, those examples are better.

Similar Messages

  • Pls tell me how to upload from excel file to database.

    hello,experts,
    I want to upload data from excel local file to database table created by myself.when I use function
    CALL FUNCTION 'GUI_DOWNLOAD'
    the data in the internal table just become error code data that can not understand.
    who can help me out?
    thanks.

    Hi,
    1st copy the values in XLS into internal table by using function Module:-
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    exporting
    filename = file_name<it is file path of u r XLS>
    i_begin_col = 1
    i_begin_row = 1
    i_end_col = 250
    i_end_row = 1
    tables
    intern = itab<this structure is same like u r database table>
    exceptions
    inconsistent_parameters = 1
    upload_ole = 2
    others = 3.
    if sy-subrc 0.
    then modify or insert these values to database from internal table:-
    modify <DB table> from itab accepting duplicate keys.
    for file popup use :
    at selection-scree on <screen field>.
    call function 'F4_FILENAME'
    exporting
       program = sy-cprog
       dynnr     = sy-dynnr
    importing
       filename = zfilename.
    here zfilename of type rlgrap-filename.
    and pass this as path in ASLA_EXCEL_TO_INTERNAL_TABLE
    Edited by: vijay Mekala on Dec 29, 2007 12:45 PM

  • How does "concurrent request schedule" work in database layer?

    for the EBS concurrent request schedule, what triggers the schedule work? I find no related jobs in database,
    I don't know what others can realize the schedule of concurrrent requests without database job?
    thanks!
    Edited by: easonmy on 24-Apr-2012 20:02

    easonmy wrote:
    for the EBS concurrent request schedule, what triggers the schedule work? I find no related jobs in database,
    I don't know what others can realize the schedule of concurrrent requests without database job?The status of the concurrent requests in FND_CONCURRENT_REQUESTS table -- Concurrent Processing - How to Determine Scheduled Concurrent Requests [ID 170107.1]
    Concurrent Processing - What are the Meaning of the Codes in the STATUS_CODE and PHASE_CODE Columns of FND_CONCURRENT_REQUESTS Table? [ID 152209.1]
    TABLE: APPLSYS.FND_CONCURRENT_REQUESTS
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE
    Thanks,
    Hussein

  • How to select from multiple addresses of account in IC Web Client

    Hi all,
    We are implementing a B2C scenario for IC Web Client. We have customers with multiple addresses. However, when we search the acount, only standard address comes to screen.  We want to be able select the related address, and then confirm the acount with that address.
    Is there any way to customize the Web Client in order to be able to select from multiple addresses of the acount?
    Thanks in advance.
    Edited by: Danisman Danisman on Aug 31, 2010 2:52 PM

    Thanks for the answer. Yes, we are using 7.0 but in the account identification screen, there is no personalize button ( I assume you are suggesting adding an addres block by using that button, right?).
    We checked the necessary customizing : there is an entry for fucntional profile PERSONALIZATION : ALL_ENABLED.
    Should we do something else to show the button?
    Thanks again.

  • Call EJB3 from Controller

    Hi everybody,
    my post here is intended to clarify couple of things i might have misunderstood specially with my lack of experience in UI5 technology
    Is it possible to call an EJB session bean from Controller without exposing it as a web service, or it must be exposed as Restful service since the SAP UI5 is running on browser and not on server. if it's possible is there example somewhere?
    as far as I understood from SAPUI5 framework, the code will run on the browser and not on the application server. is this right?
    Thanks for your relpies
    Sam

    Hi,
    I do not have much information on calling EJB from sapui5 but found out this blog Todos application with SAPUI5, Jersey, and JPA
    Please go through it...may be useful for your requirement.
    Regards,
    Chandra

  • How can I get a list of database names from environment

    Hi,
    How can I get a list of database names from environment.
    I had found a method in JE API Docs named Environment.getDatabaseNames(), and i couldn't found the same method in Berkeley DB.
    I use java interface, is it supported?
    Thanks.

    Hello,
    I don't know if it would work for you, but have you checked the db_archive utility at:
    http://download.oracle.com/docs/cd/E17076_01/html/api_reference/C/db_archive.html
    Check the -s option.
    Thanks,
    Sandra

  • How to go from a View Controller to a View Controller

    Hey everyone, I have asked this question over on Stack Overflow, and really had no luck with it.
         I am wondering how to go from one (1) View Controller that has buttons and another View Controller that has a UIWebViewer in? I know how to do the simple part to get the two to link up. But, the buttons are going to have different URL's hooked up to them, and I want to be able to reuse the Web Viewer. I am using the Swift Programming language to be able to do this.
    below is my current code that is has my buttons sitting on top of my web viewer,
    import UIKit
    import WebKit
    class ViewController: UIViewController {   
        @IBOutlet var wbView: UIWebView!
        var strUrl = ""
            @IBAction func buttonAction(sender: UIButton) {
                switch (sender.tag){
                case 1:
                    strUrl = "https://www.google.co.in/"
                case 2:
                    strUrl = "https://in.yahoo.com/"
                case 3:
                    strUrl = "https://www.facebook.com/"
                case 4:
                    strUrl = "https://bing.com/"
                default:
                    break;
                reloadWebViewWithUrl(strUrl);
            func reloadWebViewWithUrl(strUrl: NSString){
                var url = NSURL(string: strUrl);
                var request = NSURLRequest(URL: url!);
                wbView.loadRequest(request);
            override func viewDidLoad() {
                super.viewDidLoad()
                // Do any additional setup after loading the view, typically from a nib.
            override func didReceiveMemoryWarning() {
                super.didReceiveMemoryWarning()
                // Dispose of any resources that can be recreated.
    How should I go about changing this two allow my buttons to be in their own ViewController and still be able to to the secondary View Controller with the WebViewer?
    Thank You all in advanced with the help on this!

    This is the FirstViewController Code
    import UIKit
    class FirstViewController: UIViewController {
        @IBAction func webAction(sender: UIButton) {
            let index = sender.tag
            chosenURLString = addresses[index]
            performSegueWithIdentifier("WebViewSegue", sender: self)
        override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
            if let controller = segue.destinationViewController as?
                SecondViewController {
                controller.urlString = chosenURLString
                chosenURLString = nil
        private let addresses = ["", "https://www.google.com", "https://www.facebook.com", "https://spca.org", "https://www.facebook.com/wagzpack?fref=photo"]
        private var chosenURLString: String?
    This is the SecondViewController Code
    import UIKit
    class SecondViewController: UIViewController {
        @IBOutlet var webSite: UIWebView!
        var urlString: String?
        override func viewDidLoad() {
            super.viewDidLoad()
            if let urlString = urlString {
                if let url = NSURL(string: urlString) {
                    let request = NSURLRequest(URL: url)
                    webSite.loadRequest(request)
                    println("loading \(urlString)")
                else {
                    println("badly formed URL string.")
            else {
                println("missing URL string.")

  • How to set the password encrytacion a database. Accdb from Visual Basic 2010 for a report. Rpl

    I want to know how to set the password encrytacion a database. Accdb from Visual Basic 2010 for a report. Rpl

    You have to connect via ODBC, then use code along the lines of what is described here:
    http://scn.sap.com/thread/3526924
    by me on March 28 and Jan on March 29.
    Also see KBA: 1686419 - SAP Crystal Reports designer does not recognize Access *.accdb file
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • How to read files from MIT-BIH arrhythmia database using labview

    hello friends,
    How can i read the files from MIT-BIH arrhythmia database using labview 8.6. These file extensions are in different format ie is .atr, .dat and .hea
     The link for the following database is below, any example vi for reading this data in labview would be very useful.
    http://www.physionet.org/physiobank/database/mitdb​/
    Message Edited by infra444 on 01-27-2009 07:01 AM

    You will find some help here.
    http://www.physionet.org/physiotools/matlab/#wfdb
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • How to import a *.dmp file (exported from 10g) to 8i database?

    Hi everybody!
    Could anybody tell me how to import a *.dmp file (exported from 10g) to 8i database?
    I have tried but it seemed to be error "wrong version".
    Thanks a lot!

    From 10.1.0 to 8.1.7 => Use the EXPORT 8.1.7 to export the data from the 10.1.0 database and IMPORT 8.1.7 to
    import the data into the 8.1.7 database.
    Metalink note 132904.1 Subject: Compatibility Matrix for Export & Import Between Different Oracle
    Nicolas.

  • How to pass external regions programaticaly from controller ?

    Hi Team,
    I have a new page. in that page there are 2 stack layout regions.
    How can we Dynamically open an external region from Controller in OAF page instead hardcording in the property inspector.
    For example : my DB table datas are like this
    SEQUENCE     WEB_HTML_CALL
    1               /oracle/apps/wer/felta/external/webui/suplierExtPGRN
    2               /oracle/apps/wer/felta/external/webui/requestorExtPGRN
    If you required any details,please let me know.
    thanks in advance.

    Hi,
    You can add that region to your page by hard coding but make that rendered false.
    Then in your controller, depending on the requirement you can set that region visible by rendering it to true.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can i convert data from DBF to oracle database 10g?

    Sir,
    How can i convert data from DBF to oracle database 10g?

    I assume you at least know how to dump the contents of foxpro dbf file into CSV format.
    Regarding SQL*Loader, hope this demo makes it a bit clear to you...
    http://www.princeton.edu/~storacle/sqlloader_demo.shtml
    I agree that it is an old web page (references Oracle 8.0.5) but basics remain the same.
    If it is still unclear to you after referring above link, then get an Oracle consultant.

  • How to call jpf controller method from javascript

    Can any one help me how to call pageflow controller method from JavaScript.\
    Thanks.

    Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
    1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
    document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
    document.getElementById("batchForm").submit;
    2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
    document.getElementById("ACTION_NAME").value = "UPDATE";
    document.getElementById("batchForm").submit.
    Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
    3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
    This entire lines of code should do what we want.
    <netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>                    
    <netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
    <c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
    <%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
    <netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
    </c:forEach>               
    </netui:select>
    See if you can build along those above lines of code. Any other simpler approches are highly welcome.
    Thanks
    Ravi Jegga

  • Hello, for a multilingual catalog project I would have to know how and with what tool I can place text from Excel or a database in text frames / tables. The basic idea is to provide the text box with an ID (eg text_eng_art_nr_987654 ) and above to ma

    Hello, for a multilingual catalog project I would have to know how and with what tool I can place text from Excel or a database in text frames / tables. The basic idea is to provide the text box with an ID (eg << text_eng_art_nr_987654>>) and above to make the connection. Does anyone have a tip. Thanks in advance !!!
    Bernd

    Data merge is really useful in many circumstances, but my first question would be about the size of the project. A really large catalog might be better handled by processing an IDML in some kind of translation memory tool.
    If all of your multilingual content is already in Excel, then it's probably best handled with a Data Merge. Note that you can't save Unicode CSV out of Excel for the merge, so for many languages you'll need to save "Unicode Text" out of Excel and tweak your import settings when you select a Data Source for encoding (Unicode) and delimiter (tab instead of comma).

  • How to save image catch from USB camera to database ?

    Hi guys.
    I needed help on IMAQdx tools. But i dont know how to save image that catch from USB camera to database.

    So you can acquire the image OK?
    And you want to save it to a SQL database?
    See here:
    http://zone.ni.com/devzone/cda/epd/p/id/5210

Maybe you are looking for

  • How do I install adobe as a printer?

    I need to print a .pdf from word. I bought the Adobe pack, why is it not showing as a printer choice?

  • Restoring doesn't work correctly.

    I have formatted it and I've changed the path. When I restore it, it still asks me to restore it. I have a black fifth Gen black 30 gig iPod video. Any help would be awesome! I'm getting crazy music withdraws. >_<

  • Backing up a +ASM instance

    I have started using asm and another DBA asked me if we should be backing up the +ASM instance.  Right now we are not.  Should we and how if we should?                                                                                                   

  • Is it possible to create an interactive graph/chart using Report Builder 3.0?

    Hi All, I am using Report Builder for the first time. Here is what I am trying to accomplish. The data I plan to use in Report Builder is coming from SQL Server and in the Report Builder I want to create an interactive graph(chart). For example, The

  • Problem in generating the Primary Key

    Hi All , I am trying to persist an object and also generating the primary key using a default sequence . But the problem is that the Primary key is getting incremented by 2 instead of 1 . My code looks like this : import java.util.HashMap; import jav