How to modify and update a line later was inserted and updated in the doDML() method?

Mr President

Jdev worm is 12.2.1

How to modify and update a line later was inserted and updated in the doDML() method?

I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

Method 1-first row in managed bean

    public void addNewPurchaseVoucher(ActionEvent actionEvent) {
        // Add event code here...
        BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
        DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
        RowSetIterator rsi = dciter.getRowSetIterator();        
        Row lastRow = rsi.last();        
        int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
        Row newRow = rsi.createRow();        
        newRow.setNewRowState(Row.STATUS_NEW);        
        rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
        rsi.setCurrentRow(newRow);
        
        BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
        DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
        RowSetIterator rsi1 = dciter1.getRowSetIterator();        
        Row lastRow1 = rsi1.last();        
        int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
        Row newRow1 = rsi1.createRow();        
        newRow1.setNewRowState(Row.STATUS_NEW);        
        rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
        rsi1.setCurrentRow(newRow1); 
        
        
    }


Method of doDML() of line 2 seconds in the entityImpl class


    protected void doDML(int operation, TransactionEvent e) {        
        setAmount(getPurqty().multiply(getUnitpurprice()));
       
        if (operation == DML_INSERT)  
                   {          
                     insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
    (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                       }
                       
                       if(operation == DML_UPDATE)
                       {
                           
                       updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
    (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                       }                                       
        super.doDML(operation, e);
    }

    private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
              {  
                PreparedStatement stat = null;  
                try  
                {  
                  String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
   ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                  System.out.println("sql= " + sql);    
                  stat = getDBTransaction().createPreparedStatement(sql, 1);  
                  stat.executeUpdate();  
                }  
                catch (Exception e)  
                {  
                  e.printStackTrace();  
                }  
                finally  
                {  
                  try  
                  {  
                    stat.close();  
                  }  
                  catch (Exception e)  
                  {  
                    e.printStackTrace();  
                  }  
                }  
              }  
              
              private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
              {  
                PreparedStatement stat = null;  
                try  
                {  
                  String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
   + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                  System.out.println("sql= " + sql);      
                  stat = getDBTransaction().createPreparedStatement(sql, 1);  
                  stat.executeUpdate();  
                }  
                catch (Exception e)  
                {  
                  e.printStackTrace();  
                }  
                finally  
                {  
                  try  
                  {  
                    stat.close();  
                  }  
                  catch (Exception e)  
                  {  
                    e.printStackTrace();  
                  }  
                }  
              }

Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

 <af:button actionListener="#{bindings.Commit.execute}" text="Commit"

This button update the first line added by bean managed, but the second row remains unchanged.

Please help how to update the two lines with the same button or something else.

Concerning

DML_UPDATE will call only if there is some change data attributes.

I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

I assume the update statement should look like:

  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
  {
    PreparedStatement stat = null;
    try
    {
      String sql =
        "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
        "' where VID='" + value1 + "'";
      System.out.println("sql= " + sql);
      stat = getDBTransaction().createPreparedStatement(sql, 1);
      stat.executeUpdate();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      try
      {
        stat.close();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }

Tags: Java

Similar Questions

  • How to copy and paste into the search engine does not work?

    How to copy and paste into the search engine does not work?

    It should be.

    Restart your Mac and try again.

    Other than that, make sure that OS X is updated.

    Open the App Store, and then select the updates menu.

  • How can I remove updates in the App Store I want?

    How can I remove updates in the App Store I want? that is no longer use app, but I'm getting updates listed.

    Delete all copies of the application from the main HARD drive and all external drives or mounted partitions which can have the app.

    By the end of 2012 mini Mac, OS X El Capitan 10.11.4. Apple Watch, 38 mm silver AL, Watch OS 2.2; iPad 2 Air & iPhone 6 + iOS 9.3

  • I use windows 7. How to change and be sure the default column width in Windows Explorer

    I use windows 7. How to change and be sure the default column width in Windows Explorer

    Hi Jimsw,

    ·         If it works well before?

    ·         You did changes to the computer before the show?

    Explorer Windows will remember changed settings, check if this not happen as planned.

    Follow the suggestions below for a possible solution:

    Method 1: I suggest running the fix of the article and check if it helps.

    Diagnose and repair Windows files and folders problems automatically

    http://support.Microsoft.com/mats/windows_file_and_folder_diag/

    Method 2: You can increase the width of the selected columns and apply the settings to all files and check.

    a. right click on an empty space in the Windows Explorer, click on sort by.

    b. now, enter the size required in the Pixel with and click OK.

    Now, click on the drop down menu to organize and click on folder and Search Options.

    Click view and click apply to folders and click OK.

    I hope this helps.

  • Photography plan Cloud creative student and Teacher Edition (one year) and no idea of how to get and start using the programs?

    So I just brought the creative plan Cloud photography student and Teacher Edition (one year) and no idea of how to get and start using the programs?

    Hello

    Go to creative.adobe.com and you identify with your Adobe ID

    From there, you can download the applications you purchased.

    Normally, you are taken there immediately after the purchase.

  • Difference between variable interface user layout and presentation of the add() method UI?

    Hello

    What is the difference between a variable user interface layout and presentation of the add() method UI?

    Presentation of the variable user interface is something like this:

    var windowResource = "palette {  \
        orientation: 'column', \
        alignChildren: ['fill', 'top'],  \
        preferredSize:[300, 130], \
        text: 'ScriptUI Window - palette',  \
        margins:15, \
        \
        bottomGroup: Group{ \
            cd: Checkbox { text:'Checkbox value', value: true }, \
            cancelButton: Button { text: 'Cancel', properties:{name:'cancel'}, size: [120,24], alignment:['right', 'center'] }, \
            applyButton: Button { text: 'Apply', properties:{name:'ok'}, size: [120,24], alignment:['right', 'center'] }, \
        }\
    }";
    
    var win = new Window(windowResource);
    
    win.show();
    

    presentation of the UI Add() method is something like this:

    var w = new Window('dialog', 'Random Number Generator');
    var btn_group = w.add('group'),
        btn_ok = btn_group.add('button', undefined, 'Ok');
    
    w.show();
    

    Thank you!

    Since the Guide Javascript Tools on the specifications of the resource (you're high example on the page):

    You can create one or more UI both elements by using a resource specification. This specially formatted string provides a simple and compact of the creation of an element, including any container element and its constituent elements. The resource-specification string is passed as a parameter to the constructor function Window() or add().

    The general structure of a resource specification is a specification of item type (for example, dialog box).

    followed by a pair of curly braces surrounding one or more property definitions.

    myResource var = 'dialogue {control_specs} ";

    var myDialog is new window (myResource);.

    The controls are defined as properties in windows and other containers. For each control, give the name of the control class, followed by the properties of the control between braces.

    I had trouble getting the resource specifications to work - probably just didn't make the time to understand. A few differences is that some of the properties that they put in the resource specifications in brackets after the element will not work in the other method, if you do it this way. You normally have to make a second line and add this property. I'm not sure of the first method, but the second is the function object, and you can use the structure of the object (object, nextProperty, etc.) or set a variable to represent the object. In most of the scripts that I write, I use variables and give them a name such as:

    myCheckBox var = dlg.inSomeGroup.add ('checkbox', undefined, "text box '");

    myCheckBox.name = "maCaseACocher";

    By doing this, I can create a recursive function that goes through the entire user interface and retrieves the values of the elements and writes this information to an xml file. Including the names allows the script to identify which variable to control / it is in the xml file, so that it can be reassigned to proper control. I have not tried this with the method of specifications for resources, so I don't know if it will work with it.

  • How to select and default hightlight the first line in a programmatic Table(ADF Table created based on a SortableModel) ADF.

    Hi all


    We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.


    We created a table ADF programming related to a SortableModel created programmatically to a bean.


    We need to select and highlight the first row in the table just after making it to retrieve data based on the first line.


    We tried the based on the following thread: How to call the bean support just after JSFF / page fragment loads? and a few other posts online, but it does not work very well.


    W has created a hidden text in the bottom of the JSF model as follows:


    < af:table varStatus = "rowStat" Summary = "table" value = "#{pageFlowScope.crudBean.dynamicTable.collectionModel} '"

    Rows = "#{pageFlowScope.crudBean.dynamicTable.collectionModel.RowCount} '"

    contentDelivery = 'immediate' var = 'row' rendered = 'true '.

    Binding = "#{backingBeanScope.crudBackingBean.tasksTable} '"

    selectionListener = "#{backingBeanScope.crudBackingBean.customListener} '"

    "rowSelection ="single"id ="t1"partialTriggers =": pt_gr2 "columnStretching =" column: clmn0 ">

    < af:forEach items = "#{pageFlowScope.crudBean.dynamicTable.columnNames}" var = 'name' varStatus 'vs' = > "

    < af:column sortable = "true" sortProperty rowHeader = "#{name}" = "no style" headerText = "#{pageFlowScope.crudBean.dynamicTable.columnLabel [name]}" "

    inlineStyle = "width: 100px;"  ID = "clmn$ {vs.index}" >

    < af:activeOutputText value = "#{row [name]}" id = "aot1" / >

    < / af:column >

    < / af:forEach >

    < / af:table >

    ....


    < af:outputText id = "hiddenOutputTextId" visible = "false" value = "#{backingBeanScope.crudBackingBean.afterPageLoad} '"

    Binding="#{backingBeanScope.crudBackingBean.hiddenOutputText}"/ >

    And we have added the code to the bean to support below:

    public String getAfterPageLoad() {}

    If (!.) {AdfFacesContext.getCurrentInstance () .isPostback ()}

    selectFirstRowInTasksTable();

    }

    Return afterPageLoad;

    }

    public void selectFirstRowInTasksTable() {}

    try {}

    RKS RowKeySet = new RowKeySetImpl();

    RowKeySet rksEmpty = new RowKeySetImpl();

    Model CollectionModel = tasksTable.getValue ((CollectionModel));

    ROWCOUNT int = model.getRowCount ();

    If (rowcount > 0) {}

    model.setRowIndex (0);

    Key of the object = model.getRowKey ();

    RKS. Add (Key);

    tasksTable.setSelectedRowKeys (rks);

    SelectionEvent selectEvent =

    new SelectionEvent (tasksTable.getSelectedRowKeys (), rks, tasksTable);

    selectEvent.queue ();

    customListener (selectEvent); / / to retrieve data

    AdfFacesContext.getCurrentInstance () .addPartialTarget (tasksTable);

    }

    } catch (Exception e) {}

    }

    }

    I think that () selectEvent.queue; should work even without calling the customerListener, but it is not working in all cases.

    What is the problem in my code?



    Have you tried to bind property of 'selectedRowKeys' to selection configuration / bean there?

    Something like:

    public RowKeySet getSelectedRKS() {
        if (rks == null) {
            // make first record as selected
            // create RowKeySet and assign it to rks variable(where rks is variable defined in bean with some scope higher than request scope)
        }
        return rks;
    }
    

    Dario

  • How to modify and reuse the information on a CD

    I burned a photo on a CD powerpoint presentation and discovered that some text information was incorrect after

    View the presentation in the powerpoint viewer.

    Can I change the text on the presentation and it reburn on the same CD?

    Hello

    Only if the CD was a type RW. If the CD and R, then you can not change.

    If a RW, you can even delete the old information on the CD and re - burn the CD.

    I hope this helps.

  • How to know which update causes the system crash

    Can you tell us how to check the update is the culprit?

    Hi Steve,.

    Inorder to know which update is the cause of the crash of the system, you can install the updates one by one. Firstly uninstall the updates that have been recently installed.

    Uninstall the update:

    1. click on start and type "update installed" in the searc box. Click on view installed updates

    2. right click on the update you want to uninstall. Once the uninstall is complete, reboot the computer.

    3. install the updates one by one.

    You would get to know what update is at the origin of the disorder. You can hide this particular update.

  • How do we install updates when the installation program does not work

    Whenever I try to install the updates, I get to the page 'Please read the license terms' and 'Next' is not available.

    I've been in contact with Microsoft about this before, and an engineer has spent half of the day sorting - and it is still the same!

    Help, please!

    http://support.Microsoft.com/kb/971058

    How to reset the Windows Update components?

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://www.Microsoft.com/downloads/en/default.aspx

    Also, try to put the KB numbers in the search at the above link > then download them manually.

    If the above does not solve it:

    Windows Update Forum:

    It comes with Vista, upgrade install and activate Forum.

    You will get the best help for any problem of Update/Service Pack in the Windows Update Forum; the link below:

    http://social.answers.Microsoft.com/forums/en-us/vistawu/threads

    When you repost here, kindly include the Error Codes, and exactly what is happening when you try to update.

    In this way, you will receive the best help.

    See you soon

    Mick Murphy - Microsoft partner

  • How to install downloaded updates from the C:/Windows/Software Distribution?

    I downloaded the updates of Microsoft with a limited internet connection, but during the installation of the update, I turned off my laptop. After a google search, I find that the downloaded updates are store on "C:/Windows/Software Distribution/downloads and there are number of folders in the directory.

    But now I don't know how to install these updates downloaded from the directory. Please tell me how to deal with it because I have little internet connection and I can not afford to download again 1.7 GB of data.

    Hello Laura,

    Thanks for posting your query on the Microsoft Community.

    According to the description of problem you downloaded Windows Update but not installed at the same time and want to install in the folder C:/Windows/Software Distribution.

    I would like to inform you that the folder C:/Windows/Software Distribution just keep the entries in the updates that get downloaded or installed. We are not able to install the updates in this folder.

    However, I suggest you to check the update history and see whether or not the updates to install. According to my experience, the knowledge and conclusions, I know that if updates downloaded but then installed it after the next reboot of the computer.

    I suggest you return the item mentioned below and learn more about the Windows updates.

    Windows Update: frequently asked Questions

    Hope that the information provided is useful. Let us know if you have any concerns related to Windows. We will be more than happy to help you.

    Kind regards

  • How to customize and difficulty permanently the size (zoom %) web pages in Firefox that Internet Explorer is: view - Zoom - Custom (percentage).

    How do I customize and fix permanently the size of web pages (zoom %) in Firefox than Internet Explorer is:
    View - Zoom - Custom (percentage).

    Thank you

    This can help you.

    https://support.Mozilla.com/en-us/questions/894000

  • Satellite C660-1LD: how to recover and return to the factory settings

    Hi guys,.

    I suffer with any problem on any website a few linked words and when I click on it, an ad. opening of site Web which is a little virus I think and the laptop runs very slowly

    I decided to restart the laptop of the t and return to the factory settings.

    Could you please help me how to restart I'm not really good with computers so if you explain step by step it would be fantastic.

    Thank you

    Hello

    Read the discussions here in the forum of Toshiba product recovery.
    In addition, check this documentation how to use HARD drive recovery:

    + How to recover a Toshiba notebook with the HDD recovery procedure.
    http://APS2.toshiba-tro.de/KB0/HTD1303440001R02.htm

  • Qosmio G20 - how to find an update for the video card?

    Hi I can't find the update for the video card and when I run the game it hand me your video card drivers are too old.update them.
    my laptop:(toshiba Qosmio G20)
    My vidoe card: (NVIDIA GeForce Go 6600)
    Operating system: (Microsoft Windows XP Professional)

    Hey,.

    To be honest I don t understand your problem. Why visit nVidia?

    All you can download it from the download page of European driver from Toshiba as a boarder suggested. I even checked this and for Qosmio G20 and Windows XP you can get all the drivers no problem at all! :)

  • Indicator how to Panel on update of the target by target pc rt code?

    Hello

    I use a desktop as a target Rt PC.

    Using the shared variable, I can see the settings in the target.

    Another way to see parameter is to set an indicator in the control panel front of target code.

    I would like to know how this indicator updates?

    Which method is more efficient (that is, it causes less target the CPU usage)? Shares of variable or an indicator in the front panel of the code target?

    Also, I would like to know is there a way to see the front of the target code in the monitor which is connected to the RT PC target?

    Thanks in advance

    This white paperexplained a bit more including the integrated HIM available on newer cRIO controllers based on Linux

Maybe you are looking for