[dbo].[addonContactFormEntries]
[Id] [int] IDENTITY(1,1) NOT NULL,
[FullName] [nvarchar](max) NOT NULL,
[Telephone] [nvarchar](max) NOT NULL,
[Company] [nvarchar](max) NOT NULL,
[Reason] [nvarchar](max) NOT NULL,
The following IUIOMaticModel:
[UIOMatic("Contact Form", "icon-users", "icon-user")]
[TableName("addonContactFormEntries")]
public class ContactFormUI : IUIOMaticModel
{
public ContactFormUI() { }
[UIOMaticIgnoreField]
[PrimaryKeyColumn(AutoIncrement = true)]
public int Id { get; set; }
[UIOMaticField("Full Name", "Enter the persons full name")]
public string FullName { get; set; }
[UIOMaticField("Telephone", "Enter the persons telephone")]
public string Telephone { get; set; }
[UIOMaticField("Company", "Enter the persons Company")]
public string Company { get; set; }
[UIOMaticField("Reason", "Enter the persons Reason")]
public string Reason { get; set; }
public override string ToString()
{
return FullName;
}
public IEnumerable<Exception> Validate()
{
var exs = new List<Exception>();
if (string.IsNullOrEmpty(Reason))
exs.Add(new Exception("Please provide a value for first name"));
return exs;
}
}
Now the URL it goes to when I click on the Contact Form link is:
When I try to view the entries (of which there are some in the table) I get:
Received an error from the server
Failed to retrieve data for child nodes undefined
Object reference not set to an instance of an object.
EXCEPTION DETAILS:
System.NullReferenceException: Object reference not set to an instance of an object.
STACKTRACE:
at UIOMatic.Controllers.PetaPocoObjectController.<GetAll>d__6.MoveNext()
at UIOMatic.Trees.UIOMaticTreeController.GetTreeNodes(String id, FormDataCollection queryStrings)
at Umbraco.Web.Trees.TreeControllerBase.GetNodes(String id, FormDataCollection queryStrings)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
Am I missing something, I've checked the docs. I'm running the latest version. Installed with Nuget.
I copied the one from the example and created the table in the Umbraco database..
using System;
using System.Collections.Generic;
using PetaPoco;
using UIOMatic.Attributes;
using UIOMatic.Enums;
using UIOMatic.Interfaces;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace HYSW.Models
{
[UIOMaticAttribute("People","icon-users","icon-user")]
[TableName("People")]
public class Person: IUIOMaticModel
{
public Person() { }
[UIOMaticIgnoreField]
[PrimaryKeyColumn(AutoIncrement = true)]
public int Id { get; set; }
[UIOMaticField("First name","Enter the persons first name")]
public string FirstName { get; set; }
[UIOMaticField("Last name", "Enter the persons last name")]
public string LastName { get; set; }
[UIOMaticField("Picture", "Select a picture", View = "file")]
public string Picture { get; set; }
public override string ToString()
{
return FirstName + " " + LastName;
}
public IEnumerable<Exception> Validate()
{
var exs = new List<Exception>();
if(string.IsNullOrEmpty(FirstName))
exs.Add(new Exception("Please provide a value for first name"));
if (string.IsNullOrEmpty(LastName))
exs.Add(new Exception("Please provide a value for last name"));
return exs;
}
}
We are using the PetaPoco database in some views and its working.
/****** Object: Table [dbo].[People] Script Date: 2015-12-03 13:36:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[People](
[Id] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [nvarchar](255) NOT NULL,
[LastName] [nvarchar](255) NOT NULL,
[Picture] [nvarchar](255) NOT NULL
) ON [PRIMARY]
GO
Ah yes that might be the issue, it might be fetching the TableName attribute from the wrong namespace, make sure like Ryan mentoins it coming from Umbraco.Core.Persistence;
using System;
using System.Collections.Generic;
using System.Web.DynamicData;
using UIOMatic.Attributes;
using UIOMatic.Interfaces;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace HYSW.Models
{
[UIOMatic("SignUp", "icon-users", "icon-user")]
[Umbraco.Core.Persistence.TableName("People")]
public class Person : IUIOMaticModel
{
Thought I would give the package a try (it's a great idea for simple tables!) but I get a variant of the error described here:
Using Umbraco 7.3.8. Note that we are using an Angular frontend and have a lot of controllers extending the UmbracoApiController for our web app. It is a theoretical possibility that this interferes with routing, but this should be fixed since we had a problem with indexing not working which we did some config to get working again.
Received an error from the server
Failed to retrieve data for child nodes undefined
Cannot perform runtime binding on a null reference
EXCEPTION DETAILS:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
STACKTRACE:
at CallSite.Target(Closure , CallSite , Object , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at UIOMatic.Trees.UIOMaticTreeController.GetTreeNodes(String id, FormDataCollection queryStrings)
at Umbraco.Web.Trees.TreeControllerBase.GetNodes(String id, FormDataCollection queryStrings)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UIOMatic.Attributes;
using UIOMatic.Interfaces;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace cms7_0_1.Models
{
//[UIOMaticAttribute("Pocotest", "icon-users", "icon-user", ReadOnly = true)]
[UIOMaticAttribute("Pocotest", "icon-users", "icon-user")]
[TableName("braPocoTest")]
public class PocoTest : IUIOMaticModel
{
[UIOMaticIgnoreField]
[PrimaryKeyColumn(AutoIncrement = true)]
public int id { get; set; }
[UIOMaticField("value", "Enter the value")]
public string value { get; set; }
public override string ToString()
{
return id + ": - " + value;
}
public IEnumerable<Exception> Validate()
{
var exs = new List<Exception>();
return exs;
}
}
}
Works on my simple testclass (which I tried out because I wanted to reduce test compexity). Trying my real life class now and get the same error.
Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UIOMatic.Attributes;
using UIOMatic.Interfaces;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace cms7_0_1.Models
{
[UIOMaticAttribute("Bestillinger", "icon-users", "icon-user", ReadOnly = true)]
[TableName("braBestillingsPakke")]
public class BestillingsPakke : IUIOMaticModel
{
[UIOMaticIgnoreField]
[PrimaryKeyColumn(AutoIncrement = true)]
public int ID_BestillingsPakke { get; set; }
[UIOMaticField("[FR_Member]", "Enter the memberId ")]
public int FR_Member { get; set; }
[UIOMaticField("Startdato", "Skriv inn startdato", View = "datetime")]
public DateTime StartDato { get; set; }
[UIOMaticField("Sluttdato", "Skriv inn sluttdato", View = "datetime")]
public DateTime SluttDato { get; set; }
[UIOMaticField("[PakkeType]", "Skriv inn PakkeId")]
public int PakkeType { get; set; }
[UIOMaticField("[OpprettetDato]", "Skriv inn opprettet dato")]
public DateTime OpprettetDato { get; set; }
public override string ToString()
{
return ID_BestillingsPakke + " - " + FR_Member;
}
public IEnumerable<Exception> Validate()
{
var exs = new List<Exception>();
return exs;
}
}
}
That what happened with me after install ui-o-matic on umbraco v 7.5.3 and run the application and navigate to back-office >>[uiomatic]
An error occured
Object reference not set to an instance of an object.
EXCEPTION DETAILS
System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext)
at Umbraco.Web.Trees.ApplicationTreeController.
=========
my code like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UIOMatic.Attributes;
using UIOMatic.Enums;
using UIOMatic.Interfaces;
using Umbraco.Core.Persistence;
namespace Ta2heal.Web.Models.UIOMatic
{
[Umbraco.Core.Persistence.TableName("ta2healCountry")]
[Umbraco.Core.Persistence.PrimaryKey("Id")]
[UIOMatic("Country", "icon-box-open", "icon-box-open", RenderType = UIOMaticRenderType.List, ConnectionStringName = "umbracoDbDSN")]
public class Country : IUIOMaticModel
{
[UIOMaticIgnoreField]
[Column("Id")]
public int Id { get; set; }
[Column("Name")]
public string Name { get; set; }
[Column("IsActive")]
public bool IsActive { get; set; }
public IEnumerable<Exception> Validate()
{
//add validation rules here
return new List<Exception>();
}
}
}
Failed to retrieve data for child nodes undefined
I have a table with the following structure:
The following IUIOMaticModel:
Now the URL it goes to when I click on the Contact Form link is:
When I try to view the entries (of which there are some in the table) I get:
Am I missing something, I've checked the docs. I'm running the latest version. Installed with Nuget.
Fixed: When I picked the namespaces to include I picked:
rather than
Comment author was deleted
Ah great, thanks for posting the solution!
Hi,
Even though I have the "using Umbraco.Core.Persistence.DatabaseAnnotations" in my code, I get the same error..
Received an error from the server Failed to retrieve data for child nodes undefined
Object reference not set to an instance of an object.
EXCEPTION DETAILS:
System.NullReferenceException: Object reference not set to an instance of an object. STACKTRACE:
at UIOMatic.Controllers.PetaPocoObjectController.
Can you post your entire class and I'll have a look?
Comment author was deleted
Yup if you post your entire class (including the using statements) we can have a look :)
Hi Tim and Ryan,
I copied the one from the example and created the table in the Umbraco database..
We are using the PetaPoco database in some views and its working.
//Jonas
Comment author was deleted
SO your peta poco table is in a different db?
No, sorry I wrote "Peta Poco database" its in the Umbraco database as you see from the Screenshot. Just below the cmsTemplate table.
Comment author was deleted
If that is the case, UI-O-Matic needs to know about it so you need to update the attribute
Comment author was deleted
Ok well don't spot an issue with your table or class, any chance you can drop the create script for the table here then I can try to duplicate
Also I'll expect you'll want to include
That is required when using the [TableName] , at least for me.
Comment author was deleted
Ah yes that might be the issue, it might be fetching the TableName attribute from the wrong namespace, make sure like Ryan mentoins it coming from Umbraco.Core.Persistence;
Hi,
If i insert
Resharper tells me to use
instead.
Use both.
Finally got it thanks....
Comment author was deleted
Ah great, it's working now! Let me know if there are any other issues.
Hi Tim, thanks alot for the help. It is a fantastic package and saves us a lot of time.
I have a couple of feature questions. Where can I send them?
Comment author was deleted
@Jonas just create a new forum topic and I'll reply there :) glad you like it!
Hi.
Thought I would give the package a try (it's a great idea for simple tables!) but I get a variant of the error described here:
Using Umbraco 7.3.8. Note that we are using an Angular frontend and have a lot of controllers extending the UmbracoApiController for our web app. It is a theoretical possibility that this interferes with routing, but this should be fixed since we had a problem with indexing not working which we did some config to get working again.
I can provide the whole stack trace if necessary.
My DB table looks like this:
And my class looks like this:
Comment author was deleted
Hi Jørgen a full stack trace would be useful! Thanks
Also could you tell me the Umbracco version you are running this on?
Will then try to replicate the issue.
Cheers, Tim
Updated the original post now.
Comment author was deleted
Ok thanks for the update will give your code a spin
Comment author was deleted
Ok I get the same behaviour, checking the issue now and will report back a bit later
Ok, great!
Always good to know that the issue can be reproduced :-)
Comment author was deleted
Seems it's due to the column names and properties starting with a lowercase char, so looks like you found a bug :) fixing now
What's my price? What's my price? ;-)
Comment author was deleted
You'll receive this wonderfull bug hunter hat :p
That will rule the after ski this winter :-D
Comment author was deleted
Ok found a fix, just testing now and will release a new version in a couple of moments
Comment author was deleted
New release is building...
Comment author was deleted
OK 1.6.3 is out fixing the lowercase propname issue
Get it while it's hot: https://www.nuget.org/packages/Nibble.Umbraco.UIOMatic/
You should just be able to use nuget to upgrade, let me know if that fixes the issue and if you have any further questions.
Cheers, Tim
Works! Good job and very quick response! Thanks a lot!
Comment author was deleted
Sweet, thanks for confirming!
Works on my simple testclass (which I tried out because I wanted to reduce test compexity). Trying my real life class now and get the same error.
Class:
Table:
Some typo I can't see or a variant of the bug?
Comment author was deleted
Hmmm strange, will give it a shot
Comment author was deleted
Ok can reproduce, thinking it's the underscores, trying to fix now
Comment author was deleted
Ok found a fix, it's due to the id column not being named Id, stupid bug that got introduces by merging a pull request doh, building new version now
Comment author was deleted
Version 1.6.4 is out fixing this issue, again just upgrade using nuget
Works! Excellent! Have a nice weekend!
Comment author was deleted
Same to you!
That what happened with me after install ui-o-matic on umbraco v 7.5.3 and run the application and navigate to back-office >>[uiomatic]
An error occured
Object reference not set to an instance of an object.
EXCEPTION DETAILS
System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext) at Umbraco.Web.Trees.ApplicationTreeController.
=========
my code like this:
what can I do??
is working on a reply...