Using Custom Objects in Chameleon Display Conditional Testing

Ben Tiedt’s Chameleon is one of my favorite aspects of developing in Community Server.  With it’s hierarchical contextual awareness and library of smart ASPNET controls, sophisticated UI’s can be created in very little time.  Of course, using CodeSmith templates to bang out the underlying class structures helps facilitate the process, too.

Chameleon makes heavy use of <CSControl:Placeholders /> which display content using a <DisplayConditions> property.  As an example, the DisplayCondition test to display page content to registered users only would be

<DisplayConditions>
        <CSControl:UserInRoleCondition Role=”Registered Users” UseAccessingUser=”true” runat=”server” />
</ DisplayConditions>

If registered, thus in the “Registered Users” role, the content would display.  You wouldn’t think of being able to use non-native Community Server objects for this sort of conditional testing (at least I wouldn’t have), so when I did it a couple days ago I had to say, “sweeet!”

I wanted to restrict the display of two Telligent.Glow.TabPanel tabs in my Jobs Management Application to users in the OfficeAdministrator role.  To all other users those tabs would be hidden.

Because I extended Community Server’s User object with new properties and employed a custom RolesConfiguration class I was able to perform a quick and powerful display conditional test shown below.

 

<CSControl:PlaceHolder ID=”PlaceHolder1″ runat=”server”>
    <DisplayConditions>
   <DBVT:UserPropertyValueComparison ComparisonProperty=”IsOfficeAdministrator”
    Operator=”IsSetOrTrue” runat=”server” UseAccessingUser=”True” />
    </DisplayConditions>
    <ContentTemplate>
    yousa!
    </ContentTemplate>
 </CSControl:PlaceHolder>

 

The <DBVT:UserPropertyValueComparison /> statement represents objects located in a custom class library outside of the Community Server base package, yet leveraged in Chameleon like any native CSControl object.

For the Community Server Intelligentsia out there, no, this didn’t work to control tab display, only because the Placeholder could not be placed between TabbedPane elements.  I went with the page-behind to get it done.

 

if (!jobUser.IsOfficeAdministrator)
{
    ((Telligent.Glow.TabbedPane)DayTabs.Panes[12]).Tab.Visible = false;
    ((Telligent.Glow.TabbedPane)DayTabs.Panes[13]).Tab.Visible = false;
}

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.