Document Author:
Coextant Systems International AG
Document Manager:
Coextant Systems International AG
All information in this manual i
s Copyright of Coextant Systems
International AG. The material in this document is for information
only and is subject to change without notice. While reasonable
efforts have been made in the preparation of this document to
assure its accuracy, Coextant Sy
stems International AG assumes
no liability resulting from errors or omissions in this document, or
from the use of the information contained herein.
Coextant Systems International AG reserves the right to make
changes in the product design without reserva
tion and without
notification to its users.
Coextant Systems International AG
Building Web Applications with
Hyper.Net Framework SDK
SDK Architecture and
Steps involved in building a Web Application
Building Web Applications with Hyper.Net Framework SDK
Proprietary Information
-
Do Not Distribute
Page
2
Of
59
Contents
Building Web Applications with the Hyper.Net Framework SDK
................................
................................
............
4
General Features of the Hyper.Net Framework SDK
................................
................................
..........................
4
Technical Overview of Framework Modules
................................
................................
................................
........
5
Web Components Module
................................
................................
................................
...............................
5
Object
-
Oriented SDK Module
................................
................................
................................
..........................
5
Web Service Interfac
e Module
................................
................................
................................
.........................
5
Caching System Module
................................
................................
................................
................................
..
6
N
-
Tier Architecture Module
................................
................................
................................
..............................
6
Im
pact on Development
................................
................................
................................
................................
...
6
The Hyper.Net Framework SDK in Detail
................................
................................
................................
............
7
How to Install the Hyper.Net SDK Web Server Controls in Visual Studio .Net
................................
................
9
How to Build a Basic Hyper.Net Web Application Using the Hyper.Net Framework SDK
.............................
11
Web Server Con
trols for Rapid Web Application Design
................................
................................
...........
11
Business Classes for Fast Object
-
Oriented Access to Content
................................
................................
12
Creating an Application Using C#
................................
................................
................................
.............
13
Where to Start?
................................
................................
................................
................................
.....
13
Bridging the
Web Application and the HNFSDK
................................
................................
....................
15
Providing Extra Settings for the HNAcme Web Application
................................
................................
..
15
Creating the Acme ASP.Net Pages
................................
................................
................................
........
17
Th
e Code Explained
................................
................................
................................
..............................
20
Creating the Content Area
................................
................................
................................
.....................
22
Creating the TOC
................................
................................
................................
................................
...
27
Providing Navigation for the Web Application
................................
................................
.......................
28
Enabling Search
................................
................................
................................
................................
....
31
Conclusion
................................
................................
................................
................................
....................
36
Accessing the Hyper.Net Framework SDK via Web Services
................................
................................
..........
39
Hyper.Net Framework SDK
Business Object Model Class Overview
................................
..............................
41
Primary Data Classes
................................
................................
................................
...............................
41
MetaInfo
................................
................................
................................
................................
.................
41
MetaInfoCollection
................................
................................
................................
................................
.
41
Publication
................................
................................
................................
................................
.............
42
PublicationCollection
................................
................................
................................
.............................
43
Search
................................
................................
................................
................................
...................
44
Topic
................................
................................
................................
................................
......................
45
TopicCollection
................................
................................
................................
................................
......
46
Bookmarks
................................
................................
................................
................................
.............
47
Content
................................
................................
................................
................................
..................
47
JavigatorNavigation
................................
................................
................................
...............................
48
Navigati
onImage
................................
................................
................................
................................
....
49
NavigationLink
................................
................................
................................
................................
.......
49
Subtopics
................................
................................
................................
................................
...............
49
TOC
................................
................................
................................
................................
.......................
50
TopicAncestors
................................
................................
................................
................................
......
50
TreeViewNavigation
................................
................................
................................
...............................
51
Download
................................
................................
................................
................................
...............
52
Feedback
................................
................................
................................
................................
...............
52
Recommend
................................
................................
................................
................................
..........
52
Subscribe
................................
................................
................................
................................
...............
53
Subscriptions
................................
................................
................................
................................
.........
53
EmailSender
................................
................................
................................
................................
..........
54
Proprietary Information
-
Do Not Distribute
Page
3
Of
59
EventTrace
................................
................................
................................
................................
............
54
HyperNetFuzzySearch
................................
................................
................................
..........................
54
Tools
................................
................................
................................
................................
......................
55
TopicFile
................................
................................
................................
................................
.................
55
Structures
................................
................................
................................
................................
..................
56
fts_publication, fts_topic
................................
................................
................................
........................
57
publication
................................
................................
................................
................................
..............
57
publicationMetaInfo
................................
................................
................................
...............................
58
topic
................................
................................
................................
................................
.......................
58
topicMetaInfo
................................
................................
................................
................................
.........
58
Proprietary Information
-
Do Not Distribute
Page
4
Of
59
Building Web
Applications with the
Hyper.Net Framework SDK
The HNFSDK is a comprehensive set of tools aimed to boost the performance of any Hyper.Net
-
based web or
windows application, as well as reduce the time and amount of code required to create a solution.
The HNFS
DK can be considered as business middleware that allows you to develop on any kind of Microsoft .Net
compliant language, and for any type of application that requires knowledge
-
sharing.
The HNFSDK comes with a fully functional W3C compliant SOAP web servi
ce out of the box, allowing you to share
content created by Hyper.Net with other Microsoft technologies such as Microsoft Content Management Server and
Microsoft Site Server. It also enables deployment of content to non
-
Microsoft platforms and languages.
The HNFSDK is thus middleware that lets you rapidly deliver highly
-
optimized Web applications and deliver content
simultaneously to multiple Web applications across technologies.
General Features of the Hyper.Net Framework SDK
The Solution Development Fram
ework for Hyper.Net is an innovative new approach for managing the process of
getting corporate content on
-
line and achieving rapid success with your e
-
business initiatives. The Framework
leverages the power and benefits of industry standards like XML, Web
Services, and object
-
oriented techniques, and
then makes them transparent to your staff.
The Solution Development Framework for Hyper.Net provides the following modules that help you get things done:
Web Components Module
: Lets you quickly create tables
of contents, topic displays, related and subtopic lists,
associated file display lists (for source and PDF files), publication approval, and other content
-
related functions
that give users ways to search, locate, display, read, and navigate through oceans
of information. Without low
-
level programming. The Web Components Module is the secret to creating new content
-
rich portals at an
accelerated pace.
Object
-
Oriented SDK Module
: Gives developers a standard object
-
oriented access point, useful from any
indust
ry
-
standard programming language, that provide access to all parts of Hyper.Net publications without
understanding relational data concepts. The Object
-
Oriented SDK Module is the key to letting developers do low
-
level data integration when special needs ar
ise.
Web Service Interface Module
: Enables XML
-
based Web Services power for your solutions, letting you share
Hyper.Net publications with any other solution through an industry
-
standard SOAP interface. The Web Service
Interface Module is the fast way to ex
tend the power of Hyper.Net to the needs of a distributed enterprise, and
let's you meet requirements for syndicating content, centralizing publishing services, and selling specific
information to specific customers.
Caching System Module
: Provides a built
-
in comprehensive caching system that accelerates page
-
loading speed
for all of your publications. Integrated with Hyper.Net's topic
-
level security system, the caching system flattens
the bottlenecks typically associated with serving large amounts of conte
nt including images and binary files,
allowing you to support more users without scaling additional server hardware. The hardware savings provided
by the caching system alone are reason enough to use the entire Hyper.Net Solution Development Framework
N
-
Tier Architecture Module
: Provides a ready
-
to
-
use n
-
tier application layer built on top of the relational
database and leveraging the Object
-
Oriented SDK and Caching System Modules. When you use this component
Proprietary Information
-
Do Not Distribute
Page
5
Of
59
of the Hyper.Net Framework, you can avoid int
egrating web applications with the relational database, eliminate
selection programming, and are free to focus on building your solution at the ASPX level. Using the above
components of the Hyper.Net Framework together, you can save what is normally months
of tedious
programming and debugging, dramatically reducing development time and project risk.
Technical Overview of Framework Modules
Web Components Module
The Framework's standard drag
-
and
-
drop web components are made available from a Hyper.Net Tools to
olbar in MS
.Net. Various web components are provided for quickly creating tables of contents, topic displays, related and
subtopic lists, associated file display lists (for source and PDF files), publication approval, and other content
-
related
functions.
Eliminates the need to program an n
-
tier Solution to access relational data in the Hypermedia Data Store. The
Hyper.Net Framework provides the benefits of a standard n
-
tier architecture without the development effort
Allows quick construction of .Net
-
based
web solutions that display large numbers of complex publications in a
rich portal environment, without a portal cost
Provides point
-
and
-
click configuration capabilities for each component that make it possible to realize a custom
result without additional
programming
Makes it possible to reduce development times for standard projects more than 60%, and creates consistency
across solutions that makes them easily upgradable
Object
-
Oriented SDK Module
The Framework's SDK is a standard programming interface, u
seful from any industry
-
standard programming
language, that provides your Solutions with access to all parts of publications using an easy
-
to
-
understand object
-
oriented interface.
Enables rapid creation of content
-
oriented Web and Windows Solutions that re
quire custom manipulation of
publications and their parts. Publications and their parts can be integrated with other data at the code level to
create new ways to blend content with data from other sources.
Provides access to publications at a conceptual le
vel like Publication, Topic, etc. using standard objects and
collections that are easy to manipulate.
Makes it possible to access Hyper.Net data without an understanding of Hyper.Net relational structure or
relational database access techniques.
Provides X
SLT access for a layer of XML transformation that can be used in addition to the standard Hyper.Net
XSLT functions, letting you serve content to the web and to other devices in different markups from the same
content in the Hypermedia Data Store.
Web Servi
ce Interface Module
The Framework's SOAP
-
based XML Web Service interface is an access point for requesting various parts of a
publication, including topics, associated files, entire publications, and other relations from other Solutions that can be
distributed across any net. Information can be accessed at any level and passed to the requesting Solution without
using the object
-
oriented SDK.
Makes it possible to integrate Hyper.Net data with any external Solution that can communicate through a stand
ard
web services interface
Allows use of Hyper.Net content on remote Web Solution servers not having access to the Hypermedia Data Store
Proprietary Information
-
Do Not Distribute
Page
6
Of
59
Caching System Module
The Framework's caching system provides a built
-
in comprehensive caching system that accelerates
page
-
loading
speed for all publications and their parts. The caching system flattens the bottlenecks typically associated with serving
large amounts of content including images and binary files, allowing you to support more users without scaling
additional
server hardware. The hardware savings provided by the caching system alone are reason enough to use the
entire Hyper.Net Solution Development Framework.
Essential for Web solutions that provide access to large numbers of binary files such as PDF and sourc
e files
User
-
specific caching preserves topic
-
level security protection
Useful for implementing file system release of static web site content
Manages the relational content access process to keep the number of database accesses and transfers to the
absolu
te bare minimum, and to minimize network traffic
N
-
Tier Architecture Module
The Framework's ready
-
to
-
use n
-
tier architecture is the foundation for the other Framework modules. Invisible, and
installed along with the Framework, this module provides you with
an n
-
tier application architecture that is optimized
for the media
-
rich content you need to serve to your users through your web applications. From stored procedures all
the way up to integration points with the Object
-
Oriented SDK Module, developers have
what they need to
implement web solutions quickly and without the usual programming/debugging work.
Stored procedures for Microsoft SQL
Selection statements that access metadata and security information correctly
Selection statements that retrieve the inf
ormation you need most: XML, HTML, PDFs, attachments, images, etc.
Selection statements that implement customizable search requests
Assembly of datasets ready
-
to
-
use at the ASPX level
Integration with the Object
-
Oriented SDK Module
Separation of database l
ayer from data access layer from business logic layer
Impact on Development
The primary goal of any rapid solution development framework is to let you create corporate solutions using a
standardized, cookie
-
cutter approach that doesn't require experts ever
y time you want to do something. The e
-
business
Solution Development Framework for Hyper.Net is specifically designed to make this a reality, and to let developers
create better web sites in less time.
How? Today's web technologies require programming man
y low
-
level details such as database access, connections,
and security. On top of that, developers need to model the data so that it is useful for the solution. The e
-
business
Solution Development Framework for Hyper.Net does all of this for you. That mean
s developers no longer need to
spend time implementing tedious low
-
level details, and can instead spend time developing the features you need
most: the features that improve your business process and make users happy.
Best of all using the Framework is eas
y. If your developers know the basics of programming in .Net, they know how
to create full
-
blown e
-
business solutions based on Hyper.Net. And to make things even easier, all modules of the
Hyper.Net Solution Development Framework come with integrated onlin
e documentation, letting you get started
without formalized education.
Proprietary Information
-
Do Not Distribute
Page
7
Of
59
The Hyper.Net Framework SDK in Detail
We begin by presenting the primary architecture of the HNFSDK, a set of integrated data access tools that combine to
create a ready
-
to
-
use n
-
tier a
pplication architecture that provides object
-
oriented access to Hyper.Net content. This
information will help you determine how to best use the HNFSDK’s varying tools and services to meet your business
needs.
Figure 1
–
HNFSDK Architecture
Figure 1
depicts the HNFSDK architecture, which, as can be seen, has as a backbone forming the “common tools.”
From bottom to top you can find:
1.
FTP Tool
. This component provides additional FTP functionality that enables the Hyper.Net Framework to
support FTP protoc
ol for content transfer. This component can be found in the assembly
Hyper.Net.Framework.Microsoft.Ftp.dll
1
.
2.
SGML to XML Converter
. This component allows the framework to convert any HTML document into a valid
XML or XHTML document. This component can be f
ound in the assembly
Hyper.Net.Framework.Microsoft.Sgml.dll
2
.
3.
Common Tools
. This key component inside the HNFSDK infrastructure contains many classes and functions
shared between all other components. This component can be found in the assembly
Hyper.Net.F
ramework.Common.dll
.
4.
DAL COM+ (Data Access Layer)
. This component is in charge of managing the connection and resources
associated with accessing the Hypermedia Data Storage database (HNHDS). It’s the foundation for all other
components upwards in the Figu
re. It is built into a COM+ component in order to gain all the inherited benefits
of a COM+ application. This component can be found in the assembly
Hyper.Net.Framework.DAL.dll
.
5.
DBL (Data Business Layer)
. This component is responsible for transforming info
rmation coming from the DAL
into representations needed by the upper levels of the Common Tools. The DBL encapsulates all stored procedure
1
This assembly is not formally supported by Coextant because it is based on free .Net code from Microsoft. For further
assistance on this functionality, refer to
http://www.gotdotnet
.com
2
Ibid
.
Proprietary Information
-
Do Not Distribute
Page
8
Of
59
names and parameters, as well as the knowledge needed to transform database responses into meaningful XML
documents.
This component can be found in the assembly
Hyper.Net.Framework.DBL.dll
.
6.
BOM (Business Object Model)
. This object
-
oriented component encapsulates all classes that represent the
information of a document after transformation by the DBL. The result of access
ing Hyper.Net content at the
BOM level is an object
-
oriented representation of publications, topics, metadata, and associated components of
published documents that allows you to build applications that transparently access content without
understanding th
e data model in the HDS. This component can be found in the assembly
Hyper.Net.Framework.BOM.dll
.
7.
The following picture depicts the high
-
level class organization within the BOM. For a complete reference to the
HNFSDK please refer to the help found in the H
NFSDK installation folder.
8.
9.
Figure 2
–
BOM Class Organization
10.
Web.UI
. This component is one of the most powerful components the HNFSDK offers. It is a set of .Net Web
Server Controls that encapsulate almost all the logic behind controls needed to create a
typically web application.
It thus eliminates almost all of the effort needed to communicate directly with the BOM or the database directly,
and provides you with a way to quickly create web applications using drag
-
drop components. You will learn how
to u
se this component, as well as the BOM classes, later on this document. This component can be found in the
assembly
Hyper.Net.Framework.Web.UI.dll
.
11.
AppControls
. This component is also a set of web server controls used for less
-
common tasks required when
bui
lding Hyper.Net web applications. It represents higher levels of logic, and for this reason is considered within
the HNFSDK as application controls. This component can be found in the assembly
Hyper.Net.Framework.Web.UI.AppControls.dll
.
12.
XML SOAP Web Servic
e
. This w3C compliant component allows any other application to connect remotely to
Hyper.Net transformed data, and also provides access to the same data to applications built on non
-
Microsoft
technologies. This component encapsulates all logic from the BO
M and exposes it through an HTTP SOAP
Interface. This component can be found in the virtual directory
Hyper.Net.Framework.Web.Services
, and the
associated assembly
Hyper.Net.Framework.Web.Services.dll
.
13.
Search XML Converter
. This component makes it possible
to pass an XML document as parameter to a web
method from the XML SOAP WS component, and to transform this document into a valid Hyper.Net Object
Oriented Search Definition (HOOSD
3
). This component can be found in the assembly
Hyper.Net.Framework.XmlSearch.dll
.
3
A sample illustrating how to use the HOOSD can be found later in this document.
Proprietary Information
-
Do Not Distribute
Page
9
Of
59
14.
Web.Services.BOM
. This component is based on the Hyper.Net web service interface. It encapsulates all calls to
the server, and instantiates an object oriented class framework to retrieve data, constructs an XML result
doc
ument, and returns it to the calling application, similar to the BOM explained above. This component can be
found in the assembly
Hyper.Net.Framework.Web.Services.BOM.dll
.
a.
Cache Cleaner
. This application is in charge of cleaning up all unused and old entri
es in the Hyper.Net Advanced
Cache System (HACS). The HACS is normally a temporary folder on disk used for fast rendition of content in
any Hyper.Net web application.
b.
Hyper.Net XML Search Definition Tool
. This application provides an easy way to build com
pliant and well
-
formed Hyper.Net XML Files that represent object
-
oriented searches. The files are fed to the web method of the
XML SOAP WS to obtain search results.
c.
Log Viewer
. This application allows you to visualize and browse the log files the Hyper.Net
Framework tracks
while monitoring milestones within the execution of threads.
The HNFSDK provides you with a comprehensive set of tools that allows you to rapidly build any kind of application
for knowledge
-
share using the Hyper.Net infrastructure for doc
ument transformation.
In the following sections we will go a little more deeply into HNFSDK application development concepts, and
describe how to do some quick tricks to achieve the fantastic results.
Before you start, it's a good idea to install and confi
gure Hyper.Net, and then publish a few documents into the
Hypermedia Data Store with it. Once done, you’ll have a little data in your HDS the HNFSDK can access. Refer to
the Hyper.Net Installation and Configuration Guides to do this. After you have publish
ed content, you can start to
follow this guide and develop custom web solutions in accelerated time.
How to Install the Hyper.Net SDK Web Server Controls in
Visual Studio .Net
Please note that the version of the HNFSDK 4.7 is
compiled for the
Microsoft .Net Framework 1.1
and
Visual
Studio .Net 2003
, therefore you’ll need to have these
important pieces installed before continuing.
To make use of the Web GUI components provided by the Hyper.Net Framework, you must setup a toolbar in
Microsoft Vis
ual Studio .Net as shown in
Figure 3
.
Proprietary Information
-
Do Not Distribute
Page
10
Of
59
Figure 3
–
Visual Studio .Net and the Hyper.Net Framework Toolbar
To accomplish this, follow these steps:
1.
Open Visual Studio .Net
2.
Select the Toolbar and right
-
click with the mouse to get the speed menu, and select
“Add Tab.” At the bottom the
pointer will start to flicker at the place where you should insert the name of the Hyper.Net tab. Type:
Hyper.Net
3.
Select the new toolbar tab and right
-
click with the mouse to popup the speed menu again. Select “Add/Remove
Item
s…” in the screen that appears, and select the tab .”Net Framework Components” and then “Browse…” as
shown in
Figure 4
Browse to the installation path
[X]:
\
[Chosen Installation Directory]
\
bin
\
HN_Framework
\
bin
and select the
Hyper.Net.Framework.Web.UI.dll
a
nd
Hyper.Net.Framework.Web.UI.AppControls.dll
assemblies respectively.
4.
At this point, you should be able to see 14 icons in the toolbar, representing the set of Web Server Controls that
this version of the Hyper.Net Framework offers, as above in
Figure 3
.
Proprietary Information
-
Do Not Distribute
Page
11
Of
59
Figure 4
–
Adding the Web GUI Control components to the toolbar
Now that you've added the web server controls to the Visual Studio .Net toolbar, you’re ready to start building a basic
Hyper.Net web application using the HNFSDK.
How to Build a Basic Hyp
er.Net Web Application Using the
Hyper.Net Framework SDK
Web Server Controls for Rapid Web Application Design
The HNFSDK included with Hyper.Net is composed of web server controls found in the
Hyper.Net.Framework.Web.UI.dll
and
Hyper.Net.Framework.Web.UI.A
ppControls.dll
assemblies, as well as the
BOM classes contained in the
Hyper.Net.Framework.BOM.dll
assembly
4
.
The available web server controls are:
Web Server Control
Description
Bookmarks
Displays all the bookmarks related to a Topic. Bookmarks
correspond to bookmark
elements created by the author in the original document.
Content
Displays the content of a
Topic
regardless of the type. Whether the type is text/html,
application/pdf or any other type, it can be d
isplayed with this control.
4
For further reference to this assemblies, refer to the help found in
[
X
]:
\
[
Chosen Installation
Directory
]
\
bin
\
HN_Framework
\
Help
Proprietary Information
-
Do Not Distribute
Page
12
Of
59
JavigatorNavigation
Displays a group of Hyper.Net hierarchical data wrapped around a Java Applet to achieve
a portal
-
like navigation menu system. Content of the navigation system is retrieved using
the
Search
class.
NavigationImage
This Hyper.Net Web Server Control provides the functions needed to navigate thru topics
in a Previous
-
Next fashion.
An image is displayed on the web page.
NavigationLink
This Hyper.Net Web Server Control provides the functions needed to navigate thru topics
in a Previous
-
Next fashion. Text is displayed on the web page.
Subtopics
This Hyper.Net Web Server Control dis
plays either a set of Related or Sub Topics of a
specific
Topic
.
TOC
This Hyper.Net Web Server Contro
l displays the Table of Contents of a publication.
TopicAncestors
This Hyper.Net Web Server Control displays the ancestor links belonging to the current
instance of a
Topic
. This is traditionally used at the top of a displayed topic to allow the
user to simultaneously display the curren
t location within the content, and to allow the
user to click back to parent topics.
TreeViewNavigation
This Hyper.Net Web Server Control displays a group of Hyper.Net hierarchical data
wrapped around a JavaScript TreeView program to achieve a portal
-
like
navigation menu
system. Content of the navigation system is retrieved using the
Search
class.
Download
This Hyper.Net Web Server Control allows the user to download any type of content
contained in the hypermedia data storage; whether transformed content or attached files.
This control will prompt to confirm the download action, and provides a way to
implem
ent download of resources without first launching them in their associated
applications.
Feedback
This Hyper.Net Web Server Control enables any ASP.NET web application to provide a
'feedback' feature. The Hyper.Net.Framework.DAL COM+ component must be
installed
to properly use it.
Recommend
This Hyper.Net Web Server Control enables any ASP.NET web application to provide a
'recommend this site' feature. The Hyper.Net.Framework.DAL COM+ component must
be installed to properly use it.
Subscribe
This Hype
r.Net Web Server Control provides subscribe functionality for your Hyper.Net
web application. The Subscribe control calls the Subscriptions control.
Subscriptions
This Hyper.Net Web Server Control displays a user’s currently configured subscriptions.
This
control can be used either with or without the Subscribe control.
Business Classes for Fast Object
-
Oriented Access to Content
In conjunction with the web server controls mentioned above, the HNFSDK provides a set of business classes as
follows. These
classes allow you to access publications in the Hypermedia Data Store without relational or n
-
tier
programming:
ReaderCollection.
This class
represents a collection of readers that are valid either for a
Topic
or a
Publication
. It
represents reader securit
y for a given topic that comes from the source document or the document management
profile. You cannot create instances of this class. Instead you get instances of ReaderCollection thru instances of
Topic
or
Publication
. This class is essential when implem
enting a secure application.
MetaInfo.
This class represents metadata information about a
Topic
or
Publication
. MetaInfo can be used for
display purposes, or to enrich the application’s capabilities, for example to create customized views, categorize
docum
ents, etc. You cannot create instances of this class. Instead you get instances of MetaInfo thru instances of
MetaInfoCollection
.
MetaInfoCollection.
This class
represents a collection of MetaInfo objects. Each
Publication
and
Topic
may
have null or multip
le metadata originating from the source document, document profile, or content within the
Proprietary Information
-
Do Not Distribute
Page
13
Of
59
document. Use this collection to access all metadata information of a
Topic
or
Publication
using their public
property
MetaInfos
.
Publication.
This class provides a s
et of properties and methods that encapsulate the functionality required to
manage publications. Publications are the containers for
Topic
and
MetaInfo
class instances. You cannot create
instances of this class directly. Instead you get instances of MetaIn
fo thru instances of the
PublicationCollection
class or the
Topic
class.
PublicationCollection.
This class represents a collection of
Publication
objects. These objects are used internally
by the
Topic
class as a static member to maintain references to
Pub
lication
objects shared by multiple
Topic
instances instead of keeping
Publication
separate objects per
Topic
instance. For example multiple
Topics
may be
in the same
Publication
. The same
Publication
object will be referenced by the static
PublicationColl
ection
instance of each
Topic
. You can create instances of this class as a gateway to
Publication
instances.
Search.
This class provides the functionality required to create Hyper.Net Object Oriented Searches (HOOS). The
HOOS creates a custom XML document
that contains the results of searching the Hypermedia Data Store
database. Using HOOS, you are able to search the database without knowledge of the SQL data model, and
without database programming. Searches are built by an object
-
oriented set of static str
uctures found in the
Hyper.Net.Framework.Common.dll
assembly, introduced later in this How
-
To.
Topic.
This class provides a set of properties and methods that encapsulate the functionality required to manage
Topics within publications. You cannot create in
stances of this class, but instead you can receive references of
instances of this class through the
TopicCollection
class. When implemented, there is a specific method of access
to Topics via
TopicCollection
class that is important, and we’ll discuss this later in this How
-
To.
TopicCollection.
This class represents a collection of
Topic
objects. Topics are the primary data element
displayed in web applications built with Hyper.Net. Because this collection is
the gateway to the
Topic
class, and
therefore to other classes within the Business Object Model of the Framework, it is one of the main classes used
in the Framework as well as in this How
-
To. The most common method used with Hyper.Net web/windows
applicat
ion deployments using the HNFSDK is to declare an instance of this class as a static member of any
container web/windows application class. This in turn automatically implements a caching system that eliminates
round trips to the database, boosting the per
formance of your applications. Later on in this How
-
To you’ll learn
how to use it.
Creating an Application Using C#
Here we’ll introduce some of the most commonly used classes of the HNFSDK, as well as common methods that can
be applied to a deployment of
Hyper.Net.
Where to Start?
The best way to start is from the beginning, so let’s start Visual Studio .Net and select “New Project.” Select a C#
project type and the “ASP.NET Web Application” template from the dialog box. Afterwards type “HNAcme” (our
samp
le project name) in the destination location. When Visual Studio .Net has completed the initialization of the new
project, delete the WebForm1.aspx page that is automatically created; we won't be using it.
Consider that ACME Corp., our fictitious big compa
ny customer, must implement an intranet application that
distributes 50 large human resources manuals, including supporting policies and procedures to an employee
community of 30,000. It might be a library of over 3000 pages and 10,000 hypertext topics wit
h supporting PDFs and
forms, all hyperlinked together for easy navigation and access, and hypertext
-
oriented for fast search. We could not
simply post renditions of documents for such an implementation.
Proprietary Information
-
Do Not Distribute
Page
14
Of
59
The Hyper.Net web application we want to create in th
is example will make use of frames to provide a library
-
style
presentation like MSDN, and will be “generic,” meaning it could be used by other departments for other types of
documentation.
To begin, we want to split the page into 3 pieces. The left
-
top sid
e will be dedicated to a search entry form, the left
-
bottom side will be dedicated to a navigation area, and the center area will be dedicated to displaying the Topic
content. Within the center we will enable other controls like previous and next and the a
ncestor control, table of
contents (TOC), Bookmarks and sub/related topics, to provide the user with a rich navigation experience.
Let’s create a start page that will contain the frames. To do so, create a new HTML page and name it “
index.
” Make
sure it l
ooks like the code in
Code
-
Snippet 1
.
Please note that the frames are making reference to three pages that we haven’t created yet. Before moving on to the
design view of Index.htm, let’s create these ASPX pages without any code or controls to satisfy the r
eference. Name
them:
Search.htm
,
MSTreeView.aspx
and
Welcome.htm
respectively.
<!DOCTYPE HTML PUBLIC "
-
//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<TITLE>Hyper.Net
-
ACME Corp.</TITLE>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET
7.0">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</head>
<frameset cols="230,*" border="0" frameSpacing="0" frameBorder="0">
<frameset rows="45,*" border="0" frameSpacing="0" frameBorder="0">
<frame name
="tabindex" src="
Search.htm
" scrolling="no">
<frame name="content" src="
MSTreeView.aspx
" scrolling="auto">
</frameset>
<frame name="main" src="
welcome.htm
" scrolling="auto">
<noframes>
<pre id="p2"></pre>
<p id="p1">
This HTML frameset d
isplays multiple Web pages. To view this frameset, use a
Web browser that supports HTML 4.0 and later.
</p>
</noframes>
</frameset>
</html>
Code
-
Snippet 1
–
Index.htm
Now let’s create the
welcome.htm
page that will help us to introduce our web application whenever it is invoked. In
Visual Studio .Net go to the “Project” menu and select “Add HTML page…” and name it as just mentioned, and make
sure the code looks like
Code
-
Snippet 2
.
<!DOCTYPE HTML PUBL
IC "
-
//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
</HEAD>
<BODY bgcolor="#01478e">
<P><FONT face="Verdana" size="6" color="#ffffff"><STRONG>WELCOME TO HNACME
CORP.</STRONG></FONT></P>
<P> </P>
<P><FONT face="Verdana" size="2" color="#ffffff">This sample application
will help you understand the concepts behind the use of the Hyper.Net Framework
SDK.</FONT></P>
<P><FONT face="Verdana" size="2" color="#
ffffff"></FONT> </P>
Proprietary Information
-
Do Not Distribute
Page
15
Of
59
<P><FONT face="Verdana" color="#ffffff" size="2">You're welcome to
<STRONG>explore/copy/modify</STRONG>this application.</FONT></P>
<P><FONT face="Verdana" color="#ffffff" size="2"></FONT> </P>
<P><FONT face="Verdana" c
olor="#ffffff" size="2">Hyper.Net and Hyper.Net
Framework SDK are trademarks of Coextant Systems International AG.</FONT><br>
<FONT face="Verdana" color="#ffffff" size="2">All rights
reserverd ® 2002
-
2005</FONT></P>
<P><FONT color="#ffffff" siz
e="2"><SPAN class="hnpara"><FONT
face="Verdana"><SPAN class="TextEmph2"><SPAN class="hnoverride" style="FONT
-
SIZE: 9pt;
FONT
-
FAMILY: 'Arial'"></SPAN>
</SPAN></FONT></SPAN></FONT> </P>
<P><FONT color="#ffffff" size="2"><SPAN class="hnpara"><FONT
face=
"Verdana"><SPAN class="TextEmph2"><SPAN class="hnoverride" style="FONT
-
SIZE: 9pt;
FONT
-
FAMILY: 'Arial'">Coextant Systems
International AG<BR></SPAN>
</SPAN>Schönbergstr. 45<BR>
73760 Ostfildern/Stuttgart<BR>
Germany<BR>
Tel: +49 (0
)711 45 10 00 0<BR>
Fax: +49 (0)711 45 10 00 20<BR>
Mail: </FONT><A class="hnoutside"
href="mailto:info@coextant.de" target="_blank">
<FONT face="Verdana"
color="#ffffff">info@coextant.de</FONT></A></SPAN></P>
</FONT>
</BODY>
</HTML>
C
ode
-
Snippet 2
–
Welcome.htm
Bridging the Web Application and the HNFSDK
One of the things we must do to support the infrastructure required by the web server controls is to add references to
HNFSDK assemblies like
Hyper.Net.Framework.Common.dll
5
and
Hyper.Net.Framework.BOM.dll
. Do this before
attempting to continue; in Visual Studio .Net go to “References” and add the references as in
Figure 5
.
Error! Objects cannot be created from editing field codes.
Figure 5
–
Adding the BOM and Common Assemblies
Providing Extra Settings for the HNAcme Web Application
Before going any further, we need to change some settings in the
web.config
file for the web application we are
creating to assure the controls render properly; so let’s add the following
appSettings
section;
Code
-
Snippet 3
shows
these settings.
<
appSettings
>
<
add
key
="AttachmentHandlers"
value
="ignore>ignore"
/>
<
add
key
="LinkedDocumentHandlers"
v
alue
="Autostart.aspx>topic.aspx;../link.aspx>link.aspx"
/>
<
add
key
="ImagePullerForNSM"
value
="src.a
spx"
/>
<
add
key
="WebAppCSAPath"
value
=..”/Content"
/>
<
add
key
="SecurityMode"
value
="NSM"
/>
5
The
Hyper.Net.Framework.Common.dll
assembly contains lots of tools required all along the framework, therefore we need
to reference it in the project. To get an insight into the details of this assembly, refer to the on
-
line help.
Proprietary Information
-
Do Not Distribute
Page
16
Of
59
<
add
key
="ContentDisplayURL"
value
="Topic.aspx"
/>
<
add
key
="TopicContentTarget"
value
="Content"
/>
<
add
key
="ExcludeTopics"
value
="PDF, NativeHTML,
About, Source"
/>
<
add
key
="sqlConnection.ConnectionString"
value
="data source=localhost;initial
catalog=HNHDS;password=password;user id=sa"
/>
</
appSettings
>
Code
-
Snippet 3
–
appSettings Configuration Section
These settings are very important when b
uilding a Hyper.Net web application with the HNFSDK, since they tell the
framework how to work. Let’s take a minute to analyze them.
The
AttachmentHandlers
key makes it possible to override the default attachment
-
displaying ASPX inserted into
published con
tent by Hyper.Net during the transformation process (this is configured in the Hyper.Net Schema for the
document type). By default the value is
source.aspx
. As an example if you don’t what to use the default page but
rather one called
attachments.aspx
, we
can create a rule that tells the framework to convert
source.aspx
into
attachments.aspx
as follows:
…
value
="source.aspx>attachments.aspx" …
Note here that the asp.net names are separated by a “greater than” (>
) symbol, so in this way we build rules for
framework content transformation. In our Acme application we won’t make use of this, so we put
ignore
as the value
for the rule, as in Code
-
Snippet 3.
The
LinkedDocumentHandlers
key is a rule
-
key used like Attach
mentHandlers, but applies to document link
resolution instead. A link handler is a piece of code that takes information from Hyper.Net content about a hyperlink
target, and looks up the target based on certain criteria, which may include user security, loc
ation, language, etc. By
default the Hyper.Net Schema puts the values
Autostart.aspx
and
link.aspx
as default link handlers. To make things
easier, link handlers are implemented as ASPX pages. In the case of Acme, we want to transform the first one into
to
pic.aspx. In the
second one we want to move the relative path of the
link.aspx
to the one shown in the snippet
above. So here we have provided examples of two possible needs and ways to modify these values.
Please refer to the Hyper.Net Configuration Guide to
learn about the Hyper.Net Schema and how to set these
types of handlers. You can find the proper values in the
Hyper.NetConfig.xml
file, in the
Publisher
section inside
the
ConstructionRules
section. It
is out of the scope of
this How
-
To to explain this configuration file and its
sections. If you configure Hyper.Net to use your planned
asp.net pages, you can put the
ignore
keyword in the
HNFSDK configuration entries explained above.
The
ImagePullerForNSM
key tells the HNFSDK which asp.net page to use when retrieving images when the
security mode is set to Non Secure Mode (NSM). NSM is an overall mode that tells a Hyper.Net application that
reader security is not being used, and checks for security can be s
kipped to enhance application performance. In our
case we’ll use the
src.aspx
default page defined in the Hyper.Net Schema.
The
WebAppCSAPath
key tells the framework where to look for the virtual CSA (Content Storage Area) containing
cached content (cached
from the Hypermedia Data Store). For further reference on the CSA refer to the online help.
In our Acme application we indicate that it is one folder up, relative to the path of the HNAcme we are creating, so we
must add a rule that overrides the default
location.
The
SecurityMode
key tells the HNFSDK the kind of security to be used globally. In our case this is NSM (Non
Secure Mode), which means that our Acme application can be publicly navigated and no content is private. Enabling
this mode causes the HN
FSDK to skip all security checks, enhancing application performance. There are other 3
Proprietary Information
-
Do Not Distribute
Page
17
Of
59
security modes as follows:
FSM
(Full Security Mode, security is checked at the Publication and Topic levels),
PSM
(Publication Security Mode, security is checked only a
t the publication level) and
TSM
(Topic Security Mode,
security is checked only at the topic level).
The
ContentDisplayURL
key tells the HNFSDK which page should be used for showing content in the browser. In
our case is the page called
topic.aspx
. We have
n’t created this page yet, but we’ll reach that point soon.
The
TopicContentTarget
setting indicates which frame it implementing the
topic.aspx
page. Since we’re using
frames we need to specify this value in here.
The
ExcludeTopics
key tells the HNFSDK not
to select the mentioned type of topics from the Hypermedia Data
Store. In our case we don’t want the topic types listed above to show up in the web application anywhere.
The
sqlConnection.ConnectionString
key is very important since it tells the HNFSDK wh
ere the Hypermedia Data
Store database (HNHDS) is located. The HNFSDK supports multiple SQL Server databases instances on a single
server, but there is a restriction in the sense that only one connection per application can be used. So you might have
sever
al Hyper.Net web applications hosted in a single sever but targeting different databases.
Proper configuration of these settings ensures you achieve proper behavior of your Hyper.Net application. Now that
we have learned about these fundamental settings, l
et us move forward with our Acme application development effort.
Creating the Acme ASP.Net Pages
Let us complete the pages we started to create in earlier sections. In Visual Studio .Net go to the “Project” menu and
select “Add Web Form…” Name this form
sr
c.aspx
.
In the design view from the toolbar select the tab “Hyper.Net Framework SDK” we created earlier, and drag the
“Content” web server control and drop it into the workspace, make sure everything looks like in
Figure 6
.
Proprietary Information
-
Do Not Distribute
Page
18
Of
59
Figure 6
–
src.aspx
This page
has no code behind, and that’s all we will do to this page. The beauty of this Hyper.Net Web Server Control
(and the others), is that it encapsulates all the logic needed to get the proper content displayed in the browser without
having to write a line of
code.
Let’s now create the
link.aspx
page (it handles dynamic resolution of hyperlinks). Here we’ll see the BOM classes in
action for the first time, and see how easy it is to use them to perform any kind of content operation in an object
oriented way.
In
Visual Studio .Net go to the “Project” menu and select “Add Web Form…” Name this form
link.aspx
, and in the
workspace select the “HTML” view and add the following HTML code:
<
span
id
="span_result"
runat
="server"
style
="FONT
-
SIZE: 8pt; FONT
-
FAMILY: Verdana,
Tahoma, Arial"></
span
>
Keep in mind the name of the span tag id, and remember that it’s set to run at the server side. Later you’ll learn why
we have created this code. Now press
F7
to switch to the code behind view to start to use the
BOM
.
The code you a
re about to write it is one of the most complex you will see in the HNAcme application, and requires
that you have a solid knowledge of how to program with ASP.NET. However if you’re a moderately
-
experienced
developer, you’ll recognize that this piece of c
ode is actually quite easy. It’s a really good sign when the most
complex code is actually the easy stuff.
Make sure your code looks like the shown in the
Code
-
Snippet 4
. Just below we’ll go deeply into the code details
and explain what’s happening.
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
// Program
specifics
using
System.Xml;
// Hyper.Net SDK
using
Hyper.Net.Framework.BOM;
using
Hyper.Net.Framework.Common;
namespace
HNAcme
{
public
class
link : System.Web.UI.Page
{
protected
System.Web.UI.HtmlControls.HtmlGenericControl span_result;
pr
ivate
void
Page_Load(
object
sender, System.EventArgs e)
{
System.Configuration.AppSettingsReader configurationAppSettings =
new
System.Configuration.AppSettingsReader();
string
_topicaspx =
((
string
)(configur
ationAppSettings.GetValue("ContentDisplayURL",
typeof
(
string
))));
string
DOC_UNID = Request.QueryString["DOC_UNID"];
if
(DOC_UNID !=
string
.Empty && DOC_UNID !=
null
)
Response.Redirect(
string
.Format("{0}?DOC_UNID={1}",
_topicaspx, DOC_UNID));
else
Proprietary Information
-
Do Not Distribute
Page
19
Of
59
{
string
DB = Request.QueryString["DB"];
if
(DB !="" && DB !=
null
) DB = DB.Replace( "'", "''" );
string
PT = Request.QueryString["PT"];
if
(PT !="" && PT !=
null
) PT = PT.Replace( "'", "''" );
string
DH = Request.QueryString["DH"];
if
(DH !=""&& DH !=
null
) DH = DH.Replace( "'", "''" );
if
((DH !=
string
.Empty && DH !=
null
) || (PT !=
string
.Empty && PT !=
null
))
{
Search _srch =
new
Search("topic.aspx","Content","NSM",
-
1);
_srch.Searc
hCriteria = publication.IsEffective == 1 &
publication.Audience == "Production";
if
(DH !=
string
.Empty)
_srch.SearchCriteria = _srch.SearchCriteria & topic.Heading == DH;
if
(PT !=
string
.Empty)
_srch.SearchC
riteria = _srch.SearchCriteria & publication.Title == PT;
Hyper.NetField[] _hnfa =
new
Hyper.NetField[4];
_hnfa[0] = topic.TopicID;
_hnfa[1] = topic.Heading;
_hnfa[2] = publication.Title;
_hnfa[3] = publication.Category;
_sr
ch.AddNewOutputNode("Topic",_hnfa,"{0} {1} {2} {3}");
XmlDocument _res = _srch.Execute();
if
(_res.DocumentElement.ChildNodes.Count > 0)
{
XmlNodeList _xndl = _res.SelectNodes("//Topic");
if
(_xndl.Count == 1)
Page.Response.Redirect(
string
.Format("{0}?DOC_UNID={1}",
_topicaspx,
_xndl[0].Attributes["topic_TopicID"].Value));
else
{
span_result.InnerHtml =
string
.Format("<b>{0}</b> documents matching the
criteria were found.<br><br>",_xndl.Count);
H
tmlTable _tbl =
new
HtmlTable();
_tbl.CellSpacing = 5;
_tbl.CellPadding = 2;
_tbl.Width = "100%";
_tbl.Attributes["style"] = "FONT
-
SIZE: 8pt; FONT
-
FAMILY: Verdana";
HtmlTableRow _tblrH =
new
HtmlTableRow();
HtmlTableCell _tblcH1 =
n
ew
HtmlTableCell();
_tblcH1.BgColor = "#dcdcdc";
HtmlTableCell _tblcH2 =
new
HtmlTableCell();
_tblcH2.BgColor = "#dcdcdc";
_tblcH1.InnerHtml = "<b>Document Heading</b>"; _tblcH2.InnerHtml =
<b>Publication Cat
egory</b>";
_tblrH.Cells.Add(_tblcH1);
_tblrH.Cells.Add(_tblcH2);
_tbl.Rows.Add(_tblrH);
foreach
(XmlNode _xnd
in
_xndl)
{
if
(_xnd.Attributes["topic_TopicID"] !=
null
)
{
HtmlTableRow _tblr =
new
HtmlTableRow();
HtmlT
ableCell _tblc1 =
new
HtmlTableCell();
Proprietary Information
-
Do Not Distribute
Page
20
Of
59
HtmlTableCell _tblc2 =
new
HtmlTableCell();
_tblc1.InnerHtml =
string
.Format("<a href=
\
"{0}?DOC_UNID={1}
\
" target=
\
"Content
\
">{2}</a>",
_topicaspx,
_xnd.Attributes["topic_TopicID"].Value,
_xnd.Attributes["topic_Heading"].Value);
if
(_xnd.Attributes["publication_Category"] !=
null
)
_tblc2.InnerHtml =
string
.Format("{0}
\
\
{1}",
_xnd.Attributes["publi
cation_Category"].Value,
_xnd.Attributes["publication_Title"].Value);
_tblr.Cells.Add(_tblc1);
_tblr.Cells.Add(_tblc2);
_tbl.Rows.Add(_tblr);
}
}
span_result.Controls.Add(_tbl);
}
}
else
span_result.InnerHtml = "<font color=
\
"blue
\
">No documents for the current link
were found.<br>Process Terminated.</font>";
}
else
span_result.InnerHtml = "<font color=
\
"red
\
">No parameters found.<br>Process
Terminated.</font>";
}
}
override
protected
void
OnInit(EventArgs e)
{
InitializeComponent();
base
.OnInit(e);
}
private
void
InitializeComponent()
{
this
.Load +=
new
System.EventHandler(
this
.Page_Load);
}
}
}
Code
-
Snippet 4
–
link.aspx code behind
The Code Explained
The first thing to do is the
standard stuff: reference namespaces and other system specifics like the Xml namespace.
That’s at the top in the usual place.
Also, we want to run the code in the Page_Load event, so this will be the only code we need to touch.
The construction rules sect
ion of the primary Hyper.Net configuration file defines the type of query strings that can
are passed to our link handler ASPX. We’ll use those by default, but in a very specialized project you may want to
pass your own query string names. Once more, it’s
out of the scope of this paper dive into those seas, so let’s move
on.
By default the query strings we must take care of are:
DOC_UNID
(Document Unique ID),
DB
(Hypermedia
Database),
PT
(Publication Title) and
DH
(Document Heading).
Proprietary Information
-
Do Not Distribute
Page
21
Of
59
Because the DOC_UNID i
s the most important value, the first thing to do is to see whether it was passed or not, and if
so, redirect immediately to the page with this value. This value will be supplied for example when the link is to
another topic in the same publication. At tra
nsformation time, the target topic id can be determined. That’s what we do
with the following lines of code:
string
DOC_UNID = Request.QueryString["DOC_UNID"];
if
(DOC_UNID !=
string
.Empty && DOC_UNID !=
null
)
{
System.Configuration.AppSettingsReader co
nfigurationAppSettings =
new
System.Configuration.AppSettingsReader();
string
_topicaspx =
((
string
)(configurationAppSettings.GetValue("ContentDisplayURL",
typeof
(
string
))));
Response.Redirect(
string
.Format("{0}?DOC_UNID={1}", _topicaspx, D
OC_UNID));
}
If this value was not passed, it means the target destination must be dynamically computed. This means we need to
look to see whether the other parameters where passed or not and act accordingly. So we have to do some
replacements in these v
ariables and later perform the proper logic. The following lines of code set the other variables
if found.
string
DB = Request.QueryString["DB"];
if
(DB !="" && DB !=
null
) DB = DB.Replace( "'", "''" );
string
PT = Request.QueryString["PT"];
if
(PT !="" &&
PT !=
null
) PT = PT.Replace( "'", "''" );
string
DH = Request.QueryString["DH"];
if
(DH !=""&& DH !=
null
) DH = DH.Replace( "'", "''" );
Now we have to analyze these variables and apply the proper logic. If either of DH or PT has a value we must go to
the
database and search for any document that matches, either by document heading or by publication title, and either
redirect if only one matching target topic is found, or present a summary of matched target topics if more are found.
For that we must create
a Hyper.NetField
6
that must be attached to our Hyper.Net Search object, and define the output
nodes for the XML search result. We do this in the following lines of code.
if
((DH !=
string
.Empty && DH !=
null
) || (PT !=
string
.Empty && PT !=
null
))
{
Search _srch =
new
Search("topic.aspx","Content","NSM",
-
1);
_srch.SearchCriteria = publication.IsEffective == 1 &
publication.Audience == "Production";
if
(DH !=
string
.Empty)
_srch.SearchCriteria = _srch.SearchCr
iteria & topic.Heading == DH;
if
(PT !=
string
.Empty)
_srch.SearchCriteria = _srch.SearchCriteria & publication.Title == PT;
Hyper.NetField[] _hnfa =
new
Hyper.NetField[4];
_hnfa[0] = topic.TopicID;
_hnfa[1] = topic.Heading;
_hnfa[2] = publi
cation.Title;
_hnfa[3] = publication.Category;
_srch.AddNewOutputNode("Topic",_hnfa,"{0} {1} {2} {3}");
XmlDocument _res = _srch.Execute();
...
6
Please refer to the online
help to learn about this and other classes mentioned in this paper.
Proprietary Information
-
Do Not Distribute
Page
22
Of
59
In the code above, we have used for the first time the Search class and other HNFSDK functions to create
a powerful
object
-
oriented search to fulfill our needs.
The rest of the code traverses the resulting XML and dynamically generates HTML to be delivered to the browser.
This does require solid understanding of C#, but is a standard .Net procedure. To save
space and allow us to keep the
examples together, we’ll cut some code from the explanation. If you remember the
span_result
HTML tag we created
before, you’ll find it is used here to present the search result summary. Keep in mind this code runs when mult
iple
link targets have been found. We do this with the following lines of code:
if
(_res.DocumentElement.ChildNodes.Count > 0)
{
XmlNodeList _xndl = _res.SelectNodes("//Topic");
if
(_xndl.Count == 1)
Page.Response.Redirect(
string
.Format("{0}?DOC_UNID={1}", _topicaspx,
_xndl[0].Attributes["topic_TopicID"].Value));
else
{
span_result.InnerHtml =
string
.Format("<b>{0}</b> documents matching the
criteria were found.<br><br>",_xndl.Count);
...
Let’s move onto displa
ying the content of topics.
Creating the Content Area
In Visual Studio .Net go to the “Project” menu and select “Add Web Form…” name this form
Topic.aspx
. This
corresponds to the
ContentDisplayURL
key described above. Now make sure that the HTML view looks
as it does
here in
Code
-
Snippet 5
7
:
<%@ Register TagPrefix="hn4f" Namespace="Hyper.Net.Framework.Web.UI"
Assembly="Hyper.Net.Framework.Web.UI" %>
<%@ Page language="c#" Codebehind="Topic.aspx.cs" AutoEventWireup="false"
Inherits="HNAcme.Topic" %>
<!DOCTYP
E HTML PUBLIC "
-
//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>topic</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScri
pt">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<style>.hnf_ancestor { FONT
-
SIZE: 8pt; COLOR: white; FONT
-
FAMILY: Verdana,
Tahoma, Arial }
.Metadata { FONT
-
SIZE: 8pt; COLOR: white; FONT
-
FAMILY: Verdana, Tahom
a, Arial }
.NavigationLink { FONT
-
SIZE: 9pt; COLOR: white; FONT
-
FAMILY: Verdana }
.hn_ancestor { DISPLAY: none }
.hnancestor { DISPLAY: none }
</style>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="topic" method="post" runat="server">
<
table width="100%">
<tr>
7
If you’re following this guide and have access to the attached source code, the snippets presented here can be skipped for
readability, also if you have the electronic version of this p
aper just copying and paste will make much more sense to you.
Proprietary Information
-
Do Not Distribute
Page
23
Of
59
<td width="85%">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%"
border="0">
<tr height="5%">
<td bgColor="navy" colSpan="3"><font color="#ffffff">Ancestor(s):
<hn4f:topicancestors id="TopicAncestors1"
runat="server" CssClass="hnf_ancestor"
ExcludeEmptyAncestors="False"
LinkSeparator="
-
>" ContentDisplayWebApplication="Topic.aspx"
CssClassName="hnf_ancestor"></hn4f:topicancestors></font></td>
</tr>
<tr>
<td><table style="FONT
-
SIZE: 8pt; FONT
-
FAMILY:
Verdana" width="100%">
<tr>
<td class="hnf_default_font" width="80" bgColor="azure">See Also:</td>
<td bgColor="aliceblue" colSpan="1" rowSpan="1" width="550"><A
class="hnf_default_font" id="lnkTOC" href="#" runat="server">Table
of Contents</A></td>
</tr>
<tr>
<td class="hnf_default_font" colSpan="2"><hn4f:bookmarks id="Bookmarks1"
runat="server" CssClassName="hnf_default_font"></hn4f:bookmarks></td>
</tr>
</table>
</td>
</tr>
<TR height="5%">
<TD vAlign="top" colSpan="3" height="1%"><asp:lab
el id="LblTitle"
runat="server"></asp:label></TD>
</TR>
<TR height="80%">
<TD vAlign="top" colSpan="3"><hn4f:content id="Content1"
runat="server"></hn4f:content></TD>
</TR>
<tr height="5%">
<td bgColor="navy" colSpan="1"><span style="COLOR: white"><
hn4f:navigationlink
id="NavigationLink1" runat="server" ContentDisplayWebApplication="topic.aspx"
CssClassName="NavigationLink"
MoveTo="Previous" Font
-
Italic="True"
ForeColor="White">Previous</hn4f:navigationlink></span></td>
<td align="right" bgColor="n
avy" colSpan="2"><span style="COLOR:
white"><hn4f:navigationlink id="Navigationlink2" runat="server"
ContentDisplayWebApplication="topic.aspx" CssClassName="NavigationLink"
Font
-
Italic="True" ForeColor="White">Next</hn4f:navigationlink></span></td>
</tr>
</TABLE>
</td>
<td width="15%">
<table width="100%" height="100%">
<tr height="50%">
<td valign="top"><hn4f:Subtopics id="Subtopics3" runat="server"
TopicContentDisplayURL="topic.aspx"></hn4f:Subtopics></td>
</tr>
<tr height="50%">
<td valign="to
p"><hn4f:Subtopics id="Subtopics2" runat="server"
TopicContentDisplayURL="topic.aspx" RenderTopicFor="Subtopics"></hn4f:Subtopics></td>
</tr>
</table>
Proprietary Information
-
Do Not Distribute
Page
24
Of
59
</td>
</tr>
</table>
</form>
</body>
</HTML>
Code
-
Snippet 5
–
Topic.aspx HTML view
Since we’ve alr
eady seen how to drag and drop the controls, we’ll skip that description at this point. Note that in the
code snippet above, already included are all the required Hyper.Net web server controls we need to make this central
frame work.
The result of the code above should be something like shown in
Figure 7
.
Figure 7
–
Topic.aspx in design view
Let’s take a minute to understand what this page does. As you might have realized by now, we didn’t write any
complex code, which means that
all the hurdles of building complex applications with Hyper.Net content has been
made easy for you. But we still have to make some small changes in the code behind of the page to accomplish little
details like telling the TOC link where to go, and where to
put the Heading of the displayed topic. As you will see it’s
quite simple. Put the following code snippet in the code behind of the page:
...
private static TopicCollection _tpc = new TopicCollection();
private void Page_Load(object sender, System.EventAr
gs e)
{
string js =
Proprietary Information
-
Do Not Distribute
Page
25
Of
59
string.Format("javascript:window.open('TOC.aspx?DOC_UNID={0}','TOC','titlebar=no,toolb
ar=no,scrollbars=yes,status=no,resizable=no,width=600,height=600')",Request.QueryStrin
g["DOC_UNID"]);
lnkTOC.Attributes["onclick"]=js;
Topic _t
p = _tpc.GetTopic(Request.QueryString["DOC_UNID"]);
lbHeading.InnerText = _tp.Heading; // setting the heading.
} ...
Code
-
Snippet 6
–
Topic.aspx code behind
Next we’re configuring the controls we just placed and coded. We must do a few important things
to wind up the
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Comments 0
Log in to post a comment