Add a Browseview widget in an action command
Made by the Easy Diffusion AI

Add a Browseview widget in an action command

The Browseview Widget is the table that lists the documents in the standard Content Server GUI.

Lets add a browseview to an action command, for example to list contents, when the action command is executed

A browseview widget

Steps:

1. In _SubClassExecute of the action command add at the end

// set up nodeRec Record 
response.data.nodeRec = $WebNode.WebNodeUtils.NodeToWebNode( node )
response.data.path=Assoc.CreateAssoc()
response.data.path.pRootType=141
//Create the Child Objects and call the browse function of the webnode of our node
._BrowseCreateObjects(	webnode, prgCtx,	request,response )
(webnode)._browseContents        

Explanation: nodeRec is a textual description of the parent node (i.e. the container). Path.pRootType = 141 (Subtype of the Enterprise Workspace)

2. Copy these two routines from an Action-XXX command of the webnode into the OSpace object and adapt them

/*
_BrowseCreateObjects - a Copy from the Action-xxx Handlers to create all Child Objects
under the main object 
*/
function void _BrowseCreateObjects( Object webnode, Object	prgCtx,Dynamic	request,Dynamic		response )
		
		Boolean		displayIcon
		Integer		subtype
		List		exclude
		List		parm
		Object		obj
		String		url
		
		Object		factoryUtil = $LLIAPI.FactoryUtil
		String		nextURL = Web.Escape( $WebDsp.HTMLPkg.ArgsToURL( request ) )
		RecArray	objs = RecArray.Create( { "name", "url", "img", "subtype", "imgMapDivTagClassFirst" } )
		RecArray	iconObjs = RecArray.Create( { "name", "alt", "url", "img", "subtype" } )
		
		exclude = $WebNode.WebNodes.GetItem( response.data.path.rootSubtype )._RootExcludeSubTypes( prgCtx, request )
			
		for obj in .ChildWebNodes( webnode, TRUE, prgCtx, request )
			
			subtype = obj.fSubType
			displayIcon = obj.DisplayIcon()
			
			if ( ( subtype in exclude ) == 0 ) && factoryUtil.IsCreatable( prgCtx, subtype )
				
				url = Str.Format( \
							"%1?func=ll&objType=%2&objAction=create&parentId=%3&nextURL=%4",\
							request.SCRIPT_NAME,\
							subtype,\
							request.node.pId,\
							nextURL )
				
				RecArray.AddRecord( objs, { obj.Name(), url, obj.GIF1616(), subtype, obj.GIFSmallIconMapClass() } )
				
				if ( displayIcon )
				
					RecArray.AddRecord( iconObjs, { obj.Name(), obj.GifAddItemAltTag(), url, obj.GifAddItem(), subtype } )
				end
			end
		end
		
		RecArray.Sort( objs, "name" )
		RecArray.Sort( iconObjs, "name" )
		
		response.data.createInID = request.node.pId
		response.data.nextURL = nextURL 
		response.data.createObjects = objs
		response.data.createObjectIcons = iconObjs
	end


/*
ChildWebNodes - Returns a list of all webnodes of all childs under the parameter webnodeparent-
A Copy from Action-xxx Handlers to provide browseview functionality
*/
function List ChildWebNodes( Object webnodeParent, Boolean	addable = FALSE, Object	prgCtx = Undefined, Record	request = Undefined )
		List	retval
		//	One-time setup. 
		if ( IsUndefined( .fChildWebNodes ) || IsUndefined( .fChildWebNodesAddable ) )
			List	applTypes
			Integer	aType 
			Object	childWebNode
			Object	webNode
			List	exclude = $WebNode.WebNodes.GetItem( .fSubType )._RootExcludeSubTypes( prgCtx, request )
			Object	webNodes = $WebNode.WebNodes
			List	webNodeList = webNodes.GetItems()
			
			//	Preset the lists
			.fChildWebNodes = {}
			.fChildWebNodesAddable = {}
			//	Add child WebNodes by child subtypes.
			for aType in (webnodeParent).fChildSubtypes
				webNode = webNodes.GetItem( aType )
				.fChildWebNodes = List.SetAdd( .fChildWebNodes,\
											   webNode )
				if ( webNode._IsAddable( prgCtx, request ) )
					.fChildWebNodesAddable = List.SetAdd( .fChildWebNodesAddable,  webNode )
				end
			end
			
			for webNode in webNodeList
				
				//	Is the WebNode already in the list?
				if ( ( webNode in .fChildWebNodes ) == 0 )
					
					childWebNode = Undefined
					
					//	Add child WebNode by others' parent subtypes.
					if ( .fSubtype in webNode.fParentSubtypes )
						
						childWebNode = webNode
					end
					
					if ( IsUndefined( childWebNode ) )
						
						//	Add child WebNode by child application type.
						applTypes = webNode.ApplTypes()
						
						for aType in .fChildApplTypes
							
							if ( aType in applTypes )
								
								childWebNode = webNode
								
								break
							end
						end
					end
					
					if ( IsUndefined( childWebNode ) )
						
						//	Add child WebNode by others' parent application types.
						applTypes = .ApplTypes()
						
						for aType in webNode.fParentApplTypes
							
							if ( aType in applTypes )
								
								childWebNode = webNode
								
								break
							end
						end
					end
					
					//	Add this WebNode as a child?
					if ( IsDefined( childWebNode ) )
						
						if ( ( webNode.fSubtype in exclude ) == 0 )
							
							.fChildWebNodes = List.SetAdd( .fChildWebNodes,\
														   webNode )
							
							if ( webNode._IsAddable( prgCtx, request ) )
								
								.fChildWebNodesAddable = List.SetAdd( .fChildWebNodesAddable, \
																	  webNode )
							end
						end
					end
				end
			end
		end
		
		if ( addable )
			retval = .fChildWebNodesAddable
		else
			retval = .fChildWebNodes
		end
		
		return retval
	end        

3. Copy the auxiliary routines into Ospace

/* Helper Functions for stting up the Child Chain
 * can be included in the main functions
*/
	function List ApplTypes()
		
		return .LLNode().fApplTypes
	end
	
	function Object LLNode( \
		Integer	subtype = .fSubtype )
		
		
		return $LLIAPI.LLNodeSubsystem.GetItem( subtype )
	end        

4. Declare variables in OSpace

	Dynamic fChildWebNodes = undefined
	Dynamic fChildWebNodesAddable = undefined 
	Dynamic fChildSubTypes
	Dynamic fChildApplTypes
	Integer fSubType=6080 (= Subtype des Containerelements)        

5. In the Weblingo of the action command, insert it at the point where the browseview should appear:

;String		webNodeHTMLPrefix = $Kernel.ModuleSubsystem.GetItem( "webnode" ).HTMLPrefix()
		;Assoc		data = .fResponse.data

	;;call <webNodeHTMLPrefix + "browseview.html">( prgCtx, request, data )
        



要查看或添加评论,请登录

Reiner Merz的更多文章

社区洞察

其他会员也浏览了