MVC Problem

Hi to all
This is Praveen Reddy. I am trying to develop one small MVC model application. In this, from the controller class i am caling model class, and this class displaying 25 records from the database. now i want to display these 25 records in to View component (jsp ). i dont know how to do this. if any one knows please help me. i am very thankful to you. Thanks in advance.
Edited by: praveen_nlg on Aug 21, 2009 4:17 AM

Have a read of the 'Web Tier' section. It contains some example code and an excellent explanation of how JSP's work!
[http://java.sun.com/javaee/5/docs/tutorial/doc/bnadp.html|http://java.sun.com/javaee/5/docs/tutorial/doc/bnadp.html]
m

Similar Messages

  • MVC problem - infinite loop?

    I'm going to use a horribly oversimplified example to make my point here, because if I were to describe the actual code I'm looking at, it would take the better part of the afternoon and I'd probably bore you all to tears in the process. So, for the sake of argument, let's assume the following model object:
    public class MyModelObject
      private int a;
      private int b;
      private int c;
      public void setA(int newA)
        a = newA;
        b = newA + SOME_CONSTANT;
        c = newA + SOME_OTHER_CONSTANT;
      public void setB(int newB)
        this.setA(SOME_CONSTANT-newB);
      public void setC(int newC)
        this.setA(SOME_OTHER_CONSTANT-newC);
      public int getA()
        return a;
      public int getB()
        return b;
      public int getC()
        return c;
    }So what we see from this is that the setter for one class property actually changes the value of all three class properties (whether this is good design or not is questionable, but keep in mind this is a horribly simplified example for discussion purposes). The point is that the rules regarding the internal state of MyModelObject are governed entirely within that class - the controller and view don't know about these rules (again, questionable design, but bear with me here).
    Now let's imagine we have a view class that displays a MyModelObject instance and allows the user to change the value of a, b, or c. We also have a controller class that observes the view and responds to changes. When the user modifies the value of, let's say b, the controller will respond to that change by calling the setB() method in MyModelObject. Problem is, now the model and the view are out of synch... someone has to tell the view that the other two class properties have also been modified as a result of calling setB() - whose responsibility is this? Should the model inform the view that something has changed so that the view can redisplay it, or should the view observe the model and automatically redisplay whenever the model is modified?
    More importantly - let's say the controller is observing the view for changes, and the view is observing the model for changes... how do you avoid an infinite loop? For example, the user changes the value of b in the view, which causes the internal state of MyModelObject to be modified, which causes a change in the view, which causes a change in the model, and so on and so forth.
    A twist on the above problem is that it is illegal in some Swing components (JTextPane, for instance) to modify the view while a change notification is in progress... so something like this would throw an IllegalStateException:
    //somewhere in the controller
    public void insertUpdate(DocumentEvent docEvent)
      //update the model
      myModelObject.handleChange(docEvent);
      //now redisplay since the model has changed:
      myTextPane.display(myModelObject);
      // IllegalStateException is raised - Attempt to mutate in notification
    }This fails because you can't change the state of the view component in the event handler for a view change event. How do you get around this using proper MVC architecture? Or am I completely out to lunch here?

    The view shouldn't send events to the controller unless they make sense... For example, it shouldn't fire a change event when the user types in a new value. But only if the user presses enter, or the view loses focus (if this gesture is taken as equivalent).
    So when the change of the view comes from the side-effects of a setter of some property, it should fire no event (so that it will not loop). So it sounds no big problem (if such a distinction of events is easy - it should).

  • Can anyone solve this simple MVC problem with ArrayCollection

    I have very simple application trying to understand how to apply MVC without any framework. There are quite a few exemples on the net but most do not deal with complex data.
    here is my application with 4 files: MVCtest.mxml, MyController.as, MyModel.as and MyComponent.as
    first the Model MyModel.as
    package model
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import mx.collections.ArrayCollection;
    [Event(name="ArrayColChanged", type="flash.events.Event")]
    [Bindable]
    public class MyModel extends EventDispatcher
      private static var instance:MyModel;
      public static const ARRAYCOL_CHANGED:String = "ArrayColChanged";
      private var _myArrayCol:ArrayCollection;
      public function MyModel(target:IEventDispatcher=null)
       super(target);
       instance = this;
      public static function getInstance():MyModel
       if(instance == null)
        instance = new MyModel();
       return instance;
      public function get myArrayCol():ArrayCollection
       return _myArrayCol;
      public function set myArrayCol(value:ArrayCollection):void
       _myArrayCol = new ArrayCollection(value.source);
       dispatchEvent(new Event(ARRAYCOL_CHANGED));
    then the controller: MyController.as
    package controller
    import components.MyComponent;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import model.MyModel;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;
    public class MyController extends EventDispatcher
      [Bindable]
      public var view:MVCtest;
      [Bindable]
      public var componentView:MyComponent;
      private var _model:MyModel = MyModel.getInstance();
      public function MyController(target:IEventDispatcher=null)
       super(target);
       _model.addEventListener("ArrayColChanged", onArrayColChange);
      public function initialise(event:Event):void
       getData();
      public function getData():void
       var dataRO:RemoteObject = new RemoteObject;
       dataRO.endpoint = "gateway.php";
       dataRO.source = "MytestdbService";
       dataRO.destination = "MytestdbService";
       dataRO.addEventListener(ResultEvent.RESULT, dataROResultHandler);
       dataRO.addEventListener(FaultEvent.FAULT, dataROFaultHandler);
       dataRO.getAllMytestdb();   
      public function dataROResultHandler(event:ResultEvent):void
       _model.myArrayCol = new ArrayCollection((event.result).source);
      public function dataROFaultHandler(event:FaultEvent):void
       Alert.show(event.fault.toString());
      public function onArrayColChange(event:Event):void
       componentView.myDataGrid.dataProvider = _model.myArrayCol;
    This is the main application: MVCtest.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:controller="controller.*"
          xmlns:components="components.*"
          width="600" height="600"
          creationComplete="control.initialise(event)">
    <fx:Declarations>
      <controller:MyController id="control" view = "{this}"/>
    </fx:Declarations>
    <fx:Script>
      <![CDATA[
       import model.MyModel;
       import valueObjects.MyVOorDTO;
       [Bindable]
       private var _model:MyModel = MyModel.getInstance();
      ]]>
    </fx:Script>
    <s:VGroup paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
      <s:Label fontSize="20" fontWeight="bold" text="MVC Test with components"
         verticalAlign="middle"/>
      <components:MyComponent/>
    </s:VGroup>
    </s:Application>
    And this is the component: MyComponent.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <s:layout>
      <s:VerticalLayout paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"/>
    </s:layout>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label fontSize="16" fontWeight="bold" text="My Component " verticalAlign="bottom"/>
    <s:DataGrid id="myDataGrid" width="100%" height="100%" requestedRowCount="4">
      <s:columns>
       <s:ArrayList>
        <s:GridColumn dataField="mystring" headerText="String"></s:GridColumn>
        <s:GridColumn dataField="myinteger" headerText="Integer"></s:GridColumn>
        <s:GridColumn dataField="myreal" headerText="Real"></s:GridColumn>
        <s:GridColumn dataField="mydate" headerText="Date"></s:GridColumn>
       </s:ArrayList>
      </s:columns>
    </s:DataGrid>
    </s:Group>
    Here is the code to generate the database:
    CREATE DATABASE mytest;
    CREATE TABLE myTestDB
          myid INT UNSIGNED NOT NULL AUTO_INCREMENT,
          mystring CHAR(15) NOT NULL,
          myinteger INT NOT NULL,
          myreal DECIMAL(6,2) NOT NULL,
          mydate DATE NOT NULL,
          PRIMARY KEY(myid)
    ) ENGINE = InnoDB;
    INSERT INTO myTestDB (mystring, myinteger, myreal, mydate) VALUES ('Test', 123, 45.67, '2012-01-01'), ('Practice', 890, 12.34, '2012-02-01'), ('Assay', 567, 78.90, '2011-10-01'), ('Trial', 111, 22.22, '2009-09-09'), ('Experiment', 333, 44.44, '1999-04-15'), ('Challenge', 555, 66.66, '2012-12-21');
    And finally here is the PHP script.
    <?php
    class myVOorDTO
      var $_explicitType = "valueObjects.myVOorDTO";
      public $myid;
      public $mystring;
      public $myinteger;
      public $myreal;
      public $mydate;
      public function __construct()
        $this->myid = 0;
        $this->mystring = "";
        $this->myinteger = 0;
        $this->myreal = 0.0;
        $this->mydate = date("c");
    class MytestdbService
      var $username = "yourusername";
      var $password = "yourpassword";
      var $server = "yourserver";
      var $port = "yourport";
      var $databasename = "mytest";
      var $tablename = "mytestdb";
      var $connection;
      public function __construct()
        $this->connection = mysqli_connect(
        $this->server, $this->username, $this->password, $this->databasename, $this->port);
    * Returns all the rows from the table.
    * @return myVOorDTO
      public function getAllMytestdb()
        $query = "SELECT * from $this->tablename";
        $result = mysqli_query($this->connection, $query);
        $results = array();
        while ($obj = mysqli_fetch_assoc($result))
          $row = new myVOorDTO();
          $row->myid = $obj['myid'] + 0;
          $row->mystring = $obj['mystring'];
          $row->myinteger = $obj['myinteger'] + 0;
          $row->myreal = $obj['myreal'] + 0.0;
          $row->mydate = new Datetime($obj['mydate']);
          array_push($results, $row);
        return $results;
    ?>
    My understanding as to what is going on is: (1) on creation complete the application launch the initialise() function of the controller (2) this function starts the remoteObject which get the data (3) once the results arrive the resultHandler store the data into the ArrayCollection of the model ***this does not work*** (4) even if part 3 did not work, the setter of the ArrayCollection in the model send an event that it has been changed (5) the controller receive this event and assigns the ArrayCollection of the model as the dataprovider for the datagrid in the compoent.
    Of course, since the ArrayCollection is null, the application gives an error as the dataProvider for the datagrid is null.
    What is missing in this application to make it work properly? I believe this is an example that could help a lot of people.
    Even if I change the setter in the model to _myArrayCol = ObjectUtil.copy(value) as ArrayCollection; it still does not work.
    Also, it seems that the remoteObject does not return a typed object (i.e. myVOorDTO) but rather generic objects. I am usually able to make this works but in this particular application I have not managed to do it. Again what's missing?
    Thanks for any help with this!

    Calendar c = GregorianCalendar.getInstance();
    c.set(Calendar.YEAR,2000);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));
    c.set(Calendar.YEAR,2001);
    System.out.println(c.getActualMaximum(Calendar.WEEK_OF_YEAR));But it says that 2000 has 53 weeks and 2001 has 52.

  • MVC Problem with getter method of table attribute in model class

    Hi,
    I am on 620 SP34. I am writing a bsp application with mvc. One of the model classes has an attribute of type table. I use this attribute in a htmlb-tableview and '//MODEL/ZMY_TAB' for data binding. If I try to activate a getter method for this attribute, the application dumps with exception <i>BSP exception: Structure component with name "ZMY_TAB" does not exist</i>. I find the SAP source, that raising this exception (see below). The source code looks like: <i>"I don't support getter methods for tables in attribute path"</i>! The setter method works fine, so I am at a loss. Has anyone of you wrote a getter method for an table attribute in bsp-mvc? Have I to consider anything special?
    Thanks,
    Carsten
    Main Program CL_BSP_MODEL==================CP
    Source code of CL_BSP_MODEL==================CM00Z
    METHOD IF_BSP_MODEL_BINDING~GET_ATTRIBUTE_DATA_REF
           * check if attribute exists for binding!                                   
             if exists_attribute( l_name ) is initial.                                
               return.                                                                
             endif.                                                                               
    * setter or getter defined? Not supported for DATA REF requests            
             if get_getter( attribute_name = l_name ) is not initial.                 
               raise exception type cx_bsp_inv_component                              
                 exporting name = l_name.                                             
             endif.                                                   

    You have two options:
    1. Make your attributes public. It should work fine.
    2. If you need to process the attribute values before it is used, you can make the attribute private but will need three methods
    GET_T_ZMY_TAB that returns the table
    SET_T_ZMY_TAB that sets the values
    GET_M_T_ZMY_TAB that returns DDIC information about the attribute. The same holds good for structures(Change to GET_S_ and GET_M_S_ ) and simple attributes(Change to GET_ and GET_M_).
    The set and get methods are kind of documented at http://help.sap.com/saphelp_nw04/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/content.htm but there is no mention of the GET_M_ methods. I could not find one single document on the Model part MVC.
    Once I added the GET_M_XYZ methods to my attributes, my BSPs started to work fine.
    Cheers
    Sreekanth

  • JInternalFrame problem

    Hello,
    I've got a JFrame class like this :
    public class FrameTest extends JFrame
    public JFrameTest()
    JDesktopPane desktop = new JDesktopPane();
    this.setContentPane(desktop);
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    Test panelTest = new Test();
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    contentPane.add(panelTest , panelTest .gridBagConstraints);
    At this point, I've got no problem. My frame is visible and my panel is inside.
    On the listener of a button of my panel, I want to open an JInternalFrame.
    My JInternal class is like this :
    public class JInternalFrameTest extends JInternalFrame
    public JInternalFrameTest(String title)
    super(title, true, true, true);
    this.pack();
    this.setVisible(true);
    The code of the listener is like this :
    JInternalFrameTest internalFrameTest = new JInternalFrameTest("TITLE");
    frameTest.getContentPane().add(internalFrameTest ); //frameTest is a reference on the main frame (instance of JFrameTest)
    At the execution of my application, when the listener starts, the JInternalFrameTest is created but near the panel not on the top. Moreover, I can't specify the position and the size of my JInternalFrameTest object because when I specify them in the JInternalFrameTest class, nothing happen.
    If you have a solution for me because I don't understand what I have forgotten.
    Thanks.

    michal1101 wrote:
    As I understand, in mvc - if the view is not updated , so it's a bug.What are you trying to say here? There are two options: there is a bug in Java that millions of people have missed, and you've somehow found OR you're misunderstanding something. Which do you think is more likely?
    Does anyone had that kind of mvc problem?No. Either something in your code is wrong, or you're misunderstanding something pretty basic.
    Ps. It's difficult to send an example, since i can't send the code from work.Then you understand that it's difficult to help you, right? Without seeing code, we can't tell you what's wrong with your code. You were asked for an SSCCE, which shouldn't contain any extra "company-sensitive" code. It's your call, but claiming that your problems must be a "bug" and refusing to post any code won't get you very far.

  • Problem with BSP MVC

    Hi all,
    I had a bsp application which is now running live in the organization. Recently, I got a problem report back from user, which is causing data loss.
    After the support team check the problem and found out the source of the problem. Let me briefly state the problem here. The application is using bsp mvc and it is stateful.
    First, when a user open the application in IE, it is a timesheet entry application, first page will display the time entry of that user for current month. let say the default selected month is September. then if the user wan to compare the entry with previous month, then he will open a new window (ctrl + N) or new tab (ctrl + T), then open the application again. Because of using SSO, the application will not prompt user to login again and will directly lead user to the time entry page. then the user change the month to August for the second new page.
    after the user change the month to august, it will refresh the model that hold the data of the month. means the model now carry August calendar. then the user go back to the first window or the first tab with september time entry, he try to add in new data into that time entry, and save. when it is saved, the september data will go into the August data not go into the September data. this causing data loss in September.
    If I tried this again with not using (ctrl + N) or (ctrl + T) but is open another new IE broswer instance, then it wont give this problem at all. because it create another new model to hold the calendar data. It work fine as long as the user not open two or more windows or tab in a same IE instances.
    Does anyone here meet this problem before or could provide any suggestion to solve this kind of problem? I cant simply changed the application to stateless because it already using worldwide and it will cause a lot of problem. Sorry if my question here was not clear enough.
    Thanks you. (reward point will be given for helpful answer.)

    Is there anyone can understand my problem?
    Thanks you.

  • Problem in Creating Check boxes as a column in a table using MVC

    I am trying to display a table format using the Model view controlers, with 1st column as a checkbox. if the user chooses some check boxes and submit the screen then i need to update the information in a custome table.
    I am having a problem in creating the check boxes, also pls tell me how to catch the line items checked by the user in the table...
    Sri

    HI Srinivas
       I am not getting what the exact problem is.....
    I am giving you a work around.....to me it does not seems to be an Ideal Solution..But Probably it will solve your problem....
    Changes To be Made in Page Layout...
    In Pagelayout     
    <htmlb:tableView id   = "tvX"                           width                 = "100%"                           visibleRowCount       = "8"                           fillUpEmptyRows       = "X"                         selectedRowIndexTable = "<%= selectedRowIndexTable %>"
    <b>selectedrowindex      = "<%= selectedrowindex %>"
    onrowselection        = "select"</b>
    selectionMode   = "MULTISELECT"                           table                 = "<%= sflight %>" />
    <b>selectedindexrow is an attribute of type INT4</b>
    In Do handle event.....instead of using the previous code use this one...
    if event->id = 'SUBMIT'.  
    DATA:      WA  TYPE  INT4.     
    LOOP AT SELECTEDROWINDEXTABLE INTO WA.
    *Here you can read your table of TABLEVIEW with index *equal to WA into a workarea and then use that workarea *to update the customer table      ENDLOOP.   
    elseif event->id = 'tvX'.
    tv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request                                      name    = 'tableView'                                      id      = 'tvX' ).  
    IF tv IS NOT INITIAL.    
    table_event = tv->data.   
    selectedRowIndex = table_event->SELECTEDROWINDEX.
    append selectedrowindex into SELECTEDROWINDEXTABLE.
    endif.
    ENDIF.
    Meanwhile..Let me check why that code does not work.....
    Hope it solve your problem....
    Cheers:)
    Mithlesh

  • A problem to display a jsp Using MVC approach

    Hello everybody
    I have got a problem with RequestDispatcher and I would like to get your help.
    I excpect the servlet to display the index.jsp page but the server displays a blank page. web.xml's <servlet> and <servlet-mapping> are set correctly at this TestServlet servlet. what could be the problem?
    my code looks like this:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class TestServlet extends HttpServlet{
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {     
         String url = "/index.jsp";     
         ServletContext context = getServletContext();
         RequestDispatcher dispatcher = context.getRequestDispatcher(url);
                   dispatcher.forward(request, response);     }
    public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
              //doGet(request,response);
    PS: please help me, this step blocks me for several weeks.
    thank you.

    Hello Thomas, thanks for your answer.
    >
    Thomas Jung wrote:
    > Does this problem happen in IE for all different MIME Types?  I can't recreate your problem as the same functionality works perfectly fine in my installation of IE.
    It does happen for Gif-, Jpeg- and Pdf-binaries (other Mime-types I haven't tested yet) and it is IE 7 I am using.
    > Do you have any browser plug-ins - like Anti-Virus scanners that might be interupting? 
    There are no relevant (as far as I can tell) plug-ins especially no anti-virus scanners loaded.
    > >however an export of the binary stream shows the binary is incomplete.
    > This could be indicative of the problem or it might be perfectly normal.  What trace tool are you using? 
    > It might just be the cause of a multi-part MIME.
    The trace-tool is HttpWatch.
    I think this correlates with the fact that the tab closes right away (i.e. before the stream has been downloaded completly).
    > Can you download attachments in IE from other websites?  There really isn't anything special that SAP is doing in Web Dynpro from a browser side.
    I can download/open Pdfs from SDN for example
    Unfortunately I still haven't got a clue what happens. The code-snipplet producing the response looks like this
    METHOD onactionopen_document .
      DATA: file TYPE zrms_st_file.
      file = wd_this->get_file( ).
      cl_wd_runtime_services=>attach_file_to_response(
          i_filename      = file-filename
          i_content       = file-binary
          i_mime_type     = file-mimetype
          i_in_new_window = abap_true ).
    ENDMETHOD.
    where the type zrms_st_file has three components: binary (type tr_xstring), filename and mimetype (both dstring). Debugging (breakpoint right before method is called) shows that the mimetype is correct.
    Regards,
    Sebastian

  • Developing MVC, with ADF, problem saving to oracle database

    Following this tutorial
    http://www.oracle.com/technology/obe/obe_as_1012/j2ee/develop/endtoend/newADFto
    J
    SP/defaultendtoend.htm, I'm developing an application MVC, I create a jsp, for
    show my datas, in this jsp I have a Button in order to creta a new record and
    alaso have a button to make commit. When click create button, it take me to a
    new jsp where you can put the data for new record. When click submit my record
    has been created but when I tried to create a new record, the application just
    update the record that I Created, and the rest of button like next, previous,
    commit, just stop working. Also when I tried to make a commit, it take me to
    the jsp of create a new record.

    LD,
    You don't need to set the CLASSPATH environment variable.
    Personally, I prefer not setting CLASSPATH at all and using the "-classpath" option to the "java" command.
    You only need to include the JDBC driver.
    Your command should be:
    java -classpath C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar test
    Your error message states that class "java.sql.Savepoint" is not found.
    I see the following in your CLASSPATH:
    C:\Program Files\Oracle\jre\1.1.8\bin
    I'm guessing you're probably running java version 1.1
    Class "Savepoint" was introduced in java 1.4
    Try the following command:
    (Again, I recommend unsetting CLASSPATH first.)
    java -version
    If it doesn't say you're running java 1.4 then that explains the cause of your error message.
    Also, I suggest visiting this Web page:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    One of the links on that page is to the OTN forum on JDBC.
    That forum contains an announcement that class "oracle.jdbc.driver.OracleDriver" is deprecated.
    Here is the link:
    http://forums.oracle.com/forums/ann.jspa?annID=201
    The first URL I posted above has links to sample code as well.
    It's not a good idea to do connect to the database as the SYSTEM user if you aren't intending to do administration work.
    That's why Oracle supplies the sample SCOTT schema.
    The login and password is usually "scott/tiger".
    Story goes that the guy who developed the SCOTT schema is indeed called Scott and Tiger is the name of his cat. (Whatever ;-)
    Good Luck,
    Avi.

  • JButton problem in MVC Using DefaultTableModel

    View:
    I have a JDialog that contains a JTable.
    Model:
    I extend DefaultTableModel
    Problem:
    I want a button at the bottom of the JDialog, that is not in the JTable.
    The button is supposed to change a value in the model, when clicked
    I want the button's text to change when the value in the model changes, so it displays the new value.
    But it seems to me the real view is the JTable, not the enclosing JDialog, so if I try to create the JButton in the Model, I can not access it outside the JTable So how do work around this?
    Any advice??

    Create a panel containing the JTable, say BorderLayout.Center and JButton at say, BorderLayout.south. Add the panel to the JDialog. The button can have actionListener with actionPeformed method to change the value in the table. You should be able to access the button outside of the Table that way.

  • Grid problem in MVC Kendo Grid view

    Hi,
    I have a Problem on Update In Kendo Grid.I have a grid that has "popup" editing.  The problem is that if I click Cancel in the popup dialog,
    the record being edited is deleted..
    And another problem, When i click Delete button but the function will go on Create in server side why this problem.my coding is
       @(Html.Kendo().Grid<Explorer.Models.TdsModel>()
              .Name("termGrid")
              .HtmlAttributes(new { style = "width: 100%; height:550px" })
              .Columns(columns =>
                  columns.Bound(c => c.TDSName).Title("Training Data Set").Width("15%");
                  columns.Bound(c => c.TDSShortName).Title("Short Name").Width("15%");
                  columns.Bound(c => c.CreatorName).Title("Owner").Width("15%");
                  columns.Command(command => { command.Edit(); command.Custom("Delete").Text("<span class='k-icon k-delete'></span>Delete").Click("openWindow"); }).Width(160);
              .ToolBar(toolbar =>
                  toolbar.Create();
              .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ManageTdsPopup").DisplayDeleteConfirmation(false))
              .Resizable(resize => resize.Columns(true))
              .Sortable()
              .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
              .Scrollable(scrollable => scrollable.Virtual(true))
              .DataSource(dataSource => dataSource
                  .Ajax()         
                  .Batch(true)
                  .ServerOperation(false)
                      .PageSize(20)
                  .Model(model => model.Id(p => p.Id))
                  .Create("Tds_Create", "Admin")
                  .Update("Tds_Update", "Admin")
                  .Destroy("Tds_Destroy", "Admin")
                  .Read(read => read.Action("GetTds", "Admin")))
              .ColumnResizeHandleWidth(6)
    Karthikn.s

    Hi Karthikeyan,
    In my opinion, this thread is related to ASP.NET forum. So please post thread on that forum for more effective response. Thank you for understanding. Please refer to the following link.
    http://forums.asp.net/.
    Regards,
    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.

  • Problem in Installation of MVC 4

    When I am installing MVC 4 against VS 2010, it is showing an error: SETUP FAILED. ONE OR MORE ISSUES CAUSED THE SETUP FAILED. PLEASE FIX THE ISSUES AND THEN RETRY SETUP.
    0x81f40001- This product requires Visual Studio 2010 SP1.
    "PC config: win 7 HB SP1,VS 2010 Ultimate"

    Hi,
    As the error message:
    "0x81f40001- This product requires Visual Studio 2010 SP1."
    You should make sure your VS is 2010 SP1 before install MVC 4.
    And you can see the links below:http://www.asp.net/mvc/mvc4
    Best Wishes!
    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. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How can I create a new table in a MySQL database in MVC 5

    I have an MVC 5 app, which uses MySQL hosted in Azure as a data source. The point is that inside the database, I want to create a new table called "request". I have already activated migrations for my database in code. I also have the following
    code in my app.
    Request.cs: (inside Models folder)
    public class Request
    public int RequestID { get; set; }
    [Required]
    [Display(Name = "Request type")]
    public string RequestType { get; set; }
    Test.cshtml:
    @model Workfly.Models.Request
    ViewBag.Title = "Test";
    <h2>@ViewBag.Title.</h2>
    <h3>@ViewBag.Message</h3>
    @using (Html.BeginForm("SaveAndShare", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
    @Html.AntiForgeryToken()
    <h4>Create a new request.</h4>
    <hr />
    @Html.ValidationSummary("", new { @class = "text-danger" })
    <div class="form-group">
    @Html.LabelFor(m => m.RequestType, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
    @Html.TextBoxFor(m => m.RequestType, new { @class = "form-control", @id = "keywords-manual" })
    </div>
    </div>
    <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
    <input type="submit" class="btn btn-default" value="Submit!" />
    </div>
    </div>
    @section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    HomeController.cs:
    [HttpPost]
    public ActionResult SaveAndShare(Request request)
    if (ModelState.IsValid)
    var req = new Request { RequestType = request.RequestType };
    return RedirectToAction("Share");
    The point is that, I want the user to fill the form inside the Test view and click submit, and when the submit is clicked, I want a new entry in the new table to be created. But first of course I need to create the table. Should I create it using SQL query
    through MySQL workbench? If yes, then how can I connect the new table with my code? I guess I need some DB context but don't know how to do it. If someone can post some code example, I would be glad.
    UPDATE:
    I created a new class inside the Models folder and named it RequestContext.cs, and its contents can be found below:
    public class RequestContext : DbContext
    public DbSet<Request> Requests { get; set; }
    Then, I did "Add-Migration Request", and "Update-Database" commands, but still nothing. Please also note that I have a MySqlInitializer class, which looks something like this:
    public class MySqlInitializer : IDatabaseInitializer<ApplicationDbContext>
    public void InitializeDatabase(ApplicationDbContext context)
    if (!context.Database.Exists())
    // if database did not exist before - create it
    context.Database.Create();
    else
    // query to check if MigrationHistory table is present in the database
    var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery<int>(
    string.Format(
    "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
    // if MigrationHistory table is not there (which is the case first time we run) - create it
    if (migrationHistoryTableExists.FirstOrDefault() == 0)
    context.Database.Delete();
    context.Database.Create();

    Hello Toni,
    Thanks for posting here.
    Please refer the below mentioned links:
    http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
    http://social.msdn.microsoft.com/Forums/en-US/3a3584c4-f45f-4b00-b676-8d2e0f476026/tutorial-problem-deploy-a-secure-aspnet-mvc-5-app-with-membership-oauth-and-sql-database-to-a?forum=windowsazurewebsitespreview
    I hope that helps.
    Best Regards,
    Sadiqh Ahmed

  • Problem in DBCP Connection Pooling with BLOB in Tomcat

    Hi All,
    I am using the DBCP connection pooling in tomcat server version 6.0.18.
    I have session table which maintains the session details of the user in BLOB column. Recently I am facing a problem. When a user logs in, I am storing the session details in the DB. It throws an exception like this. When I restart the tomcat, it just works fine. But after some days it is again throwing the same exception.
    Code:
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.JdbcTemplate] - Executing prepared SQL statement [INSERT INTO SESSION (SESSION_CODE,LAST_ACCESS,VALID_SESSION,SESSION_DATA) VALUES(?,?,?,?)]
    2009-01-27 06:03:13,789 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 1, parameter value [c2896a488efb7fe15430fab10d502577], value class [java.lang.String], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 2, parameter value [1233064993], value class [java.lang.Long], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 3, parameter value [1], value class [java.lang.Integer], SQL type unknown
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - Setting SQL statement parameter value: column index 4, parameter value [org.springframework.jdbc.core.support.SqlLobValue@18af32e], value class [org.springframework.jdbc.core.support.SqlLobValue], SQL type 2004
    2009-01-27 06:03:13,789 DEBUG [org.springframework.jdbc.support.lob.DefaultLobHandler] - Set bytes for BLOB with length 390
    2009-01-27 06:03:13,789 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,790 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] bound to thread [http-8443-6]
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Unable to translate SQLException with Error code '17410', will now try the fallback translator
    2009-01-27 06:03:13,790 INFO [web.controller.LoginController] - Caught Exception while creating sesion in DB
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Triggering beforeCompletion synchronization
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Initiating transaction rollback
    2009-01-27 06:03:13,790 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Rolling back JDBC transaction on Connection [jdbc:oracle:thin:@stagedb1c:2115:WEB1C, UserName=WEBAPP, Oracle JDBC driver]
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Triggering afterCompletion synchronization
    2009-01-27 06:03:13,791 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Clearing transaction synchronization
    2009-01-27 06:03:13,791 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@154136a] for key [org.apache.commons.dbcp.BasicDataSource@bdec44] from thread [http-8443-6]
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceTransactionManager] - Releasing JDBC Connection [connection is closed] after transaction
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Returning JDBC Connection to DataSource
    2009-01-27 06:03:13,791 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Could not close JDBC Connection
    java.sql.SQLException: Already closed.
    at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
    at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:313)
    at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:274)
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:316)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:966)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:832)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:777)
    at web.controller.LoginController.onSubmit(LoginController.java:109)
    at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
    at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:595)
    My Session table has the following structure:
    Code:
    Name Null? Type
    SESSION_CODE NOT NULL VARCHAR2(100)
    LAST_ACCESS NOT NULL NUMBER
    VALID_SESSION NOT NULL NUMBER
    SESSION_DATA NOT NULL BLOB
    I have the following in the Spring context file :
    Code:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="initialSize" value="5"/>
    <property name="maxActive" value="5"/>
    <property name="minIdle" value="2"/>
    <property name="poolPreparedStatements" value="true"/>
    <property name="defaultAutoCommit" value="false"/>
    </bean>
    I am using the oracle.jdbc.driver.OracleDriver as jdbc driver. And also using the commons-dbcp-1.2.2.jar and ojdbc14.jar.
    Can some one help me out to solve this issue?
    Thanks in Advance.

    I am also facing the same problem, please let me know if there any suggestions,
    DEBUG|2010-05-07 16:41:25,866|main|(SQLErrorCodeSQLExceptionTranslator.java:266)|org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator|Unable to translate SQLException with Error code '17410', will now try the fallback translator
    DEBUG|2010-05-07 16:41:25,866|main|(SQLStateSQLExceptionTranslator.java:94)|org.springframework.jdbc.support.SQLStateSQLExceptionTranslator|Extracted SQL state class '08' from value '08000'
    thanks
    sundaravel n

  • MVC Design Help, Single Servlet, How do I access the Model and DB

    Hi all. New here and looking for some help.
    I am currently writing a website that allows the creation of users, that may upload articles and post comments on articles. Im trying to develop using MVC. I have a single controller servlet that processes POST actions throughout the site (eg. InsertArticle, DeleteArticle, ModifyArticle, etc..)
    Now my problem is, just how do I retrieve the articles from the database? .. for example, if I load up a page http://localhost/articles.jsp which should display all the articles currently in the site.. I would have a function say getAllArticles() which should return a collection of all the articles. I can then iterate through the articles in the jsp page.
    I am trying to use <jsp:useBean...etc.> BUT.. my articles bean constructor takes a databaseconnection object as a parameter. If I use useBean I cant pass the databaseconnection object to the bean and I get an error because it cannot create the bean.
    Any help on this would be appreciated as well as any tutorial links. I also looked at the petstore blueprint program on the sun website, but that program has me completely lost with all the xml. I would prefer not to use custom tags or struts for now. I would like to keep it simple with snippets of java code in the jsp pages for data retrieval and display while keeping all the business logic in the beans of the model. I would also like to keep this relatively secure. I am developing using Oracle Jdeveloper 10g.
    Thanks
    Jazz

    Hey steve, thanks for that.. but thats exactly what i
    dont want to do. I also realize that ive been writing
    the ejb's incorrectly to begin with and have begun to
    rewrite them. However maybe I can make it easier..
    what im trying to do is precisely what is in this
    diagram..
    http://gsraj.tripod.com/jsp/jsp.html
    the problem im having is where it passes data back to
    the jsp page.. entity beans cant (or shouldnt?) be
    accessed directly from jsp pages.. which means i
    create a session bean which interacts with the entity
    bean and can return information to the jsp page.. i
    understand what i have to do.. i just dont know how to
    do it.. been searching for google for tutorials and
    etc.. this site is the closest ive come but .. as you
    can see it says "more to come" ..
    thanks again guys really appreciate itAhhh. EJBs. Enterprise Java Beans and JavaBeans are two completely different beasts. I know nothing about EJBs, except:
    1) They are much harder to use (and serve a different purpose I assume) then JavaBeans
    2) Tomcat (the server I use) doesn't support them.
    Sorry I can't be of more help.

Maybe you are looking for

  • My flash player is not working in Youtube! Please help!

    I have the version 10,2,152,32 installed. it works in facebook and i can play games like Farmville, but it just isn't working in Youtube. it would just show a black box which would immediately disappear. this is what happends when i use internet expl

  • Subtitle problem on 32L4333 TV. Weird font type due to greek language

    Hi there! I just bought a new Toshiba Smart Tv (32L4333) and while I am trying to view a video with greek subs there are only weird characters. I know that this problem is due to encoding but i can understand how in 2013 Toshiba doesn't have selectio

  • Premiere Pro Crash - Can't even load project

    Premiere was running fine for most of the weekend, then began to crash every time I tried to open the project. Other projects open briefly, followed by a crash within 5 minutes. Most recent error: Problem signature:   Problem Event Name:          BEX

  • Extracting mpeg files from DVD studio pro burnt DVD

    I burnt a dvd with studio pro a while back and have scince deleted the mpeg file. I want to make and edit and burn a new dvd. Is there any way to get my mpeg file back off the dvd so I can edit it?

  • Available Retraction from BPC to ECC

    Hi Friends ! I would like to know how many available retractors are possible from BPC to ECC: 1) Fund Management - BPC to BI & then Standard Tcode in ECC 2) PCA - Only possible for flat file upload Is there any more retractors? any presentation avail