This discussion is archived
2 Replies Latest reply: Nov 16, 2012 11:27 AM by AlejandroProfet RSS

SelectOneChoice and Table

964423 Newbie
Currently Being Moderated
Hi Experts,

I have a requirement in which I have to use selectonechoice and on selecting some item in the selectonechoice I have to show the table which is associated with the selected item.

I am using jdev 11.1.1.6

Thanks,
Tarun
  • 1. Re: SelectOneChoice and Table
    user404 Pro
    Currently Being Moderated
    You could use a ViewCriteria and bind the selected value to it.
    Great example on how to do this at runtime:
    http://jobinesh.blogspot.be/2010/10/creating-view-criteria-having-bind.html
  • 2. Re: SelectOneChoice and Table
    AlejandroProfet Journeyer
    Currently Being Moderated
    Hi Tarun,

    If you have more than one table and want to choose one of them using a <af:selectOneChoice>, you can do something like this:
    <af:selectOneChoice label="Choose a table" id="soc1" value="#{viewScope.socValue}" autoSubmit="true">
      <f:selectItem itemValue="1" id="si1" itemLabel="Employees"/>
      <f:selectItem itemValue="2" id="si2" itemLabel="Departments"/>
    </af:selectOneChoice>
    <af:panelCollection partialTriggers="::soc1" id="pc1">
      <af:table value="#{bindings.EmployeesView1.collectionModel}" var="row" rows="#{bindings.EmployeesView1.rangeSize}"
                emptyText="#{bindings.EmployeesView1.viewable ? 'No data to display.' : 'Access Denied.'}"
                fetchSize="#{bindings.EmployeesView1.rangeSize}" rowBandingInterval="0" id="t1"
                rendered="#{viewScope.socValue eq null or viewScope.socValue eq '1'}">
        <af:column sortProperty="#{bindings.EmployeesView1.hints.EmployeeId.name}" sortable="false"
                   headerText="#{bindings.EmployeesView1.hints.EmployeeId.label}" id="c5">
          <af:outputText value="#{row.EmployeeId}" id="ot5">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.EmployeeId.format}"/>
          </af:outputText>
        </af:column>
        <af:column sortProperty="#{bindings.EmployeesView1.hints.FirstName.name}" sortable="false"
                   headerText="#{bindings.EmployeesView1.hints.FirstName.label}" id="c6">
          <af:outputText value="#{row.FirstName}" id="ot6"/>
        </af:column>
        <af:column sortProperty="#{bindings.EmployeesView1.hints.LastName.name}" sortable="false"
                   headerText="#{bindings.EmployeesView1.hints.LastName.label}" id="c7">
          <af:outputText value="#{row.LastName}" id="ot7"/>
        </af:column>
      </af:table>
      <af:table value="#{bindings.DepartmentsView1.collectionModel}" var="row" rows="#{bindings.DepartmentsView1.rangeSize}"
                emptyText="#{bindings.DepartmentsView1.viewable ? 'No data to display.' : 'Access Denied.'}"
                fetchSize="#{bindings.DepartmentsView1.rangeSize}" rowBandingInterval="0" id="t2"
                rendered="#{viewScope.socValue eq '2'}">
        <af:column sortProperty="#{bindings.DepartmentsView1.hints.DepartmentId.name}" sortable="false"
                   headerText="#{bindings.DepartmentsView1.hints.DepartmentId.label}" id="c8">
          <af:outputText value="#{row.DepartmentId}" id="ot8">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.DepartmentsView1.hints.DepartmentId.format}"/>
          </af:outputText>
        </af:column>
        <af:column sortProperty="#{bindings.DepartmentsView1.hints.DepartmentName.name}" sortable="false"
                   headerText="#{bindings.DepartmentsView1.hints.DepartmentName.label}" id="c9">
          <af:outputText value="#{row.DepartmentName}" id="ot9"/>
        </af:column>
      </af:table>
    </af:panelCollection>
    AP

Legend

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