Fetch Selected LOV value and display corresponding data in other field












1














Table:Item



Columns:



  ItemNumber,
Description


Transient Attribute1:
Items



LOV created on Items which displays Item Number



Transient Attribute2:



 ItemsDescription-This should display Description of above item selected.Added following code on Attribute 2:


if(ItemNumber!=null)
{ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber);
return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description");
}
else
{
return null; }


Need to display description on Attribute2 column










share|improve this question




















  • 1




    Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
    – rahul
    Nov 16 at 5:56












  • Items attribute is also Transient variable?
    – Shaili
    Nov 16 at 6:17






  • 1




    Yes.Items is also Transient
    – rahul
    Nov 16 at 6:25






  • 1




    Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
    – rahul
    Nov 16 at 6:31










  • What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
    – Shaili
    Nov 16 at 6:46


















1














Table:Item



Columns:



  ItemNumber,
Description


Transient Attribute1:
Items



LOV created on Items which displays Item Number



Transient Attribute2:



 ItemsDescription-This should display Description of above item selected.Added following code on Attribute 2:


if(ItemNumber!=null)
{ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber);
return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description");
}
else
{
return null; }


Need to display description on Attribute2 column










share|improve this question




















  • 1




    Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
    – rahul
    Nov 16 at 5:56












  • Items attribute is also Transient variable?
    – Shaili
    Nov 16 at 6:17






  • 1




    Yes.Items is also Transient
    – rahul
    Nov 16 at 6:25






  • 1




    Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
    – rahul
    Nov 16 at 6:31










  • What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
    – Shaili
    Nov 16 at 6:46
















1












1








1







Table:Item



Columns:



  ItemNumber,
Description


Transient Attribute1:
Items



LOV created on Items which displays Item Number



Transient Attribute2:



 ItemsDescription-This should display Description of above item selected.Added following code on Attribute 2:


if(ItemNumber!=null)
{ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber);
return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description");
}
else
{
return null; }


Need to display description on Attribute2 column










share|improve this question















Table:Item



Columns:



  ItemNumber,
Description


Transient Attribute1:
Items



LOV created on Items which displays Item Number



Transient Attribute2:



 ItemsDescription-This should display Description of above item selected.Added following code on Attribute 2:


if(ItemNumber!=null)
{ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber);
return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description");
}
else
{
return null; }


Need to display description on Attribute2 column







java oracle-adf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 at 8:12









Shaili

618825




618825










asked Nov 16 at 5:46









rahul

397




397








  • 1




    Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
    – rahul
    Nov 16 at 5:56












  • Items attribute is also Transient variable?
    – Shaili
    Nov 16 at 6:17






  • 1




    Yes.Items is also Transient
    – rahul
    Nov 16 at 6:25






  • 1




    Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
    – rahul
    Nov 16 at 6:31










  • What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
    – Shaili
    Nov 16 at 6:46
















  • 1




    Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
    – rahul
    Nov 16 at 5:56












  • Items attribute is also Transient variable?
    – Shaili
    Nov 16 at 6:17






  • 1




    Yes.Items is also Transient
    – rahul
    Nov 16 at 6:25






  • 1




    Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
    – rahul
    Nov 16 at 6:31










  • What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
    – Shaili
    Nov 16 at 6:46










1




1




Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
– rahul
Nov 16 at 5:56






Yes.I tried following code to fetch ItemNumber: if(ItemNumber!=null){ oracle.jbo.Key keyVal=new oracle.jbo.Key(ItemNumber); return ItemVO1.findByKey(keyVal,1)[0].getAttribute("Description"); } else{ return null; }
– rahul
Nov 16 at 5:56














Items attribute is also Transient variable?
– Shaili
Nov 16 at 6:17




Items attribute is also Transient variable?
– Shaili
Nov 16 at 6:17




1




1




Yes.Items is also Transient
– rahul
Nov 16 at 6:25




Yes.Items is also Transient
– rahul
Nov 16 at 6:25




1




1




Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
– rahul
Nov 16 at 6:31




Yes.Items is also Transient.To be specific Items has an LOV with View Attribute:Items List Attribute:ItemNumber UIHints displays:ItemNumber..Applied above code on Transient Attribute2:ItemsDescription to get description based on ItemNumber selected by user
– rahul
Nov 16 at 6:31












What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
– Shaili
Nov 16 at 6:46






What exactly is happening in your case? Are you getting LOV in transient variable? If yes so on selecting , desc is not appeared? Or LOV itself is not populated?
– Shaili
Nov 16 at 6:46














1 Answer
1






active

oldest

votes


















1














What I understood that your requirement is :



You need to show item description based on item Number selection in LOV in ADF.



Item Description and Item Number both are Transient field.



I have used ADF 11g.



I do not have any item related table. So I used 2 VO for Emp table itself.



   - One is base EmpVO
- Second is LOV VO (empObjVO)


Table : Emp



    - emp_id
- emp_name
- item_emp_id ( Transient variable - LOV - based on emp_id)
- item_emp_desc (Output Transient variable - Output text - On selection of LOV)


empObjVO - contains



     - emp_id ( This column is list for item_emp_id)
- emp_name (This column will be description for selection of emp_id)


EmpVo



     - item_emp_id has LOV of empObjVO1 with List Attribute and UI display attribute both.
( As you told item number is displayed in LOV. consider emp_id as item_number here).

List type is choice list.


After all above configuration, Place item_emp_id and item_emp_desc in a jsff page as select one choice and output text respectively.



item_emp_id definition in page :



       <af:selectOneChoice value="#{bindings.item_emp_id.inputValue}"
label="#{bindings.item_emp_id.label}"
required="#{bindings.item_emp_id.hints.mandatory}"
shortDesc="#{bindings.item_emp_id.hints.tooltip}"
id="soc3" autoSubmit="true"
valueChangeListener="#{bean1.changeVal}">
<f:selectItems value="#{bindings.item_emp_id.items}" id="si3"/>
</af:selectOneChoice>


Make autosubmit=true for it.



Create ValueChangeEventListner and create a method in a bean to trigger on change of value in LOV.
item_emp_desc definition is :



    <af:outputText value="#{bindings.item_emp_desc.inputValue}" id="ot1"
partialTriggers="soc3"/>


Use partial trigger as soc3 because it is dependent on soc3.



public void changeVal(ValueChangeEvent vce) {
// Add event code here...
Integer selectedCode=null;
//As we get indexes not value of LOV so need to map selected index with value.

if (vce.getNewValue() != null) {
this.setvalueToExpression("#{bindings.item_emp_id.inputValue}",
vce.getNewValue()); //Updating Model Values
selectedCode =
Integer.parseInt(this.getValueFrmExpression("#{bindings.item_emp_id.attributeValue}").toString());

System.out.println("******** Selected Value in List***** " +
selectedCode);
System.out.println("*******Display Value in List ****" +
getValueFrmExpression("#{bindings.item_emp_id.selectedValue.attributeValues[1]}"));
}

String e_id=selectedCode.toString(); //It will contain selected item_emp_id
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcIteratorBindings =
bindings.findIteratorBinding("EmpView1Iterator"); // Base table Emp VO iterator
DCIteratorBinding dcIteratorBindings1 =
bindings.findIteratorBinding("empViewObj1Iterator"); // LOV table Emp Vo iterator
ViewObject vo = dcIteratorBindings.getViewObject();
ViewObject vo1 = dcIteratorBindings1.getViewObject();
Row r1 = vo.getCurrentRow(); // get current row of base table VO


vo1.setWhereClause("e_id = " + e_id); // set where clause to get the description from LOV in VO1
vo1.executeQuery(); //execute it.
if(vo1.hasNext())
{
Row r=vo1.next(); // Get the row from LOV VO

if(r!=null)
{
r1.setAttribute("item_emp_desc", r.getAttribute("EmpName")); //set it to item_emp_desc which is a transient variable for output.
}
}

}


public void setvalueToExpression(String el, Object val) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
exp.setValue(elContext, val);
}


public String getValueFrmExpression(String data) {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
String Message = null;
Object obj = valueExp.getValue(elContext);
if (obj != null) {
Message = obj.toString();
}
return Message;
}


For undestanding the index to value conversion I have taken reference from



 [http://www.awasthiashish.com/2014/05/getting-selected-value-not-index-display-value-of-select-one-choice-programmatically-in-adf.html][1]


It may help you.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332106%2ffetch-selected-lov-value-and-display-corresponding-data-in-other-field%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    What I understood that your requirement is :



    You need to show item description based on item Number selection in LOV in ADF.



    Item Description and Item Number both are Transient field.



    I have used ADF 11g.



    I do not have any item related table. So I used 2 VO for Emp table itself.



       - One is base EmpVO
    - Second is LOV VO (empObjVO)


    Table : Emp



        - emp_id
    - emp_name
    - item_emp_id ( Transient variable - LOV - based on emp_id)
    - item_emp_desc (Output Transient variable - Output text - On selection of LOV)


    empObjVO - contains



         - emp_id ( This column is list for item_emp_id)
    - emp_name (This column will be description for selection of emp_id)


    EmpVo



         - item_emp_id has LOV of empObjVO1 with List Attribute and UI display attribute both.
    ( As you told item number is displayed in LOV. consider emp_id as item_number here).

    List type is choice list.


    After all above configuration, Place item_emp_id and item_emp_desc in a jsff page as select one choice and output text respectively.



    item_emp_id definition in page :



           <af:selectOneChoice value="#{bindings.item_emp_id.inputValue}"
    label="#{bindings.item_emp_id.label}"
    required="#{bindings.item_emp_id.hints.mandatory}"
    shortDesc="#{bindings.item_emp_id.hints.tooltip}"
    id="soc3" autoSubmit="true"
    valueChangeListener="#{bean1.changeVal}">
    <f:selectItems value="#{bindings.item_emp_id.items}" id="si3"/>
    </af:selectOneChoice>


    Make autosubmit=true for it.



    Create ValueChangeEventListner and create a method in a bean to trigger on change of value in LOV.
    item_emp_desc definition is :



        <af:outputText value="#{bindings.item_emp_desc.inputValue}" id="ot1"
    partialTriggers="soc3"/>


    Use partial trigger as soc3 because it is dependent on soc3.



    public void changeVal(ValueChangeEvent vce) {
    // Add event code here...
    Integer selectedCode=null;
    //As we get indexes not value of LOV so need to map selected index with value.

    if (vce.getNewValue() != null) {
    this.setvalueToExpression("#{bindings.item_emp_id.inputValue}",
    vce.getNewValue()); //Updating Model Values
    selectedCode =
    Integer.parseInt(this.getValueFrmExpression("#{bindings.item_emp_id.attributeValue}").toString());

    System.out.println("******** Selected Value in List***** " +
    selectedCode);
    System.out.println("*******Display Value in List ****" +
    getValueFrmExpression("#{bindings.item_emp_id.selectedValue.attributeValues[1]}"));
    }

    String e_id=selectedCode.toString(); //It will contain selected item_emp_id
    DCBindingContainer bindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding dcIteratorBindings =
    bindings.findIteratorBinding("EmpView1Iterator"); // Base table Emp VO iterator
    DCIteratorBinding dcIteratorBindings1 =
    bindings.findIteratorBinding("empViewObj1Iterator"); // LOV table Emp Vo iterator
    ViewObject vo = dcIteratorBindings.getViewObject();
    ViewObject vo1 = dcIteratorBindings1.getViewObject();
    Row r1 = vo.getCurrentRow(); // get current row of base table VO


    vo1.setWhereClause("e_id = " + e_id); // set where clause to get the description from LOV in VO1
    vo1.executeQuery(); //execute it.
    if(vo1.hasNext())
    {
    Row r=vo1.next(); // Get the row from LOV VO

    if(r!=null)
    {
    r1.setAttribute("item_emp_desc", r.getAttribute("EmpName")); //set it to item_emp_desc which is a transient variable for output.
    }
    }

    }


    public void setvalueToExpression(String el, Object val) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ELContext elContext = facesContext.getELContext();
    ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
    ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
    exp.setValue(elContext, val);
    }


    public String getValueFrmExpression(String data) {
    FacesContext fc = FacesContext.getCurrentInstance();
    Application app = fc.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = fc.getELContext();
    ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
    String Message = null;
    Object obj = valueExp.getValue(elContext);
    if (obj != null) {
    Message = obj.toString();
    }
    return Message;
    }


    For undestanding the index to value conversion I have taken reference from



     [http://www.awasthiashish.com/2014/05/getting-selected-value-not-index-display-value-of-select-one-choice-programmatically-in-adf.html][1]


    It may help you.






    share|improve this answer


























      1














      What I understood that your requirement is :



      You need to show item description based on item Number selection in LOV in ADF.



      Item Description and Item Number both are Transient field.



      I have used ADF 11g.



      I do not have any item related table. So I used 2 VO for Emp table itself.



         - One is base EmpVO
      - Second is LOV VO (empObjVO)


      Table : Emp



          - emp_id
      - emp_name
      - item_emp_id ( Transient variable - LOV - based on emp_id)
      - item_emp_desc (Output Transient variable - Output text - On selection of LOV)


      empObjVO - contains



           - emp_id ( This column is list for item_emp_id)
      - emp_name (This column will be description for selection of emp_id)


      EmpVo



           - item_emp_id has LOV of empObjVO1 with List Attribute and UI display attribute both.
      ( As you told item number is displayed in LOV. consider emp_id as item_number here).

      List type is choice list.


      After all above configuration, Place item_emp_id and item_emp_desc in a jsff page as select one choice and output text respectively.



      item_emp_id definition in page :



             <af:selectOneChoice value="#{bindings.item_emp_id.inputValue}"
      label="#{bindings.item_emp_id.label}"
      required="#{bindings.item_emp_id.hints.mandatory}"
      shortDesc="#{bindings.item_emp_id.hints.tooltip}"
      id="soc3" autoSubmit="true"
      valueChangeListener="#{bean1.changeVal}">
      <f:selectItems value="#{bindings.item_emp_id.items}" id="si3"/>
      </af:selectOneChoice>


      Make autosubmit=true for it.



      Create ValueChangeEventListner and create a method in a bean to trigger on change of value in LOV.
      item_emp_desc definition is :



          <af:outputText value="#{bindings.item_emp_desc.inputValue}" id="ot1"
      partialTriggers="soc3"/>


      Use partial trigger as soc3 because it is dependent on soc3.



      public void changeVal(ValueChangeEvent vce) {
      // Add event code here...
      Integer selectedCode=null;
      //As we get indexes not value of LOV so need to map selected index with value.

      if (vce.getNewValue() != null) {
      this.setvalueToExpression("#{bindings.item_emp_id.inputValue}",
      vce.getNewValue()); //Updating Model Values
      selectedCode =
      Integer.parseInt(this.getValueFrmExpression("#{bindings.item_emp_id.attributeValue}").toString());

      System.out.println("******** Selected Value in List***** " +
      selectedCode);
      System.out.println("*******Display Value in List ****" +
      getValueFrmExpression("#{bindings.item_emp_id.selectedValue.attributeValues[1]}"));
      }

      String e_id=selectedCode.toString(); //It will contain selected item_emp_id
      DCBindingContainer bindings =
      (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
      DCIteratorBinding dcIteratorBindings =
      bindings.findIteratorBinding("EmpView1Iterator"); // Base table Emp VO iterator
      DCIteratorBinding dcIteratorBindings1 =
      bindings.findIteratorBinding("empViewObj1Iterator"); // LOV table Emp Vo iterator
      ViewObject vo = dcIteratorBindings.getViewObject();
      ViewObject vo1 = dcIteratorBindings1.getViewObject();
      Row r1 = vo.getCurrentRow(); // get current row of base table VO


      vo1.setWhereClause("e_id = " + e_id); // set where clause to get the description from LOV in VO1
      vo1.executeQuery(); //execute it.
      if(vo1.hasNext())
      {
      Row r=vo1.next(); // Get the row from LOV VO

      if(r!=null)
      {
      r1.setAttribute("item_emp_desc", r.getAttribute("EmpName")); //set it to item_emp_desc which is a transient variable for output.
      }
      }

      }


      public void setvalueToExpression(String el, Object val) {
      FacesContext facesContext = FacesContext.getCurrentInstance();
      ELContext elContext = facesContext.getELContext();
      ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
      ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
      exp.setValue(elContext, val);
      }


      public String getValueFrmExpression(String data) {
      FacesContext fc = FacesContext.getCurrentInstance();
      Application app = fc.getApplication();
      ExpressionFactory elFactory = app.getExpressionFactory();
      ELContext elContext = fc.getELContext();
      ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
      String Message = null;
      Object obj = valueExp.getValue(elContext);
      if (obj != null) {
      Message = obj.toString();
      }
      return Message;
      }


      For undestanding the index to value conversion I have taken reference from



       [http://www.awasthiashish.com/2014/05/getting-selected-value-not-index-display-value-of-select-one-choice-programmatically-in-adf.html][1]


      It may help you.






      share|improve this answer
























        1












        1








        1






        What I understood that your requirement is :



        You need to show item description based on item Number selection in LOV in ADF.



        Item Description and Item Number both are Transient field.



        I have used ADF 11g.



        I do not have any item related table. So I used 2 VO for Emp table itself.



           - One is base EmpVO
        - Second is LOV VO (empObjVO)


        Table : Emp



            - emp_id
        - emp_name
        - item_emp_id ( Transient variable - LOV - based on emp_id)
        - item_emp_desc (Output Transient variable - Output text - On selection of LOV)


        empObjVO - contains



             - emp_id ( This column is list for item_emp_id)
        - emp_name (This column will be description for selection of emp_id)


        EmpVo



             - item_emp_id has LOV of empObjVO1 with List Attribute and UI display attribute both.
        ( As you told item number is displayed in LOV. consider emp_id as item_number here).

        List type is choice list.


        After all above configuration, Place item_emp_id and item_emp_desc in a jsff page as select one choice and output text respectively.



        item_emp_id definition in page :



               <af:selectOneChoice value="#{bindings.item_emp_id.inputValue}"
        label="#{bindings.item_emp_id.label}"
        required="#{bindings.item_emp_id.hints.mandatory}"
        shortDesc="#{bindings.item_emp_id.hints.tooltip}"
        id="soc3" autoSubmit="true"
        valueChangeListener="#{bean1.changeVal}">
        <f:selectItems value="#{bindings.item_emp_id.items}" id="si3"/>
        </af:selectOneChoice>


        Make autosubmit=true for it.



        Create ValueChangeEventListner and create a method in a bean to trigger on change of value in LOV.
        item_emp_desc definition is :



            <af:outputText value="#{bindings.item_emp_desc.inputValue}" id="ot1"
        partialTriggers="soc3"/>


        Use partial trigger as soc3 because it is dependent on soc3.



        public void changeVal(ValueChangeEvent vce) {
        // Add event code here...
        Integer selectedCode=null;
        //As we get indexes not value of LOV so need to map selected index with value.

        if (vce.getNewValue() != null) {
        this.setvalueToExpression("#{bindings.item_emp_id.inputValue}",
        vce.getNewValue()); //Updating Model Values
        selectedCode =
        Integer.parseInt(this.getValueFrmExpression("#{bindings.item_emp_id.attributeValue}").toString());

        System.out.println("******** Selected Value in List***** " +
        selectedCode);
        System.out.println("*******Display Value in List ****" +
        getValueFrmExpression("#{bindings.item_emp_id.selectedValue.attributeValues[1]}"));
        }

        String e_id=selectedCode.toString(); //It will contain selected item_emp_id
        DCBindingContainer bindings =
        (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding dcIteratorBindings =
        bindings.findIteratorBinding("EmpView1Iterator"); // Base table Emp VO iterator
        DCIteratorBinding dcIteratorBindings1 =
        bindings.findIteratorBinding("empViewObj1Iterator"); // LOV table Emp Vo iterator
        ViewObject vo = dcIteratorBindings.getViewObject();
        ViewObject vo1 = dcIteratorBindings1.getViewObject();
        Row r1 = vo.getCurrentRow(); // get current row of base table VO


        vo1.setWhereClause("e_id = " + e_id); // set where clause to get the description from LOV in VO1
        vo1.executeQuery(); //execute it.
        if(vo1.hasNext())
        {
        Row r=vo1.next(); // Get the row from LOV VO

        if(r!=null)
        {
        r1.setAttribute("item_emp_desc", r.getAttribute("EmpName")); //set it to item_emp_desc which is a transient variable for output.
        }
        }

        }


        public void setvalueToExpression(String el, Object val) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
        exp.setValue(elContext, val);
        }


        public String getValueFrmExpression(String data) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
        String Message = null;
        Object obj = valueExp.getValue(elContext);
        if (obj != null) {
        Message = obj.toString();
        }
        return Message;
        }


        For undestanding the index to value conversion I have taken reference from



         [http://www.awasthiashish.com/2014/05/getting-selected-value-not-index-display-value-of-select-one-choice-programmatically-in-adf.html][1]


        It may help you.






        share|improve this answer












        What I understood that your requirement is :



        You need to show item description based on item Number selection in LOV in ADF.



        Item Description and Item Number both are Transient field.



        I have used ADF 11g.



        I do not have any item related table. So I used 2 VO for Emp table itself.



           - One is base EmpVO
        - Second is LOV VO (empObjVO)


        Table : Emp



            - emp_id
        - emp_name
        - item_emp_id ( Transient variable - LOV - based on emp_id)
        - item_emp_desc (Output Transient variable - Output text - On selection of LOV)


        empObjVO - contains



             - emp_id ( This column is list for item_emp_id)
        - emp_name (This column will be description for selection of emp_id)


        EmpVo



             - item_emp_id has LOV of empObjVO1 with List Attribute and UI display attribute both.
        ( As you told item number is displayed in LOV. consider emp_id as item_number here).

        List type is choice list.


        After all above configuration, Place item_emp_id and item_emp_desc in a jsff page as select one choice and output text respectively.



        item_emp_id definition in page :



               <af:selectOneChoice value="#{bindings.item_emp_id.inputValue}"
        label="#{bindings.item_emp_id.label}"
        required="#{bindings.item_emp_id.hints.mandatory}"
        shortDesc="#{bindings.item_emp_id.hints.tooltip}"
        id="soc3" autoSubmit="true"
        valueChangeListener="#{bean1.changeVal}">
        <f:selectItems value="#{bindings.item_emp_id.items}" id="si3"/>
        </af:selectOneChoice>


        Make autosubmit=true for it.



        Create ValueChangeEventListner and create a method in a bean to trigger on change of value in LOV.
        item_emp_desc definition is :



            <af:outputText value="#{bindings.item_emp_desc.inputValue}" id="ot1"
        partialTriggers="soc3"/>


        Use partial trigger as soc3 because it is dependent on soc3.



        public void changeVal(ValueChangeEvent vce) {
        // Add event code here...
        Integer selectedCode=null;
        //As we get indexes not value of LOV so need to map selected index with value.

        if (vce.getNewValue() != null) {
        this.setvalueToExpression("#{bindings.item_emp_id.inputValue}",
        vce.getNewValue()); //Updating Model Values
        selectedCode =
        Integer.parseInt(this.getValueFrmExpression("#{bindings.item_emp_id.attributeValue}").toString());

        System.out.println("******** Selected Value in List***** " +
        selectedCode);
        System.out.println("*******Display Value in List ****" +
        getValueFrmExpression("#{bindings.item_emp_id.selectedValue.attributeValues[1]}"));
        }

        String e_id=selectedCode.toString(); //It will contain selected item_emp_id
        DCBindingContainer bindings =
        (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding dcIteratorBindings =
        bindings.findIteratorBinding("EmpView1Iterator"); // Base table Emp VO iterator
        DCIteratorBinding dcIteratorBindings1 =
        bindings.findIteratorBinding("empViewObj1Iterator"); // LOV table Emp Vo iterator
        ViewObject vo = dcIteratorBindings.getViewObject();
        ViewObject vo1 = dcIteratorBindings1.getViewObject();
        Row r1 = vo.getCurrentRow(); // get current row of base table VO


        vo1.setWhereClause("e_id = " + e_id); // set where clause to get the description from LOV in VO1
        vo1.executeQuery(); //execute it.
        if(vo1.hasNext())
        {
        Row r=vo1.next(); // Get the row from LOV VO

        if(r!=null)
        {
        r1.setAttribute("item_emp_desc", r.getAttribute("EmpName")); //set it to item_emp_desc which is a transient variable for output.
        }
        }

        }


        public void setvalueToExpression(String el, Object val) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
        exp.setValue(elContext, val);
        }


        public String getValueFrmExpression(String data) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
        String Message = null;
        Object obj = valueExp.getValue(elContext);
        if (obj != null) {
        Message = obj.toString();
        }
        return Message;
        }


        For undestanding the index to value conversion I have taken reference from



         [http://www.awasthiashish.com/2014/05/getting-selected-value-not-index-display-value-of-select-one-choice-programmatically-in-adf.html][1]


        It may help you.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 at 10:20









        Shaili

        618825




        618825






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332106%2ffetch-selected-lov-value-and-display-corresponding-data-in-other-field%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents