C# 클래스 Castle.MonoRail.Framework.ViewComponent

Base class for reusable UI Components.
Implementors should override ViewComponent.Initialize for implement proper initialization (if necessary). Also implement ViewComponent.Render as by default it will render a default view on [ViewFolderRoot]/components/[componentname].

You can also override ViewComponent.SupportsSection if your component supports neste sections (ie templates provided on the view that uses the view component.

Another way is to use the ViewComponentDetailsAttribute to specify a custom name and the sections supported.

Notice that view components can render strings or views on their folder. You can create sophisticate components with that mixture. Sections allow the users of your component to give it a block of content, usually customizing or definiting the content to be especially rendered by your component.

A very simplist view component that renders the time. public class ShowTime : ViewComponent { public override void Initialize() { } public override void Render() { RenderText("Time: " + DateTime.Now.ToString()); } }

This can be used from the view using the following syntax (NVelocity view engine)

#component(ShowTime)
파일 보기 프로젝트 열기: nats/castle-1.0.3-mono 1 사용 예제들

공개 메소드들

메소드 설명
Init ( IRailsEngineContext engineContext, IViewComponentContext componentContext ) : void

Invoked by the framework.

Initialize ( ) : void

Called by the framework once the component instance is initialized

Render ( ) : void

Called by the framework so the component can render its content

SupportsSection ( string name ) : bool

Implementor should return true only if the name is a known section the view component supports.

보호된 메소드들

메소드 설명
CancelView ( ) : void

Cancels the view processing.

HasSection ( String sectionName ) : bool

Determines whether the current component declaration on the view has the specified section.

RenderBody ( ) : void

Renders the component body.

RenderBody ( TextWriter writer ) : void

Renders the body into the specified TextWriter

RenderSection ( String sectionName ) : void

Renders the the specified section

RenderSection ( String sectionName, TextWriter writer ) : void

Renders the the specified section

RenderSharedView ( String name ) : void

Specifies the shared view to be processed after the component has finished its processing. (A partial view shared by others views and usually in the root folder of the view directory).

RenderText ( String content ) : void

Renders the specified content back to the browser

RenderView ( String name ) : void

Specifies the view to be processed after the component has finished its processing.

RenderView ( String component, String name ) : void

Specifies the view to be processed after the component has finished its processing.

비공개 메소드들

메소드 설명
BindComponentParameters ( ) : void

Binds the component parameters.

BindParameter ( ViewComponentParamAttribute paramAtt, PropertyInfo property, IConverter converter ) : void
GetBaseViewPath ( ) : String
GetBaseViewPath ( String componentName ) : String

메소드 상세

CancelView() 보호된 메소드

Cancels the view processing.
protected CancelView ( ) : void
리턴 void

HasSection() 보호된 메소드

Determines whether the current component declaration on the view has the specified section.
protected HasSection ( String sectionName ) : bool
sectionName String Name of the section.
리턴 bool

Init() 공개 메소드

Invoked by the framework.
public Init ( IRailsEngineContext engineContext, IViewComponentContext componentContext ) : void
engineContext IRailsEngineContext Request context
componentContext IViewComponentContext ViewComponent context
리턴 void

Initialize() 공개 메소드

Called by the framework once the component instance is initialized
public Initialize ( ) : void
리턴 void

Render() 공개 메소드

Called by the framework so the component can render its content
public Render ( ) : void
리턴 void

RenderBody() 보호된 메소드

Renders the component body.
protected RenderBody ( ) : void
리턴 void

RenderBody() 보호된 메소드

Renders the body into the specified TextWriter
protected RenderBody ( TextWriter writer ) : void
writer System.IO.TextWriter The writer.
리턴 void

RenderSection() 보호된 메소드

Renders the the specified section
protected RenderSection ( String sectionName ) : void
sectionName String Name of the section.
리턴 void

RenderSection() 보호된 메소드

Renders the the specified section
protected RenderSection ( String sectionName, TextWriter writer ) : void
sectionName String Name of the section.
writer System.IO.TextWriter The writer.
리턴 void

RenderSharedView() 보호된 메소드

Specifies the shared view to be processed after the component has finished its processing. (A partial view shared by others views and usually in the root folder of the view directory).
protected RenderSharedView ( String name ) : void
name String
리턴 void

RenderText() 보호된 메소드

Renders the specified content back to the browser
protected RenderText ( String content ) : void
content String The content to render.
리턴 void

RenderView() 보호된 메소드

Specifies the view to be processed after the component has finished its processing.
protected RenderView ( String name ) : void
name String
리턴 void

RenderView() 보호된 메소드

Specifies the view to be processed after the component has finished its processing.
protected RenderView ( String component, String name ) : void
component String
name String
리턴 void

SupportsSection() 공개 메소드

Implementor should return true only if the name is a known section the view component supports.
public SupportsSection ( string name ) : bool
name string section being added
리턴 bool