1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Framework
.ViewComponents
18 using System
.Collections
;
22 /// Renders the contents of the block component into the $childContent context
23 /// variable, and then renders the components view file.
28 /// #blockcomponent(ChildContentComponent)
29 /// This will be rendered inside a div tag.
33 /// ViewComponent view:
35 /// <div>$componentChildContent</>
38 public class ChildContentComponent
: ViewComponent
40 private readonly String EntryKey
= "componentChildContent";
43 /// Obtains the content of the child.
45 protected virtual void ObtainChildContent()
47 StringWriter writer
= new StringWriter();
49 Context
.RenderBody(writer
);
51 Context
.ContextVars
[EntryKey
] = writer
.ToString();
55 /// Populates the context.
57 protected void PopulateContext()
59 foreach(DictionaryEntry
value in ComponentParams
)
61 Context
.ContextVars
[value.Key
] = value.Value
;
66 /// Called by the framework so the component can
67 /// render its content
69 public override void Render()
71 RenderView("default");
75 /// Specifies the view to be processed after the component has finished its processing.
77 /// <param name="name"></param>
78 protected new void RenderView(string name
)
83 base.RenderView(name
);
87 /// Specifies the view to be processed after the component has finished its processing.
89 /// <param name="component"></param>
90 /// <param name="name"></param>
91 protected new void RenderView(string component
, string name
)
96 base.RenderView(component
, name
);