This discussion is archived
14 Replies Latest reply: Apr 14, 2013 6:26 PM by Jeet_A RSS

How to set default value for a VO query bind variable in a jspx page?

BAO.SZ Newbie
Currently Being Moderated
Hi,
I'm working in Jdev 11.1.2.3
I have two VO in a jspx page (VO1,VO2), and VO2 has a query bind variable (p_name) displayed in query panel for the formlayout created from VO2.
also there is a field in VO1(remarks).
Now i need to implement function as:
--when select a record in VO1, the value in VO1(remarks) will be set as the query bind variable for VO2, and get the query results( where p_name=vo1.remarks||'%').
--it's something like a master-detail relation,but i don't implement this way. since the relationship need to be VO2.name like VO1.remarks||'%'.
it's a question for:
How to set default value for a VO query bind variable and got executed in a jspx page?

Anyone can help me?
Thanks!
bao
  • 1. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi Bao,

    If VO1 has addeed as View Accessor in VO2 , inside VO2 you can refer VO1 attribute using Grrovy Expression in Bind Variable as

    adf.object.VO1.remarks+

    + for Concatenation

    Thanks,
    Jit
  • 2. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi Bao,

    If VO1 has addeed as View Accessor in VO2 , inside VO2 you can refer VO1 attribute using Grrovy Expression in Bind Variable as

    adf.object.VO1.remarks+

    + for Concatenation

    Thanks,
    Jit
  • 3. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    Hi,Jit
    Thank you for your replies. i believe "add a view accessor" is the right direction for solving the problem.
    However, since i only got to know the concept of " view accessor" in jdev yesterday, i still have some difficulties when i make the try:

    --the VO1, VO2 in my example are based on the same EO; VO1 readonly table for browse navigation, VO2 adf-form for edit;
    --after VO1 has added as View Accessor in VO2, and insider VO2 refer to "adf.object.VO1.remark"  as the Value ( Value Type: Expression) for bind variable "p_name".

    when it runs, give out errors, the page cannot render:
    --Variable VO1 not recognized.

    Can you give me furthur help?
    Thank you very much!
    bao
  • 4. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    After i come up with the problem of "Variable VO1 not recognized", i delete what i have done and try to go back to the original state(delete the view accessor, bind variable etc), but a new problem come up:
    --the VO2 adf-form shows ok. not sync with VO1.
    --the VO1 readonly table shows blank. (after some clicks to refresh the page it can show records some time, but most of the time only show "no data").

    How to fix it? and
    Many thanks!
    bao
  • 5. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi,

    VO1 not recognised could be because VOImpl not created. Please check if you have VOImpl class created for VO1.

    Also to check if adf.object.VO1.remark will work or not , you can try calling it in VO2's RowImpl class.

    Can you show me sample EO.xml and VO1.xml and VO2.xml , i can try from my end.

    Thanks,
    Jit
  • 6. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    Hi,Jit!
    my demo's VO1,VO2 XML files are:
    VO1:
    (TAMainVO.XML):

    <?xml version="1.0" encoding="GBK" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
    xmlns="http://xmlns.oracle.com/bc4j"
    Name="TAmainVO"
    Version="11.1.2.62.76"
    BindingStyle="OracleName"
    CustomQuery="true"
    PageIterMode="Full"
    UseGlueCode="false"
    RowClass="project1.TAmainVORowImpl"
    ComponentClass="project1.TAmainVOImpl"
    DefClass="project1.TAmainVODefImpl"
    SdoGen="true"
    SdoName="TAmainVOSDO"
    SdoNameSpace="/project1/common/">
    <DesignTime>
    <Attr Name="_isExpertMode" Value="true"/>
    <Attr Name="_codeGenFlag2" Value="Access|Def|Coll|VarAccess"/>
    <Attr Name="_isCodegen" Value="true"/>
    </DesignTime>
    <SQLQuery><![CDATA[SELECT ID,
           NAME,
           REMARK,
           STATUS
    FROM TA TAMain
    WHERE TAMain.status='1']]></SQLQuery>
    <EntityUsage
    Name="TAMain"
    Entity="project1.TA"/>
    <ViewAttribute
    Name="Id"
    PrecisionRule="true"
    EntityAttrName="Id"
    EntityUsage="TA"
    AliasName="ID"/>
    <ViewAttribute
    Name="Name"
    PrecisionRule="true"
    EntityAttrName="Name"
    EntityUsage="TA"
    AliasName="NAME"/>
    <ViewAttribute
    Name="Remark"
    PrecisionRule="true"
    EntityAttrName="Remark"
    EntityUsage="TA"
    AliasName="REMARK"/>
    <ViewAttribute
    Name="Status"
    PrecisionRule="true"
    EntityAttrName="Status"
    EntityUsage="TA"
    AliasName="STATUS"/>
    </ViewObject>

    ===================
    VO2:
    TAMainEVO.xml
    <?xml version="1.0" encoding="GBK" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
    xmlns="http://xmlns.oracle.com/bc4j"
    Name="TAmainEVO"
    Version="11.1.2.62.76"
    BindingStyle="OracleName"
    CustomQuery="true"
    PageIterMode="Full"
    UseGlueCode="false"
    RowClass="project1.TAmainEVORowImpl"
    ComponentClass="project1.TAmainEVOImpl"
    DefClass="project1.TAmainEVODefImpl">
    <DesignTime>
    <Attr Name="_isExpertMode" Value="true"/>
    <Attr Name="_codeGenFlag2" Value="Access|Def|Coll|VarAccess"/>
    <Attr Name="_isCodegen" Value="true"/>
    </DesignTime>
    <Variable
    Name="p_id"
    Kind="viewcriteria"
    Type="java.lang.String">
    <TransientExpression><![CDATA[adf.object.TAMainVO.id]]></TransientExpression>
    </Variable>

    <ViewAccessor
    Name="TAmainVO1"
    ViewObjectName="project1.TAmainVO"
    RowLevelBinds="true"/>
    <SQLQuery><![CDATA[SELECT ID,
           NO,
           NAME,
           REMARK,
           STATUS
    FROM TA
    where status='1']]></SQLQuery>
    <EntityUsage
    Name="TA"
    Entity="project1.TA"/>
    <ViewAttribute
    Name="Id"
    PrecisionRule="true"
    EntityAttrName="Id"
    EntityUsage="TA"
    AliasName="ID"/>
    <ViewAttribute
    Name="Name"
    PrecisionRule="true"
    EntityAttrName="Name"
    EntityUsage="TA"
    AliasName="NAME"/>
    <ViewAttribute
    Name="Remark"
    PrecisionRule="true"
    EntityAttrName="Remark"
    EntityUsage="TA"
    AliasName="REMARK"/>
    <ViewAttribute
    Name="Status"
    PrecisionRule="true"
    EntityAttrName="Status"
    EntityUsage="TA"
    AliasName="STATUS"/>
    <ViewCriteria
    Name="TAmainEVOCriteria"
    ViewObjectName="project1.TAmainEVO"
    Conjunction="AND">
    <Properties>
    <CustomProperties>
    <Property
    Name="displayOperators"
    Value="InAdvancedMode"/>
    <Property
    Name="autoExecute"
    Value="false"/>
    <Property
    Name="allowConjunctionOverride"
    Value="true"/>
    <Property
    Name="showInList"
    Value="true"/>
    <Property
    Name="mode"
    Value="Basic"/>
    </CustomProperties>
    </Properties>
    <ViewCriteriaRow
    Name="TAmainEVOCriteria_row_0"
    UpperColumns="1">
    <ViewCriteriaItem
    Name="Id"
    ViewAttribute="Id"
    Operator="="
    Conjunction="AND"

    IsBindVarValue="true"
    Required="Optional"/>
    </ViewCriteriaRow>
    </ViewCriteria>
    </ViewObject>

    =======
    The above code cannot run as expected.

    Thank you for your kindly suggestions!
    bao
  • 7. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi Bao,

    Is your requirement ,
    VO1 based on table TA is readonly VO. And VO2 which is again based on TA is editable.
    When you select row in VO1, it should show same row in VO2 (Passing Name and Remarks as Parameters) ?

    Thanks,
    Jit
  • 8. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    Hi,Jit:
    My requirements is :
    1.VO1 based on table TA is readonly VO. And VO2 which is again based on TA is editable.
    2.When select row in VO1, it should show some rows in VO2( Remarks as Parameters).
    and since it does not work, so i try to: same row in VO2 (Passing Name as Parameters).

    But now neither of them works.
    Thank you very much.
    BAO

    Edited by: user6715237 on 2013-4-12 上午9:37
  • 9. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    Hi,Jit
    I have a more realworld requirement similar to the above requirement is:
    Manage bank transactions for clients. and give invoices to clients according to their transaction records. One invoice can contain one or many transactions records. and one transaction records can be split into many invoices.

    1.there are there table: Bank_Transaction(id,remark,amount), Invoice(id,name,amount), and m-m cross table Transaction_invoice_rel(id,in_id,bt_id,remark,amount).
    2.every Invoice record may contain/relate 1 or many bank_transaction records, and one bank_transaction record may relate to 1 or many records in invoice table.
    3.when create invoice record, select one or many records from bank_transaction, and value of amount from bank_transaction table will be set as defalt value for amount in transaction_invoice_rel table, and can decrease this default value.
    and invoice.amount will be the sum of transaction_invoice_rel.amount.
    4.if one record of bank_transaction.amount > sum of correspond transaction_invoice_rel.amount. then this bank_transaction record can relate to a new invoice record.

    and I'm going to design in jdev-adf:
    1.three EO based VOes: VO1 for Bank_transaction, VO2 for Invoice, VO3 for transaction_invoice_rel;
    2.two veiw link: VL1 for VO1 to VO3 (1-m), VL2 for VO2 to VO3 (1-m);
    3.first press CreateInsert for VO2 to create a new record for VO2;
    4.then in VO1 table there are checkbox (convert from CreateInsert button for VO3), when checked/unchecked, a record will be created/deleted for VO3, and VO1.amount will be set as default value for VO3.amount. VO1.remark will be set as defalt value for VO3.remark.
    5.and sum of VO3.amount will be maped to VO2.amount. Concatenation of VO3.remark string will be maped to VO2.name.

    the above 4-5 step will need to set default value for VOi think that is similar with this thread's topic.
    but i have not succeed in it yet.
    Is this a right way?--It's better with no java/JS coding.

    thanks.
    bao
  • 10. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi Bao,

    Let me know if I understand correct
    3)First you would be entering Invoices. (Invoice.Id sequence Generated).
    Programmatically you would create another row in transaction_invoice_rel. (Same Invoice.Id as transaction_invoice_rel.in_id and transaction_invoice_rel.id wil be sequentially generated).

    4)You will create Transaction in (Bank_Transaction.id sequentially generated) and apply invoice from Invoice Table, and transaction_invoice_rel In_id and amount should be updated ?

    I assume Invoices are entered Independently and later applied to transaction as in step4 ?
    If so then it would be 1 Transaction - Multiple Invoices scenario.

    How will you enter 1 Invoice - Multiple Transactions ?


    Thanks,
    Jit
  • 11. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    Hi,Jit,
    It's so great to receive your replies, you are so kind and warmhearted. I really appreciate you!

    Let me make clear for the requirements:
    1.at the beginning we have VO1(Bank_transaction) records which cannot be modified. and no VO2(Invoice) or the VO3(cross table) records;
    2.so we begin to create VO2(Invoice) record (invoice.id sequence generated,create_date for the invoice is filled),but the amount of invoice was null, and there is no VO3(Transaction_invoice_rel) records yet.
    3.and begin to select information(amount,remarks etc) from VO1(Bank_transaction) records.
    --one or many VO1(Bank_transaction) records can be selected to be the source for one VO2(Invoice) records,
    -- the selections will be added to VO3(Transaction_invoice_rel) which can be modified itself. and now: VO3.id is generated and VO3.in_id =VO2.id, VO3.bt_id= VO1.id;
    VO3.amount can be modified to a number less than VO1.amountin this case the VO1 record can be used(relate to a new VO2 record) again next time.
    4.and the VO2(invoice.amount) is the sum of the selected records (sum of transaction_invoice_rel.amount).
    5.after selection and neccessary modification for the VO3, we get a full record for the VO2(invoice).

    Create a VO2(invoice ) and make some(0-m) selection from VO1(Bank_transaction) is in one transaction:
    --and can make 0 selection from VO1, in this case just create a special (half-completed) invoice record, but the transaction completed and is ok.
    --some time late can find(not create a new one) the special invoice record, and make selection again to finish the whole create Invoice use case.

    Thanks
    bao

    Edited by: user6715237 on 2013-4-13 下午9:35
  • 12. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    assume Invoices are entered Independently and later applied to transaction as in step4 ?
    If so then it would be 1 Transaction - Multiple Invoices scenario.
    --By selecting 1 record from Bank_Transaction, and only use "part of it(modify the amount to a number less than the original)",
    and next time this same Bank_transaction record can be selected as source selection for a new Invoice record(can use the residue amount).

    How will you enter 1 Invoice - Multiple Transactions ?
    --BY creating or selecting 1 Invoice record and then select Multiple Bank_Transactions records.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  • 13. Re: How to set default value for a VO query bind variable in a jspx page?
    BAO.SZ Newbie
    Currently Being Moderated
    This thread is helpful, i'm trying now:
    View Object bind variables:
    View Object bind variables
  • 14. Re: How to set default value for a VO query bind variable in a jspx page?
    Jeet_A Journeyer
    Currently Being Moderated
    Hi Bao,


    I think you can create Bank Transaction as independent screen for VO1(Bank_transaction) records.
    Another screen for Invoices with VO2 where you can add Multi Choice List.
    After selecting single or Multiple Transaction on Value CHange Listener you can programmatically insert/update records in VO3(cross table).

    Interesting requirement though.

    Thanks,
    Jit

Legend

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