Suppose you have an ADF table somewhere inside a JSF page and you wish it to be sortable. This is fine as long as you define two things.
- The sortproperty property of the adf:column tag which has to be one of the column names of the table binding and tell the system how to change the order by clause of the underlying view.
- The sortbale which has to be set to true or false and determines whether to allow sorting by clicking on the column header or not
So this is a perfectly good column definition for an attribute called Matnr athat corresponds to the notorious SAP material number.
<af:column sortProperty="Matnr" sortable="true" headerText="#{bindings['PF_ForSale'].labels.Matnr}"> <af:outputText value="#{row.Matnr}"/> </af:column>
If you now happen to have a transient attribute and you wish to sort the table based on this attribute, then you just can't do it. The way I see it, sorting means changing the order by clause and re executing the entire query. ADF complains that there is simply no attribute by that name and throws an SQLException that comes straight from the JDBC driver.
My suggestion for a workaround that works most of the times is this : Since 90% pf transient attributes usually serve as simple lexical transformations of real database attributes, changing the sortProperty of the adf:column tag to the value of the real column might solve the problem
Let's suppose that the ViewObject of the previous example has a transient attribute called DisplayMatnr that simply removes the leading zeros of the SAP oriented material number stored in column Matnr. It goes without saying that if Matnr is sorted then so is DisplayMatnr. Therefore writing something like ...
<af:column sortProperty="Matnr" sortable="true" headerText="#{bindings['PF_ForSale'].labels.DisplayMatnr}"> <af:outputText value="#{row.DisplayMatnr}"/> </af:column>
... might bring the desired effect. There is one last warning though the attribute that you wish to sort by must be a part of the table definition in the bindings page
4 comments :
Thank you very much for the info..
I would like to know.. when I am using the Java Application [swing, ADF BC.] Sort functionality is not working for the alternative columns. Can you please let me know is there any property to set for the sort functionality to work for other columns.
Sorry mate, I have never done it with Swing :-)
HI, I have a table that use a Object[] as a row List.
Any idea how to implemente sorting over this list ?
I mean, we use a Collection to fill the table.. how can I implemented sorting functionality ?
Hi,
Can you help me with below scenario?
I have to sort one status column as per the business rule, not alphabetically to be straight.
And I have a transient attribute which returns LONG values for each string of that status as per the business rule order.
for eg. 1 for BBB, 2 for AAA
so I want to sort as BBB, AAA as per the transient attribute.
Any help will be appreciated, I am trying since last 2 days, and I am new to the ADF, no clues left.
Thanks,
Dish
Post a Comment