Changeset 6932


Ignore:
Timestamp:
Jun 18, 2015, 2:40:59 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #1950: Add support for any-to-any link filters in table lists views

Exporting did not work when column was defined by an extension since the formatter was overwritten in some cases resulting in a ClassCastException.

The AnyToAnyDataLoader can now return the linked item which allows list pages to use the regular <base:propertyvalue> taglib to link to the target item.

Location:
trunk/src/clients/web/net/sf/basedb/clients/web/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/AnyToAnyDataLoader.java

    r6931 r6932  
    3434  implementation can also be used in standalone mode on list page.
    3535  Use {@link #create(String, Item, String)} to create an instance
    36   and then {@link #getData(DbControl, ExportedProperty, BasicItem)}
    37   with a 'null' exportedProperty parameter.
     36  and then {@link #getLinkedItem(DbControl, BasicItem)}.
    3837 
    3938  @author Nicklas
     
    8786  {
    8887    Object value = null;
     88    BasicItem linked = getLinkedItem(dc, item);
     89    if (linked != null)
     90    {
     91      value = propertyPath == null ? linked.getId() : propertyPath.getValue(dc, linked);
     92    }
     93   
     94    return value;
     95  }
     96
     97  /**
     98    Get the item that is linked to by this any-to-any link definition.
     99    @return The linked item or null if no item exists or if the item is not of
     100      the correct target type
     101  */
     102  public BasicItem getLinkedItem(DbControl dc, BasicItem item)
     103  {
     104    BasicItem linked = null;
    89105    try
    90106    {
    91107      AnyToAny any = AnyToAny.getByName(dc, item, linkName);
    92       if (any.getToType() == linkType && propertyPath != null)
     108      if (linkType == null || linkType == any.getToType())
    93109      {
    94         value = propertyPath.getValue(dc, any.getTo());
    95       }
    96       else
    97       {
    98         value = any.getToId();
     110        linked = any.getTo();
    99111      }
    100112    }
    101113    catch (ItemNotFoundException ex)
    102114    {}
    103    
    104     return value;
     115
     116    return linked;
    105117  }
    106 
    107118}
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/ExportedProperty.java

    r6931 r6932  
    113113      dataloader = new FileSetMemberLoader(fileType, propertyPath);
    114114    }
    115     else if (name.startsWith("|"))
     115    else if (name.startsWith("|") && dataloader == null)
    116116    {
    117117      // Any-to-any=|link|type|property
     
    127127        {
    128128          linkProperty = "name";
    129           formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), Type.STRING);
     129          if (formatter == null)
     130          {
     131            formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), Type.STRING);
     132          }
    130133        }
    131134        else
    132135        {
    133           formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), Type.INT);
     136          if (formatter == null)
     137          {
     138            formatter = FormatterFactory.getTypeFormatter(dc.getSessionControl(), Type.INT);
     139          }
    134140        }
    135141      }
     
    139145        propertyPath = Metadata.getInstance(linkType.getItemClass()).getPropertyPath(linkProperty, false);
    140146      }
    141       if (dataloader == null)
    142       {
    143         dataloader = new AnyToAnyDataLoader(linkName, linkType, propertyPath);
    144       }
     147      dataloader = new AnyToAnyDataLoader(linkName, linkType, propertyPath);
    145148    }
    146149    else if (dataloader == null && metadata != null)
Note: See TracChangeset for help on using the changeset viewer.