Default view for an element in custom perspectives

Topics: General
Oct 18, 2011 at 7:18 AM

What I want to achieve is having a default view display in the staging deck when a node is selected in the perspective tree. I don't think there is existing capability for this, but has anyone any advice for how I could go about it

 

The idea being that when there is too much data to comfortably display in the tree, I can display it in a list view in a view. So what I would need to do is everytime a node in the perspective tree is selected and when the perspective is opened, the stage deck is activated if it isn't already and a form is displayed in the views. If the selected node is changed, the "default view" is updated for that node. 

Oct 18, 2011 at 8:14 AM

You can probably introduce a command and a view using the Tree Definition feature and do the view using a custom ASPX or an C1 Function to do the view.

Would you like a 'node focus' and 'perspective switch' to go and open up a view on default? If you want that command to be associated with a view or focus on a node, you would need to add this aspect to the source code - it is not in the product as is.

Oct 18, 2011 at 10:44 PM

I have the command and view in place and for the moment have been executing the command manually. The intention is to open the view on node focus and perspective switch. I haven't as yet been able to determine how I can attach an event to fire on focus or switch. I think it must be somewhere in the javascript files, but I'm not really sure where that is. I've been hunting around for where the focus event that changes the toolbar is attached because that would help immeasurably, but so far I haven't had much luck. Is there any information on how the focus events are being attached?

Oct 20, 2011 at 12:22 PM

gilmae, we will construct a code sample and post it here shortly. This is not something we have tooled all the way from back- to front-end, but with a little ingenuity it should be doable.

Oct 27, 2011 at 6:27 AM

That would be great.

Somewhat related, is there a Composite Way to have something in the StageDeck, a list of IData objects for example, receive refreshes in much the same way that the perspective tree does.

As described above, I display a list and then launch other workflows to edit items. But the changes made to assets in other views are not reflected in the list until it happens to do a postback. I can do a refresh via META REFRESH or javascript, but it is exactly as rough as you can imagine, not all unlike the seamless integration of new items in the perspective tree.

You know, I guess what I am really asking is, is there a secret grimoire to understanding how the client script all hangs together?

Oct 28, 2011 at 1:13 AM

Well, it feels like it is wrong, but my solution is:

 

<script>
    var t = window.setInterval(function () { var forms = document.getElementsByTagName("form"); if (forms.length > 0) { forms[0].submit(); } }, 5000);
</script>

It probably should have some way of knowing it shouldn't do a postback, if the user is interacting with a select list.

Nov 4, 2011 at 10:28 AM
Edited Nov 4, 2011 at 10:30 AM

Hi you can write custom ui:page and add action listeners

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Composite_InstalledPackages_Media_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://www.w3.org/1999/xhtml" xmlns:control="http://www.composite.net/ns/uicontrol">
        <control:httpheaders runat="server" />
        <head>
                <title>Composite.Management.Generic</title>
                <control:styleloader runat="server"/>
                <control:scriptloader type="sub" runat="server" />
                <script type="text/javascript" src="binding/MediaPageBinding.js"/>
        </head>
        <body>
                <ui:page id="page" binding="MediaPageBinding">
                        <ui:window id="window" url="List.aspx?EntityToken=<%=HttpUtility.UrlEncode( this.EntityToken ) %>"/>
                </ui:page>
        </body>
</html>
Default.aspx.cs:
using System;

public partial class Composite_InstalledPackages_Media_Default : System.Web.UI.Page
{
	public string EntityToken
	{
		get
		{
			return Request["EntityToken"] ?? string.Empty;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{

	}
}
binding/MediaPageBinding.js
MediaPageBinding.prototype = new PageBinding;
MediaPageBinding.prototype.constructor = MediaPageBinding;
MediaPageBinding.superclass = PageBinding.prototype;

/**
* @class
*/
function MediaPageBinding() {

	/**
	* @type {SystemLogger}
	*/
	this.logger = SystemLogger.getLogger("MediaPageBinding");


	this._tree = null;

	/*
	* Returnable.
	*/
	return this;
}

/**
* Identifies binding.
*/
MediaPageBinding.prototype.toString = function () {

	return "[MediaPageBinding]";
}

/**
 * @overloads {PageBinding#onBindingRegister}
 */
MediaPageBinding.prototype.onBindingRegister = function () {
	MediaPageBinding.superclass.onBindingRegister.call(this);

	var selectedDeck = ExplorerBinding.bindingInstance.getSelectedDeckBinding();
	var selectedView = selectedDeck.getAssociatedView();
	this._tree = selectedView.getContentWindow().bindingMap.tree;

	this._tree.addActionListener(TreeNodeBinding.ACTION_ONFOCUS, this);
}

/**
* @overloads {PageBinding#handleAction}
* @implements {IActionListener}
* @param {Action} action
*/
MediaPageBinding.prototype.handleAction = function (action) {

	MediaPageBinding.superclass.handleAction.call(this, action);
	switch (action.type) {
		case TreeNodeBinding.ACTION_ONFOCUS:
			var win = this.bindingWindow.bindingMap.window;
			win.setURL("List.aspx?EntityToken=" + encodeURIComponent(action.target.node.getEntityToken()));
			break;
	}
}

/**
* Overloads {Binding#onBindingDispose}
*/
MediaPageBinding.prototype.onBindingDispose = function () {
	this._tree.removeActionListener(TreeNodeBinding.ACTION_ONFOCUS, this);
	MediaPageBinding.superclass.onBindingDispose.call(this);
}
You can attach action see documentation (http://docs.composite.net/Console/ConsoleFAQ?q=How+to+attach+actions+to+the+elements+in+the+tree+using+ActionExecutor%3F)
Sample Action Executor for aspx
 
	public sealed class MediaViewerActionExecutor : IActionExecutor
	{
		public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
		{

				string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

				string url = UrlUtils.ResolveAdminUrl(string.Format("InstalledPackages/Media/Default.aspx?EntityToken={0}", HttpUtility.UrlEncode(EntityTokenSerializer.Serialize(entityToken))));

				ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem
				{
					Url = url,
					ViewId = Guid.NewGuid().ToString(),
					ViewType = ViewType.Main,
					Label = "Media viewer"
				}, currentConsoleId);

			return null;
		}
	}
Nov 16, 2011 at 1:00 PM

We have collected the info on this page in an article at our docs site: http://docs.composite.net/Console/Node-Click-Events