BC4J - create(AttributeList attributeList)

Hello all,
I am developing a JClient app using BC4J and I have a question regarding automatically populating a field on the creation of a new record. I have done this before with a sequence but these values are a little different.
In the create(AttributeList attributeList) method (of JDev's XXXImpl.java class), I want to query a separate table for a certain value and use that value to populate a field in my current object. This specific query will always return just the one value.
Does anyone know how I can do this or If there is a better(correct) way of doing this?
All thoughts/suggestions are welcome.
Regards,
Elder

Elder:
I would suggest the following:
In the create(AttributeList attributeList) method (of
JDev's XXXImpl.java class), I want to query a
separate table for a certain value and use that value
to populate a field in my current object. This
specific query will always return just the one value.Define a VO for this query. In the EO's create() method, do something like:
   ViewObject vo = getDBTransaction().getRootApplicationModule().findViewObject(<VO-name>);
   Row row = vo.first();
   Object val = row.getAttribute(<Attr-name>);
   populateAttributeAsChanged(<eo-attr-index>, val);Thanks.
Sung

Similar Messages

  • Did bc4j create row with sequence change from integer to long

    When creating a new row through bc4j with database sequence for primary key, I followed the online examples and even checked the samples distributed with jdev production 9.0.2. They all show that the sequence is returned as Integer. I finally changed it to Long and got it to work. Has there been a change, or have I got something else fouled up?
    This is the code that worked...
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    // get the next template ID from database sequence
    SequenceImpl s = new SequenceImpl("XXPRC_TEMPLATE_ID_S", getDBTransaction() );
    java.lang.Long next = (java.lang.Long) s.getData();
    setTemplateId( new Number(next) );
    }

    When creating a new row through bc4j with database sequence for primary key, I followed the online examples and even checked the samples distributed with jdev production 9.0.2. They all show that the sequence is returned as Integer. I finally changed it to Long and got it to work. Has there been a change, or have I got something else fouled up?
    This is the code that worked...
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    // get the next template ID from database sequence
    SequenceImpl s = new SequenceImpl("XXPRC_TEMPLATE_ID_S", getDBTransaction() );
    java.lang.Long next = (java.lang.Long) s.getData();
    setTemplateId( new Number(next) );
    } Yes some javadoc was corrected to reflect this change in 9.0.2. Could you post the "context" for the javadoc where you're seeing this example so we can verify if that's corrected too.
    To get the correct Sequence value, you need to call getSequenceNumber() method and not getData which should have been (and is in 902) marked internal.

  • Uix BC4J: create a link download to download my resultsets

    Greetings,
    The case:
    - i've created my flows using the amazing uix bc4j technology;
    - end users can manipulate their data (view and update)
    - Now i'd like to create a link which will point over the query result and download the data with csv or xls format.
    Could anyone help me on that issue ? 've checked in online doc, did not find a valuable info.
    Thks for your help
    Cheers
    lb

    Hm - good point, Riley. Hadn't tried Go to URL, though I realise now this is simply because I forgot to ignore the dire warnings about "not a FrameMaker file" :-}
    However, now I have made the experiment:
    * opening the .pdf directly in Acrobat and clicking on the link opens the .zip application immediately - still no "download/open" option
    * opening the .pdf through a browser puzzlingly netts me "The file ///C:/tempo/mup55lin.tgz cannot be found. Please check the location and try again." Needless to say, the file in question is right there where it should be ...

  • Problem building unique key in create (AttributeList) after cancel create ?

    Hallo,
    i have a create form. In the create process i build a unique key.
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    try {
    String strSQL = "select max(ver_nr) from verfuegungen where sts_id = ?";
    PreparedStatement stmt = getDBTransaction().createPreparedStatement(strSQL,0);
    stmt.setInt(1,getStsId().intValue());
    ResultSet rs = stmt.executeQuery();
    rs.next();
    String snr = rs.getString(1);
    int inr = 0;
    if (snr != null)
    inr = Integer.parseInt(snr);
    inr = inr + 1;
    Number nnr = new Number(inr);
    setVerNr(nnr);
    The create process can be cancelled with the following method
    public String onCancelCreateVerfuegung() {
    BindingContainer bindings = getBindings();
    bindings.getOperationBinding("DeleteNewVerfuegung").execute();
    return "backpostdetails";
    When i initiated the create process after cancelling a second time, i've got JBO-25013.
    What can i do in the delete process that the error can't come?
    Any help is appreciated.

    Hi Claudio,
    well, I have an solution although it is neither nice nor clean...
    * Add a column Field2_notnull to Table B with not null-constraint and same type as Field2
    * Add a check-constraint to Table B like this: "nvl(Field2,'*') = Field2_notnull"
    * Create a UNIQUE KEY on Table B's Field1 and Field2_notnull and use this constraint for the MERGE-Load (INSERT/UPDATE)
    * Coming from Table A, use Field1 and nvl(Field2,'*') for the match
    As I said, neither nice nor clean, but it works, as long as you can manage to fill Field2_notnull in Table B correctly.
    Best regards
    Andreas

  • Oracle.jbo.RowCreateException: JBO-25017: Error while creating a new ROW

    I am trying same multi step PO example. I have created a search page and there are 3 other pages for PO Header, PO Line and Review/Submit Page. I am coming on 2nd page(creating Line Item) and when I click on create new item record I am getting this error. Any help will be aprrecaited.
    oracle.jbo.RowCreateException: JBO-25017: Error while creating a new entity row for POLinesEO.
    This is my code for POLineShipFullVORowImpl.java
    protected void create(oracle.jbo.AttributeList nvp)
    POLinesEOImpl lineEO = (POLinesEOImpl)getEntity(0);
    POShipmentEOImpl shipmentEO = (POShipmentEOImpl)getEntity(1);
    try
    // Create Lines EO
    lineEO.create(nvp);
    // Create Shipments EO
    shipmentEO.create(lineEO);
    // Calling this ensures that any personalization default values are
    // properly set since the OAF normally sets this in the super.create(), but
    // since this is not called in this workaround, we need another method
    // to ensure customer defaults are applied.
    // The following method was introduced in OAF internal release 11.5.10J. Since
    // the production release of the ToolBox must be able to run on 11.5.10I, this
    // cannot be enabled.
    // setDefaultValue();
    catch (Exception ex)
    lineEO.revert();
    shipmentEO.revert();
    if (ex instanceof oracle.jbo.JboException)
    oracle.jbo.JboException jboEx = (oracle.jbo.JboException)ex;
    // Developers have to do the mapping on their own becauce of the override.
    jboEx.doEntityToVOMapping(getApplicationModule(), new oracle.jbo.ViewObject[]{getViewObject()});
    throw jboEx;
    throw OAException.wrapperException(ex);
    } // end create()
    Code for PoLinesEOImpl.java
    * Initializes a new purchase order line.
    public void create(AttributeList attributeList)
         // NOTE: header id is automatically set by BC4J because of the
    // composition association.
    super.create(attributeList);
    OADBTransaction transaction = (OADBTransaction)getOADBTransaction();
    // DEFAULT: line id
    Number lineId = transaction.getSequenceValue("FWK_TBX_PO_LINES_S");
    setLineId(lineId);
    // DEFAULT: Line number
    POHeaderEOImpl headerEO = getPOHeaderEO();
    Number newLineNum = headerEO.getNextLineNum();
    setLineNumber(newLineNum);
    } // end create()
    * Sets <code>value</code> as the attribute value for ShipmentNumber
    * Business Rules
    * Required; cannot be null
    * Cannot be updated on a committed line
    * Must be unique for this purchase order
    * Must be >= 1
    public void setLineNumber(Number value)
    if (value != null)
    // Verify value is > 0
    if (value.compareTo(0) <= 0)
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // EO name
    getPrimaryKey(), // EO PK
    "LineNumber", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "DEBUG -- add message"); // Message name
    // To verify uniqueness, start by checking the entity cache.
    com.sun.java.util.collections.Iterator lineIterator =
    getEntityDef().getAllEntityInstancesIterator(getDBTransaction());
    Number lineId = getLineId();
    Number headerId = getHeaderId();
    while ( lineIterator.hasNext() )
    POLinesEOImpl cachedLine =
    (POLinesEOImpl)lineIterator.next();
    Number cachedLineNum = cachedLine.getLineNumber();
    Number cachedLineId = cachedLine.getLineId();
    Number cachedHeaderId = cachedLine.getHeaderId();
    if ((cachedLineNum != null) &&
    (cachedLineNum.compareTo(value) == 0) &&
    (cachedLineId.compareTo(lineId) != 0) && // Exclude this line
    (cachedHeaderId.compareTo(headerId) == 0))
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // EO name
    getPrimaryKey(), // EO PK
    "LineNumber", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "DEBUG -- add message"); // Message name
    // Didn't find a duplicate in the entity cache so now we check the database.
    // Note: don't bother with this if the header is in a NEW state since that
    // means we won't have any lines in the database yet.
    POHeaderEOImpl headerEO = getPOHeaderEO();
    if (headerEO.getEntityState() != STATUS_NEW)
    PurchaseEntityExpert poExpert =
    POHeaderEOImpl.getPurchaseEntityExpert(getOADBTransaction());
    PoLineNumVVOImpl valLineNumVO =
    (PoLineNumVVOImpl)poExpert.findValidationViewObject("PoLineNumVVO1");
    valLineNumVO.initQuery(headerId, value);
    // We're doing an existence check; shouldn't have any rows.
    if (valLineNumVO.hasNext())
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // EO name
    getPrimaryKey(), // EO PK
    "LineNumber", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "DEBUG -- add message"); // Message name
    // If this is the largest line number for this order, this will store it for
    // reference when creating subsequent lines.
    headerEO.resetLineNum(value);
    setAttributeInternal(LINENUMBER, value);
    } // end setLineNumber()
    Edited by: user9941374 on Mar 15, 2012 3:16 PM

    Hi Frank,
    As per the steps mentioned in the following link :
    http://www-apps.us.oracle.com:1100/fwk/jdev/doc/devguide/bus/bus_java.htm#tl
    I have created the required entity objects and view objects.
    I have an entity JobsDEO which is based on a view per_jobs_vl which is itself based on 2 tables,per_jobs_f and per_jobs_tl,wherein _tl is the translation table.
    The entity for _tl table is JobTranslationEO and has no VO associated with it.Its the JobsVO,based on JobsDEO,that has to handle any interactions with this entity too.
    JOBSDEO has a property set up for HCM_DBSEQUENCE,which makes it read the value of job_id from the sequence per_jobs_s.
    Now,when I try to insert into the JobsVO,based on JobsDEO,it gives me the above mentioned error.
    One more thing is that the error does'nt occur when we commit a row,its just when we click the "+" button in the AM Tester that we get this error.
    Please advice.

  • HOWTO: Use BC4J With or Without DB Triggers

    This HowTo describes how to use BC4J, database sequences and triggers
    and what are the ramifications.
    INTRODUCTION
    BC4J has the ability to work with database sequences in order to obtain a
    unique value when inserting records. BC4J also has the ability to
    work either with a 'before insert' trigger which automatically creates
    a new unique value for the primary key or without a trigger. When not using
    a database trigger, BC4J also has the ability to obtain the sequence value
    and set the primary key value.
    Before discussing the ramifications of using one approach or the other, let's
    show examples of how to use both approaches:
    BC4J & sequences WITH a database trigger
    and
    BC4J & sequences WITHOUT a database trigger
    HOWTO DEMONSTRATION STEPS
    To illustrate both scenarios a simple database setup script is provided which
    creates two tables:
    CUSTOMER_NT which DOES NOT have a before insert trigger and
    CUSTOMER_WT which DOES have a trigger.
    Database Install Script:
    <code>
    drop trigger customer_insert_trigger;
    drop table customer_wt;
    drop table customer_nt;
    drop sequence customer_wt_seq;
    drop sequence customer_nt_seq;
    create sequence customer_wt_seq start with 1;
    create sequence customer_nt_seq start with 101;
    create table customer_wt(
    id number,
    name varchar2(30),
    constraint
    customer_wt_pk
    primary key (id)
    create table customer_nt(
    id number,
    name varchar2(30),
    constraint
    customer_nt_pk
    primary key (id)
    prompt Inserting data...
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Mickey');
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Goofy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Daffy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Porky');
    commit
    prompt Creating trigger
    create trigger customer_insert_trigger
    before insert on customer_wt for each row
    begin
    select customer_wt_seq.nextval into :new.id from dual ;
    end;
    </code>
    The next step is to create the DEFAULT Entity Objects and View Objects using
    the Business Components Wizard.
    USING BC4J WITH A DATABASE TRIGGER
    Let's modify the entity object CustomerWt so it can use the database trigger.
    Edit the entity object CustomerWt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox. This allows you to insert without a value for the primary key
    - Check 'Refresh after Insert'. This obtains the value from the database generated by the trigger.
    - Check 'Updateable While New'. Id is only updateable when inserting.
    Click finish to complete the wizard. Save all and recompile the project.
    Now let's test our work.
    In the navigator right-click the application module and select 'Test..'. This will launch
    BC4J's built in tester. Connect to the application.
    In the tester double-click the CustomerWtView view object to run a test edit form.
    After the edit form renders, navigate through the existing records using the navigate
    buttons on the edit form. Now let's insert a record to execute the trigger.
    click on the '+' button to insert a record. Enter a value in the 'Name' field and commit the change.
    Observe that a new value has automatically been inserted into the Id field.
    That's it! You have successfully used BC4J and a database trigger.
    Now let's try it without a trigger..
    USING BC4J WITHOUT A DATABASE TRIGGER
    Now edit the entity object CustomerNT so it doesn't need a database trigger.
    Similar to before, edit the entity object CustomerNt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox.
    - Check 'Updateable While New'.
    An additional step is also required. The Create method will have to be modified to extract
    the value of the sequence.
    In the Edit EntityObject Wizard click the Java tab and select Create method and click Finish.
    The create method is generated in your Java fil e. In the Workspace view of the Navigator,
    expand the CustomerNt entity object in the navigator. Double-click
    CustomerNtImpl.java to open it in the Source Editor. In the Structure pane, double-click
    create(AttributeList). Modify the Create method so it looks like this:
    <code>
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("customer_nt_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue())); }
    </code>
    Save and compile the project.
    Now test the ViewObject CustomerNtView using the tester as before.
    In the edit form of CustomerNTView click on the '+' to insert a record. Observe that
    just as before a new value has automatically been inserted in the ID field!
    TO USE A DB TRIGGER OR NOT TO USE A DB TRIGGER.
    Using a Database trigger sometimes preferable if you have non BC4J applications
    also sharing the database. In this case it is still safest to just let the database
    update it's own primary keys.
    If you don't have any other non-BC4J applications sharing the database, then not using
    a database trigger is perfectly acceptable and can have slightly better performance.
    The important thing to remember is that the option is yours to use either approach!
    null

    Thank you for the reply Jonathon. I am using a ViewObject which
    consist of several tables. I haven't tried the DB trigger
    approach but just using the BC4 approach in overriding the
    create method.
    Here is the parent class create as a part of the
    FasNameImpl.java file which does the job correctly.
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl l_seq = new SequenceImpl
    ("SEQ_CUSTOMER_ID",getDBTransaction());
    Integer l_next = (Integer)l_seq.getData();
    setCustomerId(new Number(l_next.intValue()));
    This is when I triedpassing the value to the child table. But I
    can't figure it out. I think the link is working fine if I had a
    ViewLink deployed but it doesn't look like it's doing the job
    for ViewObject.
    I am trying to call the childclass.method
    (FasCustomer.setCustomerId(l_next);
    But I am getting error.
    Thanks a lot for your suggestions,
    Kamran
    703 696 1121

  • JBO-25017:Error occurred while creating a new entity instance (URGENT)

    Hello, can anybody help me?
    We have a project that uses BC4J business components and UIX-based web tier. The entity object that causes this problem is based on Oracle table with 'ID' key field, the value is generated by means of 'before_ins' trigger that inserts appropriate sequence's next value.
    In the java EntityImpl-based class we redefine protected 'create' method of the base class:
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    SequenceImpl idSeq = new SequenceImpl("SEQ_CATPARAMETERS", getDBTransaction());
    setId( idSeq.getSequenceNumber() );
    The fault is in the third line - setId(...) causes the exception.
    The only description of JBO-25017 I found is
    http://www.ffpmp.ru/doc/rt/oracle/jbo/CSMessageBundle.html#EXC_ENTITY_ROW_CREATE, this one don't throw any light on the problem.
    Oracle server version - 9.2.0.1
    Oracle JDeveloper version - 9.0.3.10.35,
    BC4J version - 9.0.3.10.7
    Any ideas?

    Roman,
    It looks like you're trying to assign the Id in two places.
    EITHER:
    Override the create method to assign an Id when a new entity instance is created....
    OR:
    Define a database trigger to insert the Id (and set the "refresh after insert" attribute to true).
    [Maybe the error is thrown because you're attempting to set a field which is set to refresh?]
    Does that make any sense?
    Mike

  • Creating new rows in OrderLines child

    I am currently having an issue when trying to create a new row in my order_lines table for an existing Order. When I try to do row.createRow() I get:
    Trying to create a new order line
    oracle.jbo.InvalidOwnerException: JBO-25030: Failed to find or invalidate owning entity.
         void oracle.jbo.server.EntityImpl.create(oracle.jbo.AttributeList)
         void org.cgfns.cerpass.bc.products.CrpOrderLinesImpl.create(oracle.jbo.AttributeList)
         void oracle.jbo.server.ViewRowStorage.create(oracle.jbo.AttributeList)
         void oracle.jbo.server.ViewRowImpl.create(oracle.jbo.AttributeList)
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createInstance(oracle.jbo.server.ViewRowSetImpl, oracle.jbo.AttributeList)
         oracle.jbo.server.RowImpl oracle.jbo.server.QueryCollection.createRowWithEntities(int[], oracle.jbo.server.EntityImpl[], oracle.jbo.server.ViewRowSetImpl,oracle.jbo.AttributeList)
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(int[], oracle.jbo.server.EntityImpl[], oracle.jbo.AttributeList)
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRow()
         oracle.jbo.Row oracle.jbo.server.ViewObjectImpl.createRow()
         void org.cgfns.cerpass.bc.products.TestMasterDetailView.main(java.lang.String[])
    This is the meat of the program. I've started simple to try to isolate the issue. BCs are having trouble inserting using the example provided in other OTN posts covering the same type of issue. I thinking BC4J might have a problem with the primary keys. The OrderHeaders table is linked to the OrderLines table via the OrderHeaderID but there is also a DB Sequence field for OrderLines called OrderLinesId. Both of there are checked as PK. I'm not sure if this may be causing an issue or not.
    I did create a test using the OE schema on Orders and Orderlines and I am able to create rows in it. Howerver there is no DBSequence in the OrderItems table like there is in the OrderLines table that is giving me a problem. I am able to create a view link to the OrderHeaders table and the do the link.getSource and link.getDestination calls to get the viewObjects. I then create a new row using createRow and set the attributes and commit. All works fine in OE. I do the same on the other table (OrderLines, OrderHeaders) I get the error. My source is a follows.
    public static void main(String[] args) {
    TestMasterDetailView test = new TestMasterDetailView();
    test.getApplicationModule();
    String orderId = "1106";
    if(test.am == null) {
    System.out.println("Error appMod null");
    ViewLink ordersToItems = test.am.findViewLink("CrpOrderHeaderFk1Link");
    ViewObject ordersV = ordersToItems.getSource();
    ordersV.setWhereClause("ORDER_HEADERS_ID = " + orderId);
    ordersV.executeQuery();
    System.out.println("RowCnt = " + ordersV.getRowCount()); // returns 1
    Row oRow = ordersV.next(); // throws invalid entity
    System.out.println("OrderHeadersId = " + oRow.getAttribute("OrderHeadersId"));
    ViewObject itemsV = ordersToItems.getDestination();
    if(itemsV == null) {
    System.out.println("Error itemsV == null!");
    System.out.println("Trying to create a new order line");
    Row itemRow = itemsV.createRow();
    itemRow.setAttribute("OrderHeadersId", orderId);
    itemRow.setAttribute("OrderLinesId", "3030");
    itemRow.setAttribute("StatusTypesId", "125");
    itemRow.setAttribute("Quantity", "111");
    itemRow.setAttribute("BundlesId", "139");
    itemsV.insertRow(itemRow);
    test.am.getTransaction().commit();
    test.am.remove();
    All I really want to do is insert a new record into the OrderLines table. From what I've read this seems to be an issue because of the associations. Any help would be greatly appreciated.
    Thanks,
    Brad Gibson
    TUSC

    It doesn't look like you're using DBSequence domain for the OrderLinesId attribute. If you are then you do not need to fill in the sequence as you've done in the create method.
    Getting back to create issue, You may want to set the 'order' id (foreign key) values before calling super and then call the getOrder() (or getXXX where XXX is the order accessor in this entity) method to verify if the order of the given ID exists/found in the cache.
    By the way, are you also using a similar create() in order with DBSequence as the type for the pK and you force a sequence value on top of it via setAttribute?
    Yes, this is the create method inside CrpOrderLinesImpl.java
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("CRP_ORDER_LINES_ID_SEQ", getDBTransaction());
    setAttribute("OrderLinesId",s.getSequenceNumber());
    Thanks,
    Brad

  • How to use an Oracle sequence with BC4J ?

    I'm using Business Components for Java (BC4J) with JDeveloper 3.0.
    In my database I need to insert a unique ID for each record inserted (a user ID).
    I know Oracle can generate automatically this munbers, using a sequence.
    How can I insert it automatically in the BC4J view?
    The user should be able to edit this number, since it's for identification inside the system.
    Thanks!
    null

    This is what I got from another mailing list.
    It worked for me, try it!
    Here's a code example that works for the customer table in the online order sample application that ships with jdeveloper 3. You need to override the entity's create() method (when you generate the entity you need to
    generate a create() method - check "create method" in the Java tab of the entity wizard).
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("customer_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue()));
    }

  • BC4J Objects with PKs based on two columns using multiple sequences

    I have implemented a BC4J object that is based on a DB table that has two columns as the primary key. For example Table A's primary key is Group and ID and there is a DB sequence for each Group.
    I use the BC4J object using servlets and JSPs and I have been able to implement an Update form.
    I now want to implement a Create (New) form. I've read forum postings and info on the help regarding using the SequenceImpl class to override the EntityImpl object's create method as shown below:
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    SequenceImpl mySeq = new SequenceImpl("MY_SEQ",getDBTransaction());
    setMyObjectId(mySeq.getSequenceNumber());
    But as you can see I need to know the value of the group attribute before I can get the next value sequence:
    For new EO belonging in Group1 I need sequence from "GROUP1_SEQ", Group 2 from "GROUP2_SEQ", etc.
    I would like to put this code in the Entity Object where it belongs. I guess my problem is simply how to create a new row in the View Object with a passed parameter which is the value of Group.
    Thanks in advance!

    Angelo:
    How is the EO suppose to receive the group id? Is it from the view row? If so, the VO can pass that group id to the EO through the attribute list and calling the
    public Row createAndInitRow(AttributeList nvp);
    API.
    Example code would be:
    ViewObject myVO;
    // myVO is initialized
    AttributeList nvp = new oracle.jbo.NameValuePairs();
    // GroupID is the attr name of the Group ID
    nvp.setAttribute("GroupID", <some-value>);
    Row row = myVO.createAndInitRow(nvp);
    If you do that the create(AttributeList attributeList) method of the EO will receive the GroupID value coming from the VO.
    Then, you can use that for your sequence.
    Thanks.
    Sung

  • Defaulting logic in entity create method

    Hi
    As suggested by BC4J I use the create method of my entity object to insert defaulting logic for some attributes. The code looks like this:
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    Number seqNumber = new Number();
    SequenceImpl s = new SequenceImpl("REV_SEQ", getDBTransaction());
    seqNumber = s.getSequenceNumber();
    setRevId(seqNumber);
    setCreationDate(SamUtils.getSystemDate());
    ApplicationModule am = getDBTransaction().getRootApplicationModule();
    if (am instanceof SecuredApplicationModule)
    setUsrId(((MyApplicationModule) am).getUsrId());
    But executing this code results in an Exception: "JBO-25014: Other User has changed the Row". If I remove the code between the lines above everything works ok.
    My questions are:
    - Is it ok to use set-Methods in the entity create method? Or should I set my default values to the "attributeList" instead?
    - do you think it is a problem to use the ApplicationModule as shown? I should mention that am.getUsrId() simply returns a previously stored variable and does not perform any queries or alike.
    Thanks for your help
    Frank Brandstetter

    It's definitely fine to setAttributes - I've done it myself (but not using "specific" setters).
    I haven't used the built-insequences before - this bit of your code looks a bit wasteful in terms of object creation, but that's obviously not your issue....
    It looks fine to use an application module in such a way; I coded a "current user id" function on mine too.
    I actually suspect the date-attribute, since I (me again!) had some "concurrent user" problems too. The issue was the fact that a Java date is accurate to the millisecond, and the database storage and retrieval wasn't. (I wasn't using Oracle so I'm not sure how it goes there....) A "concurrent user" exception gets thrown when bc4j goes to update an entity and finds that the date-value in the object doesn't match the "rounded" one it retrieves (as a check, just before it does the update - this is the optimistic locking) from the database. [So does the error occur only when you've saved the new entity once, then update it and try to save it again?]
    I got around it by setting the millisecond portion of any dates I used to zero (since the "storage" was accurate to a second) - so you might try that. (Did it generically in prepareForDML in my own Entity superclass, I think.)
    Otherwise, try setting the attribute, but not in the create method, and seeing if you get the same problem...
    HTH
    Mike.

  • BC4J Entity object validation and JSP

    Hi, I've been trying to implement BC4J best practices as per a previous thread with Steven Muench.
    I've placed all my business logic/validation in the entity object create and validateEntity methods. This works perfectly in the tester utility.
    In a JSP page the first time around the error raised also gets displayed properly prompting the user to go back and fix his data entry. The problem is that the error keeps reappearing even after the data has been fixed.
    We use web beans to perform the save using standard create/setAttribute/InsertRow/commit logic.
    The whole setup works perfectly in JSP if there are no errors in the data.
    Any pointers or ideas?
    Thanks.
    null

    productNew.jsp
    <FORM NAME="saveForm" METHOD=POST ACTION="productSave.jsp">
    <table align="center">
    <tr>
    <td>
    <div align="right">Product Code:</div>
    </td>
    <td>
    <input type="text" name="productcode" size="6" maxlength="6">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Sname:</div>
    </td>
    <td>
    <input type="text" name="productsname" size="20" maxlength="20">
    </td>
    </tr>
    <tr>
    <td height="19">
    <div align="right">Product Name:</div>
    </td>
    <td height="19">
    <input type="text" name="productname" size="45" maxlength="45">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Type:</div>
    </td>
    <td>
    <jsp:useBean class="com.palmtreebusiness.edms.products.jsp.LovBean" id="lov1" scope="request">
    <%
    lov1.setLovDefault("None Selected");
    lov1.setLovKey(0);
    lov1.setLovKeyDescription(1);
    lov1.setJSOnChangeMethod("");
    lov1.setLovHTMLField("producttypekey");
    lov1.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProducttypetbView");
    lov1.render();
    %>
    </jsp:useBean> </td>
    </tr>
    <tr>
    <td>
    <div align="right">Product Sub Class:</div>
    </td>
    <td>
    <jsp:useBean class="com.palmtreebusiness.edms.products.jsp.LovBean" id="lov2" scope="request">
    <%
    lov2.setLovDefault("All Selected");
    lov2.setLovKey(0);
    lov2.setLovKeyDescription(1);
    lov2.setJSOnChangeMethod("");
    lov2.setLovHTMLField("productsubclasskey");
    lov2.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProductsubclasstbView");
    lov2.render();
    %>
    </jsp:useBean>
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">STCC DG Code:</div>
    </td>
    <td>
    <input type="text" name="stccdgcodekey" size="10" maxlength="10">
    </td>
    </tr>
    <tr>
    <td>
    <div align="right">Harmonized Code:</div>
    </td>
    <td>
    <input type="text" name="harmonizedcode" size="20" maxlength="20">
    </td>
    </tr>
    </table>
    </form>
    productSave.jsp
    <%@ page language = "java" errorPage="errorpage.jsp" import = "java.util.*, oracle.jbo.*, javax.naming.*, oracle.jdeveloper.html.*, oracle.jbo.html.databeans.*" contentType="text/html;charset=ISO-8859-1"%>
    <%
    // make sure the application is registered
    oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule");
    %>
    <HTML>
    <HEAD>
    <jsp:useBean id="prod" class="com.palmtreebusiness.edms.products.jsp.productSavebean" scope="request">
    <%
    try {
    prod.initialize(pageContext, "productsjsp_com_palmtreebusiness_edms_products_bc4j_bc4jmodule.ProducttbView");
    prod.setReleaseApplicationResources(true);
    prod.save();
    response.sendRedirect("productList.jsp");
    response.setStatus(response.SC_MOVED_TEMPORARILY);
    catch (Exception ex) {
    out.println("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\">");
    out.println("<META NAME=\"GENERATOR\" CONTENT=\"Oracle JDeveloper\">");
    out.println("<TITLE>");
    out.println("Save Error");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("A save error occured.<br><br>");
    out.println(ex.getMessage());
    out.println("<br><br>Plese use the back feature of your browser to go back to the form and fix your data.");
    out.println("</BODY>");
    out.println("</HTML>");
    %>
    </jsp:useBean>
    saveBean.java
    public void save() throws oracle.jbo.JboException {
    Row rRow;
    System.out.println(request.getParameter("producttypekey"));
    System.out.println(request.getParameter("productsubclasskey"));
    try {
    // get the rowset instance
    RowSet rSet = getRowSet();
    rRow = rSet.createRow();
    rRow.setAttribute("Producttypekey", new Number(request.getParameter("producttypekey")));
    rRow.setAttribute("Productsubclasskey", new Number(request.getParameter("productsubclasskey")));
    rRow.setAttribute("Productcode", request.getParameter("productcode"));
    rRow.setAttribute("Productsname", request.getParameter("productsname"));
    rRow.setAttribute("Productname", request.getParameter("productname"));
    rRow.setAttribute("Stccdgcodekey", new Number(request.getParameter("stccdgcodekey")));
    rRow.setAttribute("Harmonizedcode", request.getParameter("harmonizedcode"));
    rSet.insertRow(rRow);
    rSet.getApplicationModule().getTransaction().commit();
    catch (oracle.jbo.JboException jboex) {
    qView.reset();
    throw new oracle.jbo.JboException(jboex.getMessage());
    catch (Exception ex) {
    throw new oracle.jbo.JboException(ex.getMessage());
    producttbimpl.java
    public void create(AttributeList attributeList) {
    try {
    SequenceImpl s = new SequenceImpl("producttb_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setProductkey(new Number(next.intValue()));
    super.create(attributeList);
    catch (Exception jboe) {
    if (jboe instanceof oracle.jbo.JboException) {
    oracle.jbo.JboException ex2 = (oracle.jbo.JboException)jboe;
    if (ex2.getErrorCode().equals("25030")) {
    return;
    throw new oracle.jbo.JboException("Unable to create this record!\n" + jboe.getMessage());
    public void validateEntity() throws oracle.jbo.JboException {
    //TODO: Add custom implementation.
    Number nSubclasskey, nTypekey;
    Number nSubclassFkey, nTypeFkey;
    try {
    nSubclassFkey = getProductsubclasstb().getProductclasskey();
    nTypeFkey = getProducttypetb().getProducttypekey();
    nSubclasskey = getProductsubclasskey();
    nTypekey = getProducttypekey();
    if (!nSubclassFkey.equals(nSubclasskey) &#0124; &#0124; !nTypeFkey.equals(nTypekey)) {
    throw new oracle.jbo.JboException("You need to specify a product sub class and type first!");
    catch (Exception ex) {
    throw new oracle.jbo.JboException("You need to specify a product sub class and type first!");
    super.validateEntity();
    null

  • BC4J/UIX Multi Entity insert/update

    Hi!
    Problem
    Is it possible to insert simultaneously both master and detail BC4J row with single UIX page? I would like to use standard UIX if possible with minimal java, but examples with java would be also helpful.
    Example
    This seems to be a very simple situation. Has anybody solved it?
    In my case I have one generic Document table and additional attributes tables for different kinds of documents like for instance LicenseDocument. Those tables are connected with Document table with 1 to 0..1 relationship and their foreign key to the Document table is also their primary key.
    I like the way that BC4J Tester works and I don't know how to make UIX work the same way.
    When I use BC4J Tester it assigns the Document table inserted but not yet committed rows primary key (DBSequence) column temporary negative values and I can insert child records that are associated with it. After commit the Document primary key is fetched from the database sequence and all the foreign keys in other tables get updated accordingly.
    When I use UIX I don't get those temporary IDs and so I can't create child records before the master record is committed. This is not good as I can't roll back the whole creation of the LicenceDocument.
    References
    I started by posting this topic to UIX forum (BC4J Multi Entity insert/update but maybe someone here knows the solution.
    Thanks in advance!
    Mihkel N�ges
    [email protected]

    I managed to workaround the issue in UIX by not using DBSequence type but fetching the sequence value in EntityImpl create method (as in Steve Muench's Techiniques demo project http://radio.weblogs.com/0118231/stories/2003/07/11/codeSampleIllustratingVariousBc4jProgrammingTechniques.html ):
    DocumentImpl.java:
    protected void create(AttributeList attributeList)
         super.create(attributeList);
         // Do this last so we don't waste any sequence numbers unnecessarily
         SequenceImpl seq = new SequenceImpl("DOCUMENT_ID_SEQ",getDBTransaction());
         setId(seq.getSequenceNumber());
    For some reason the sequence gets asked twice for every row creation. Thats not a big problem, but in the SequenceImpl javadoc this is discussed and as I understand it should not happen.

  • UIX XML - BC4J +

    We are implementing a functionality to insert new elements using BC4J components and UIX XML.
    We have carefully followed istruction from the UIX developer's guide (Business Components for Java Integration) but we notice some problems
    that we suppose are due to RowDefs with autocreate=true and the KEY attribute management flow.
    The components implemented have:
    1) A create method implemented for setting entity primary key using a DB sequence and other default values:
         protected void create(AttributeList attributeList) {
              super.create(attributeList);
              SequenceImpl seq = new SequenceImpl("VA_TIPO_PUNTEGGIO_SEQ", getDBTransaction());
              setAttribute("IdTipoPunteggio", seq.getSequenceNumber());
              setDataAgg(new Date( new Timestamp(System.currentTimeMillis())));
    2) A validation rule that checks for duplicate description using a ListCompare:
    <ListValidationBean
    OnAttribute="TitTipoPunteggio"
    OperandType="SQL"
    Inverse="true"
    ListValue="select tit_tipo_punteggio from va_tipo_punteggio where id_tipo_punteggio &#60;&#62; %IdTipoPunteggio%" >
    </ListValidationBean>
    Our problems are:
    1) The ID taken from a DB Sequence are increased by 2 (this doesn't occur using test on application module), and we suppose that it happens because row isn't
    found using the correct KEY property.
    2) When the validation's rule is triggered, row data aren't reloaded
    UIX code for apply event is:
    <event name="saveEvent" >
         <bc4j:findRootAppModule name="TipoPunteggioViewAppModule" >
              <bc4j:findViewObject name="TipoPunteggioView" >
                   <bc4j:findRow name="newRow">
                        <bc4j:setPageProperty name="key" >
                             <bc4j:stringKey />
                        </bc4j:setPageProperty>
                        <bc4j:setAttribute name="IdTipoPunteggio" />
                        <bc4j:setAttribute name="TitTipoPunteggio" />
                        <bc4j:setAttribute name="FlgObsoleto" />
                        <bc4j:insertRow/>
                        <bc4j:commit/>
                        <bc4j:executeQuery/>
                        <ctrl:go redirect="true" name="Anagrafiche_TipiPunteggio"/>
                   </bc4j:findRow>
              </bc4j:findViewObject>
         </bc4j:findRootAppModule>
    </event>
    However we have doubts on the code flow because we suppose the following istruction are missing before the findRow tag:
    <bc4j:setPageProperty name="keyTipoPunteggio" >
         <bc4j:parameter name="keyTipoPunteggio"/>
    </bc4j:setPageProperty>
    otherwise what is the reason of the keyStamp tag declared on the region?
    Moreover we don't understand the purpose of these instructions:
    <bc4j:setPageProperty name="keyTipoPunteggio" >
         <bc4j:stringKey />
    </bc4j:setPageProperty>
    because when validation on the row occurs, data of the rejected row are not reloaded.
    Perhaps would be useful an HowTo or a detailed explanation of interaction between registryDefs and event handler tags.
    TIA

    Our problems are:
    1) The ID taken from a DB Sequence are increased by 2 (this doesn't occur using test on application module), and we suppose that it happens because row isn't found using the correct KEY property.This is correct.
    2) When the validation's rule is triggered, row data aren't reloaded
    UIX code for apply event is: <snip>
    Replace it with this:
    <event name="saveEvent" >
    <bc4j:findRootAppModule name="TipoPunteggioViewAppModule" >
    <bc4j:findViewObject name="TipoPunteggioView" >
    <bc4j:setPageProperty name="key" >
    <bc4j:parameter name="key" />
    </bc4j:setPageProperty>
    <bc4j:findRow name="newRow">
    <bc4j:setAttribute name="IdTipoPunteggio" />
    <bc4j:setAttribute name="TitTipoPunteggio" />
    <bc4j:setAttribute name="FlgObsoleto" />
    <bc4j:insertRow/>
    <bc4j:setPageProperty name="key" >
    <bc4j:stringKey />
    </bc4j:setPageProperty>
    <bc4j:commit/>
    <bc4j:executeQuery/>
    <ctrl:go redirect="true" name="Anagrafiche_TipiPunteggio"/>
    </bc4j:findRow>
    </bc4j:findViewObject>
    </bc4j:findRootAppModule>
    </event>
    The main issue is that the string representation of the key changes when the row is inserted into the view object. It is a "short" key before insert and a "long" key after insert. Also, "short" keys cannot be found by ViewObject APIs to locate rows when the key is still "short".
    Here is the flow:
    1. Create page is rendered, auto-creating a new row with "short" key.
    2. In apply event handler, we must set the page property based on the submitted key
    to find the same row. Unfortunately, the "short" key does not find the old row, so
    we end up creating a new one for this request (incrementing the sequence).
    3. We may get as far as inserting the new row, upgrading to a "long" key.
    4. So we update the page property after a successful insert to the new "long" key.
    5. We rerender the page and use the page property to find the row, most likely the "long" key.
    [Note: if an exception occurred during set attribute, before insert row, the key will still
              be "short"]
    6. Once we get as far as attempting insertRow, the key will become "long" and locatable by
    ViewObject APIs.
    You don't encounter this problem in the tester because it can keep an in-memory handle to the row it
    is trying to insert for the duration of the insert attempt.
    The web-based UI relies on key-based references instead, which have the issue outlined above.
    We will follow up on this to see if "short" keys can be located by ViewObject APIs in future, allowing
    the same reference to be found across requests.
    Regards,
    John Fallows.

  • How can I set a value in a field before create when a New button is clicked

    Hi,
    I am using
    JDeveloper 10.1.3.1.0.3984 and
    JHeadstart 10.1.3.1 release 10.1.3.1.26
    I have one group and there is a detail group under that group.
    From main group to detail group there are 3 field relating those groups.
    field1
    field2
    fieldSEQ (auto-generated by database trigger)
    These 3 fields are PK.
    In the detail group, there is a New button. So, when the New button is clicked, it tries to create the record with those 3 fields value as those are coming from main group. As a result it's giving the duplicate error as that record already exists in the table.
    But I don't want to create the record with that SEQ as that will be created in the trigger.
    How can I set the SEQ temporarily any no. (-1) before create when the New button is clicked?
    Can anybody help?
    Thanks
    Syed Jabbar
    University of Windsor
    Windsor, ON, Canada

    Hello Syad,
    What I would suggest is setting the sequence number at the creation of the entity object (so in the create() method) by using the database sequence. This way it will always be unique.
    So something like:
    protected void create(AttributeList AttributeList) {
    super.create(AttributeList);
    SequenceImpl sequence =
    new SequenceImpl("KCP_SEQ", getDBTransaction());
    setFieldSeq( sequence.getSequenceNumber());
    If this still does not solve it: please go to the ADF Forum since this problem is an ADF problem, not a JHeadstart problem.
    Regards,
    Evert-Jan de Bruin
    JHeadstart Team.

Maybe you are looking for

  • Master on a View and Detail on a Table

    I have a master form and a detail tabular form attached to it - together, on the same page. Form is based on a view and the tab form is based on a table. Whenever an update needs to be done, then on the tabular form - detail record. If I try to creat

  • Windows 8 Driver Informatio​n for LaserJet, ScanJet, and other supported printers.

    To help customers successfully use their products with Windows 8, HP has identified recommended drivers per product. Please visit the following support documents for more information: HP LaserJet – Printers, MFPs, and All-in-Ones supported in Windows

  • Album shuffle has stopped working

    My 2nd gen nano has stopped shuffling albums. It used to do that just fine but then stopped for no apparent reason. I have reset the iPod, cleared and restored it all to no avail. Repeat is not on. It won't shuffle songs either. It is otherwise compl

  • 845PE MAX 2 and RAM

    Hi I need some help, just got a 845PE MAX2 board , while partitioning and installing my OS i noticed some unstabilitys, the PC kept turning it self off. Now i cant even boot it up, dies 1 sec after i turn it on. My system : Intel p4 2.4 asus geforce

  • Need help with db select

    As usual I have been stuck for a while on what is probably a very simple solution so perhaps someone can help me, thanks. I have a portfolio page to which I post a url to filter the portfolio type (0, 1 or 2) and display the results. It works ok exce