Requirement: I have an Oracle ADF Table displaying the Departments table data. Now, I want to add one more column with the name as Serial Number as the first column in the Departments Table.
Screen shot of the requirement is as below:
Solution: For solution of the above requirement follow the steps as shown below:
Step 1: Go to table properties and set varStatus=”vs”
Step 2: Drag and drop an af:column inside the table as the first column. Set headerText=”Serial Number”
Step 3: Drag and drop an af:outputText inside the column dragged and dropped in Step2.
Step 4: Set the value of the af:outputText as #{vs.index+1}
For this, go to the Value property > Click Expression Builder > Expand vs > Click index > Click add (+) from the Operands section > Add 1
Thus, the complete demo.jspx code is shown below.
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="" version="2.1" xmlns:f=""
xmlns:af="">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="demo.jspx" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:table value="#{bindings.DepartmentsVO1.collectionModel}" var="row"
rows="#{bindings.DepartmentsVO1.rangeSize}"
emptyText="#{bindings.DepartmentsVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
rowBandingInterval="0"
selectedRowKeys="#{bindings.DepartmentsVO1.collectionModel.selectedRow}"
selectionListener="#{bindings.DepartmentsVO1.collectionModel.makeCurrent}"
rowSelection="single" fetchSize="#{bindings.DepartmentsVO1.rangeSize}" id="t1" varStatus="vs">
<af:column id="c5" headerText="Serial Number" sortable="true">
<af:outputText value="#{vs.index + 1}" id="ot5"/>
</af:column>
<af:column headerText="#{bindings.DepartmentsVO1.hints.DepartmentId.label}" id="c1"
sortProperty="#{bindings.DepartmentsVO1.hints.DepartmentId.name}" sortable="true">
<af:outputText value="#{row.DepartmentId}"
shortDesc="#{bindings.DepartmentsVO1.hints.DepartmentId.tooltip}" id="ot1">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.DepartmentsVO1.hints.DepartmentId.format}"/>
</af:outputText>
</af:column>
<af:column headerText="#{bindings.DepartmentsVO1.hints.DepartmentName.label}" id="c2"
sortProperty="#{bindings.DepartmentsVO1.hints.DepartmentName.name}" sortable="true">
<af:outputText value="#{row.DepartmentName}"
shortDesc="#{bindings.DepartmentsVO1.hints.DepartmentName.tooltip}" id="ot2"/>
</af:column>
<af:column headerText="#{bindings.DepartmentsVO1.hints.ManagerId.label}" id="c3"
sortProperty="#{bindings.DepartmentsVO1.hints.ManagerId.name}" sortable="true">
<af:outputText value="#{row.ManagerId}"
shortDesc="#{bindings.DepartmentsVO1.hints.ManagerId.tooltip}" id="ot3">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.DepartmentsVO1.hints.ManagerId.format}"/>
</af:outputText>
</af:column>
<af:column headerText="#{bindings.DepartmentsVO1.hints.LocationId.label}" id="c4"
sortProperty="#{bindings.DepartmentsVO1.hints.LocationId.name}" sortable="true">
<af:outputText value="#{row.LocationId}"
shortDesc="#{bindings.DepartmentsVO1.hints.LocationId.tooltip}" id="ot4">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.DepartmentsVO1.hints.LocationId.format}"/>
</af:outputText>
</af:column>
</af:table>
</af:form>
</af:document>
</f:view>
</jsp:root>
Save all and run the application. Thus, the ran application is shown below:
Note: Even if we sort (ascending or descending order) the Departments table data based on DepartmentId, DepartmentName, ManagerId, or LocationId, still the Serial Number will be displayed in a sequential manner starting from 1.
Hence, the solution to our requirement.
If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.
Thanks & Regards,
Susanto Paul
422 total views, 1 views today