in

Community

Take part in the community surrounding CodeBreeze and other products from SteelBlue Solutions.
Latest post 05-05-2009 10:52 AM by Joseph Baggett. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-05-2009 10:52 AM

    Get List of Parents

    I just thought I would post this to help people out because I've been asked by a friend how to do it in CodeBreeze.  There might be a better way, but I'll post a way I've done it.  Let's assume you have a target tag called "Parent" in which you wanted to get a recursive list of parents in relation to a specific business entity.

    On my TemplateHelper class code behind file that inherits from CodeBreezeTemplateBase, I implement a property called ParentList and a method

     

     

     

     

     

     

     

     

     

     

    private

     

     

    List<string> _parentList = null;

     

     

    public List<string> ParentList

    {

     

     

    get

    {

     

     

    if(_parentList == null)

    {

    _parentList =

     

    new List<string>();

    }

     

     

    return _parentList;

    }

     

     

    set

    {

    _parentList = value;

    }

    }

     

     

    public void GetParentList(CodeBreeze.Business.BusinessEntity entity, CodeBreeze.Business.Project project)

    {

     

     

    string parent = entity.Tags["Parent"].Value;

     

     

    if(!String.IsNullOrEmpty(parent))

    {

    ParentList.Add(parent);

    CodeBreeze.Business.BusinessEntity parentEntity = project.BusinessEntities.FindByEntity(parent);

    GetParentList(parentEntity, project);

    }

    }

     

     

     

     

     

     

    I pass in the CodeBreeze.Business.Project in the method to access the FindByEntity method which normally gets access by passing in the _ActionTarget which is merely a string.

    In the code template, I access the list like so:

     

    <%

    GetParentList(entity, _Project);

    ParentList.ForEach(

     

     

    delegate(string

    parent)

    { %>

    <%= parent %>

    <%

    });

    ParentList =

     

     

    null

    ;

    There may be a better implementation, but I figure this may help other people.

     

     

Page 1 of 1 (1 items)
2008 - All rights reserved
Powered by Community Server (Commercial Edition), by Telligent Systems