26 May 2011
03 Jun 2011
Link to this post
I have hard time to build custom module following the sample example of products module, and I have been looking for solution by reading the forum and blogs but could not find very good solution, it looks like I am not alone for this problem. I have a few questions and I will base them on the products module since it is the model people wants to follow.
1. How does the data mapping works in the backend module? e.g. the price field in the main section(prodcutsDefinitions.cs), a TextFieldDefinitionElement is created with DataFieldName set to "Price", how is this used to map the content of the text field to dataprovider and eventually saved in sitefinity database? I can set the breakpoint in ProductItem.cs and see the value has been set in productItem's Price property but could not get any call stack information. Could you explain the code flow and how the content from definition fields been saved?
2. I was trying to add a image field to the module. I add an Image member variable to ProductItem class the same way as "Price" but with the type of "Image", and add a imageFieldElement to show/load image, but it gives me the following error:
[MetadataException: No database type mapping found for field 'image': CLR type 'Telerik.Sitefinity.Libraries.Model.Image' or column type '' unmapped. ]
OpenAccessRuntime.Relational.metadata.RelationalMappingResolver.resolveMapping(RelationalJavaTypeMapping fieldMapping, String fieldName, Class javaType, Boolean complain) +437
OpenAccessRuntime.Relational.RelationalMetaDataBuilder.createColumn(DataObjectsExtension nested, String fieldName, Class javaType, String oType, Boolean secondaryTable) +49
OpenAccessRuntime.Relational.RelationalMetaDataBuilder.createJdbcSimpleField(FieldMetaData fmd) +173
OpenAccessRuntime.Relational.RelationalMetaDataBuilder.createJdbcField(FieldMetaData fmd, Boolean quietParam) +69
[MetadataException: The metadata for field 'image' of class 'Products.Model.ProductItem' cannot be initialized: No database type mapping found for field 'image': CLR type 'Telerik.Sitefinity.Libraries.Model.Image' or column type '' unmapped. ]
Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Master.MasterGridView.OnInit(EventArgs e) +369
System.Web.UI.Control.InitRecursive(Control namingContainer) +140
System.Web.UI.Control.AddedControl(Control control, Int32 index) +197
System.Web.UI.ControlCollection.Add(Control child) +79
Telerik.Sitefinity.Web.UI.ContentUI.ContentView.LoadView(String viewName) +301
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
What should I do to implement this? Some sample code would be appreciated.
3. How to create more complex UI for backend view? Sitefinity provides some nice out of box fields we can use, but most of time, we need more complex UI, what should we do? How does the data binding work in this situation assume we need to create a user control (.ascx) for the complex UI? Exact steps with explanation would be good.