[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
IFIXGRIDBinding exports sortreference  XML
Forum Index -> Development
Author Message
levy

Power User

Joined: 12/03/2008 16:38:22
Messages: 308
Location: XpertCenter
Offline

Hi,

When exporting a FIXGRIDTreeBinding (e.g. to PDF), the (treenode's) sortreference is exported instead of the (treenode's) text.

Can you reproduce and fix that?

Regards, Daniel
[WWW]
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

...will check...!
Björn

Björn Müller, CaptainCasa GmbH
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi Daniel,

I begin to understand:
...this is always the case. The SORTREFERENCE is the hint to the variable which is used for finding the value of a cell (for sorting, export, ...). It was named "SORT"REFERENCE because the sorting was the first situation, where we required some access to the value of a cell - but then was used for other purposes as well.

We always first check for the SORTREFERENCE of a column, only if this is not available we check for definitions in TEXT/VALUE/... variables, so the SORTREFERENCE always is first (also for FIELD, LABEL, ... definitions).

So, there should be some real value representation behind...

In principal there are two options for you:

1. either you change the sorting for the tree node (e.g. by overriding:

Code:
     /**
      * Used by the default sorting: when a comparator is returned then this
      * one is used for comparing values. If null is returned then the default
      * comparator is used. - You need to override in order to apply special
      * comparators for certain columns.
      */
     protected Comparator findSortComparatorForColumnValue(String sortReference)
     {
         ...
     }
 

and pass back a "proper" text in the SORTREFERENCE (which is taken over into the exported data)


...or...

2. you override the export (FIXGRIDBinding.Exporter)

I believe 1. is definitely the easier option!

Regards, Björn

Björn Müller, CaptainCasa GmbH
emillinger


[Avatar]

Joined: 18/03/2014 08:26:17
Messages: 1
Offline

Hi Daniel,

I've had the same problem quite some time ago. I wasn't able to program a general solution but managed to find a quick workaround by overriding the exporter (just as Björn mentioned):

Code:
     @Override
     protected Exporter createExporter() {
       return new Exporter() {
         /**
          * @param ci
          * @param nullValue
          * @param asDisplayString
          *          true ==> nice formatting of string, false ==> no formatting but native format ==> usable for sorting etc.
          * @return
          */
         protected String getToBeAccessedNodeStringValue(ColumnInfo ci, String nullValue, boolean asDisplayString) {
           if (ci.getSortreference() == null)
             return nullValue;
           try {
             FacesContext fc = FacesContext.getCurrentInstance();
             Object value;
             if (ci.getSortreference().equals("orderMesstartForSorting")) //TODO solve generically: don't take sortReference but valueExpression
               value = ExpressionManagerV.getValueForExpressionString(fc, getToBeAccessedNodeExpression("ppcd.startdate"));
             else
               value = ExpressionManagerV.getValueForExpressionString(fc, getToBeAccessedNodeExpression(ci.getSortreference()));
             if (value == null)
               return nullValue;
             if (asDisplayString) {
               String nodeExpression = "#{" + m_objectBinding + ".toBeAccessedNode}";
               return ValueManager.convertObject2DisplayString(value, ci.getFormatValue(nodeExpression), ci.getFormatmaskValue(nodeExpression),
                   ci.getTimezoneValue(nodeExpression), true);
             } else
               return ValueManager.convertObject2ValueString(value);
           } catch (Throwable t) {
             CLog.L.log(CLog.LL_WAR, "Problems accessing value via sortreference: " + ci.getSortreference());
             return nullValue;
           }
         }
       };
     }
 


Regarding the original CC-implementation, I only changed these 4 lines of code:

Code:
 if (ci.getSortreference().equals("orderMesstartForSorting")) //TODO solve generically: don't take sortReference but valueExpression
               value = ExpressionManagerV.getValueForExpressionString(fc, getToBeAccessedNodeExpression("ppcd.startdate"));
             else
               value = ExpressionManagerV.getValueForExpressionString(fc, getToBeAccessedNodeExpression(ci.getSortreference()));
 


where "orderMesstartForSorting" is the sortreference and "ppcd.startdate" is the value to be displayed.

Regards, Ernst
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team