This discussion is archived
6 Replies Latest reply: Nov 12, 2012 7:48 AM by Sudipto Desmukh RSS

af:selectOneChoice value

Nina Newbie
Currently Being Moderated
Hi,
I have 2 af:selectOneChoice connected to tables in db containing a code num and code value.
The second table is secondary table connected to the first one.
What I need is when I select a value in the first selectOneChoice, the value will be sent in executeWithParams to
the second table to show the values.
The only problem I have, that instead the the code num will be sent as a parameter, what sent is its position in the list {0,1,2..}.

That is what I do in page def:
part of executewithparams:
<NamedData NDName="codeNumBV" NDType="oracle.jbo.domain.Number"
NDValue="#{bindings.Value91.inputValue}"/>


definition of Value91:<list IterBinding="Ipt98031ViewIterator" id="Value91" DTSupportsMRU="true"
StaticList="false" ListIter="CodeTableDataView8660Iterator">
<AttrNames>
<Item Value="Value9"/>
</AttrNames>
<ListAttrNames>
<Item Value="CodeNum"/>
</ListAttrNames>
<ListDisplayAttrNames>
<Item Value="CodeName"/>
</ListDisplayAttrNames>
</list>

What do I need to change so the value and not the position will be sent?

Thank you,
Nina
  • 1. Re: af:selectOneChoice value
    Sudipto Desmukh Expert
    Currently Being Moderated
    this is a very commonly asked question on forums .
    Anyways , this would help you get the value - https://blogs.oracle.com/shay/entry/getting_the_value_from_a_selec
  • 2. Re: af:selectOneChoice value
    Nina Newbie
    Currently Being Moderated
    Thank you, but I am looking for a solution using only page def and jsps, without coding in managed bean. Is it possible?

    Nina
  • 3. Re: af:selectOneChoice value
    Sudipto Desmukh Expert
    Currently Being Moderated
    Yes that is possible too -
    You would need to use a af:ForEach inside the selectOneChoice as mentioned in the end of this blog -
    http://myadfnotebook.blogspot.in/2010/09/getting-string-value-or-item-code-of.html

    You can directly retrieve its value then.
  • 4. Re: af:selectOneChoice value
    Nina Newbie
    Currently Being Moderated
    Thank you again,
    Itried to look at the example, but my case is more complex.
    I have a mian view with a numeric attribute Value9 and I want to show a selectOneChoice with all the values available from another table which contains code num and descriptions.

    My main view is: Ipt98031ViewIterator
    and CodeTableDataView8660Iterator is the table with the codes list

    <list IterBinding="Ipt98031ViewIterator" id="Value91" DTSupportsMRU="true"
    StaticList="false" ListIter="CodeTableDataView8660Iterator">
    <AttrNames>
    <Item Value="Value9"/>
    </AttrNames>
    <ListAttrNames>
    <Item Value="CodeNum"/>
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="CodeName"/>
    </ListDisplayAttrNames>
    </list>

    I still don't understand what do I need to write in the for each expression, from the lov example:
    <af:forEach items="#{bindings.DepartmentLOV.iteratorBinding.allRowsInRange}"
    var="row">
    <f:selectItem id="myItem5" itemLabel="#{row.departmentName}"
    itemValue="#{row.departmentId}"/>
    </af:forEach>


    Thank you,
    Nina
  • 5. Re: af:selectOneChoice value
    Nina Newbie
    Currently Being Moderated
    Thank you,
    I managed to send the real value and not the index to the secondary table.

    But now I have a problem to display the values when they are selected from db.
    The list contains all the data, but the values that is selected from db is not displayed.

    <af:selectOneChoice value="#{bindings.*Value91*.inputValue}"
    required="#{bindings.Value91.hints.mandatory}"
    contentStyle="width:143px"
    disabled="#{vacationRequest.manegerApproveDeclineRequest}"
    shortDesc="#{bindings.Value91.hints.tooltip}"
    showRequired="true"
    id="soc6" autoSubmit="true" >
    <af:forEach items="#{bindings.CodeTableDataView8660Tree.rangeSet}"
    var="item">
    <af:selectItem id="si111" value="#{item.CodeNum.value}"
    label="#{item.CodeName}"/>
    </af:forEach>
    </af:selectOneChoice>


    page def:

    <list IterBinding="Ipt98031ViewIterator" id="Value91" DTSupportsMRU="true"
    StaticList="false" ListIter="CodeTableDataView8660Iterator">
    <AttrNames>
    <Item Value="Value9"/>
    </AttrNames>
    <ListAttrNames>
    <Item Value="CodeNum"/>
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="CodeName"/>
    </ListDisplayAttrNames>
    </list>

    <tree IterBinding="CodeTableDataView8660Iterator"
    id="CodeTableDataView8660Tree">
    <nodeDefinition DefName="com.malam.infra.dataModel.queries.CodeTableDataView"
    Name="CodeTableDataView86600">
    <AttrNames>
    <Item Value="CodeNum"/>
    <Item Value="CodeName"/>
    </AttrNames>
    </nodeDefinition>
    </tree>

    What is missing in my code?
    Thank you,
    Nina
  • 6. Re: af:selectOneChoice value
    Sudipto Desmukh Expert
    Currently Being Moderated
    I beleive you should be using Value9 instead of Value91(since this refers to an iterator in your pageDef)

Legend

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