This discussion is archived
12 Replies Latest reply: Nov 21, 2012 10:11 AM by adf009 RSS

insert mode when child table is empty

adf009 Explorer
Currently Being Moderated
hi i have a situation where i have two table,where when i select parent table it display related information in child table,but now i what to make child table to be in insert mode if there is no related data to parent table,how can i do that,am in jdeveloper 11.1.1.6.0,i have follow this http://www.baigzeeshan.com/ but it make insert mode when the page load,i what insert mode when there is no data in child table

Edited by: adf0994 on 2012/11/19 1:29 PM
  • 1. Re: insert mode when child tabale is empty
    user404 Pro
    Currently Being Moderated
    Use your bean (a listener on the first table or getter of the child table) to check if the child table is empty (if there are no rows or no current row, your table is empty.

    Edited by: 962432 on 16-nov-2012 14:21
  • 2. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    am using a view not a bean

    Edited by: adf0994 on 2012/11/21 10:29 AM
  • 3. Re: insert mode when child table is empty
    user404 Pro
    Currently Being Moderated
    Add a bean to your page.
  • 4. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    how do i create a bean if am using a view or the bean must only have listner method,and what kind of mathod is that do you have sample of that kind of bean. do i need to create getter and setter in that class,and which page must i adda bean

    Edited by: adf0994 on 2012/11/16 5:15 PM

    Edited by: adf0994 on 2012/11/16 5:16 PM

    Edited by: adf0994 on 2012/11/16 9:23 PM
  • 5. Re: insert mode when child table is empty
    DimitrisStasinopoulos Pro
    Currently Being Moderated
    Hi,

    as far as I can undestand, you dont want to block any queries in your detail table.

    So, your detail is being executed but does not fetch any records.

    I think you can achieve this in your detail view object by overriding the executeQueryForCollection method in your detail VO and place the following:

    protected void executeQueryForCollection(Object object, Object[] object2, int i) {
    super.executeQueryForCollection(object, object2, i);
    System.out.println(" just executed query for collection..");

    long count = this.getEstimatedRowCount();
    if(count==0){
    System.out.println(" creating a new row");
    Row createRow = this.createRow();
    this.insertRow(createRow);
    this.setCurrentRow(createRow);
    }
    }

    With that way, after you execute for Collection, you can check if there are any rows, and create a new Row in the detail as you want.

    This is one way to do it..
    Hope this helps,

    Regards,
    Dimitrios.
  • 6. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    if i may ask where must i write this method in my view imp class or bean,and where is this.insertRow(createRow);
    this.setCurrentRow(createRow);his.getEstimatedRowCount(); define

    Edited by: adf0994 on 2012/11/20 1:51 PM
  • 7. Re: insert mode when child table is empty
    DimitrisStasinopoulos Pro
    Currently Being Moderated
    Hi,

    Have a look at this post.

    http://dstas.blogspot.co.uk/2012/11/create-new-row-when-there-are-no.html

    I think it will help you,
    Regards,
    Dimitrios.
  • 8. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    its working now but when i add new row it show error below,but new record is added even if is showing error
    ORA-01400: cannot insert NULL into (.."FIELDLABEL"),this happen only when the page load and i navigate to parent table with empty row and try to insert,but after that i can insert without a problem to child table when is emtpy,it seems is validating first empty field than save enterd records

    Edited by: adf0994 on 2012/11/21 10:29 AM
  • 9. Re: insert mode when child table is empty
    DimitrisStasinopoulos Pro
    Currently Being Moderated
    Hi,

    I think you have some values as required. So the validations are triggered. You have to place some values in the newly created record..
    Since you have already created a new records, you have to place some values in it that are required.

    Regards,
    Dimitrios.
  • 10. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    am trying to use this method to check my post
        public void postChanges(TransactionEvent e) {
        /* If current entity is new or modified */
        if (getPostState() == STATUS_NEW ||
        getPostState() == STATUS_MODIFIED) {
        /* Get the associated supplier for the product */
          CfgTablesImpl fields = (CfgTablesImpl)this.getCfgTables();
        /* If there is an associated supplier */
        if (supplier != null) {
        /* And if its post-status is NEW */
        if (supplier.getPostState() == STATUS_NEW) {
        /*
        * Post the supplier first, before posting this
        * entity by calling super below
        */
        supplier.postChanges(e);
        }
        }
        }
        super.postChanges(e);
        }
    Edited by: adf0994 on 2012/11/21 10:28 AM
  • 11. Re: insert mode when child table is empty
    Sireesha Pinninti Expert
    Currently Being Moderated
    Try setting newly inserted row status to STATUS_INITIALIZED.

    Sample:
    inside executeQueryForCollection(){
    .
    .
    Row createRow = this.createRow();
    //Set row status to STATUS_INITIALIZED
    createRow .setNewRowStatus(ROW.STATUS_INITIALIZED);
    this.insertRow(createRow );
    .
    .
    }

    Sireesha
  • 12. Re: insert mode when child table is empty
    adf009 Explorer
    Currently Being Moderated
    hi am not able to see setNewRowStatus on the list option
    i did this
        protected void executeQueryForCollection(Object object, Object[] object2, int i) {
        super.executeQueryForCollection(object, object2, i);
        System.out.println(" just executed query for collection..");
    
        long count = this.getEstimatedRowCount();
        if(count==0){
        System.out.println(" creating a new row");
        Row createRow = this.createRow();
        createRow.setNewRowState(Row.STATUS_INITIALIZED);
        this.insertRow(createRow);
        this.setCurrentRow(createRow);
        }
        }
    now am geting error
    Detail entity CfgFields with row key null cannot find or invalidate its owning entity.
         i try to follow http://tfathy.blogspot.com/2011/04/detail-entity-with-row-key-null-cannot.html but with no luck
    am in jdeveloper 11.1.1.6.0

    when i write
    Row createRow = this.createRow();
    createRow.
    i only get this option for select setNewRowState am not able to see .setNewRowStatus

    Edited by: adf0994 on 2012/11/21 9:10 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points