dotnetage widget development

Aug 14, 2013 at 1:04 AM
Thanks for posting tutorial of how to create widget.

My question is that how we create widget that has controller , models, views. these are separate layers (pure MVC) implementation. please provide me a guide line how do i create this widget.

Thanks
Coordinator
Aug 14, 2013 at 2:48 AM
I will post that article today, pure MVC mode is not the best way for the widgets. "More Dependency comes with lower Compatibility". The strongly type widget was the feature of the DotNetAge and it's still available now. You just need to place a "Widget" attribute on your Action method then that action will become a "Widget Action".

Then in your widget config.xml add the preference to specified the controller, action and area just below:
<preference name="controller" value="Your controller full name" />
<preference name="action" value="Your action name" />
<preference name="area" value="If is exists" />

But when you done ,you will find your widget can be share without assembly, that is not good for you. My recommend way is : View Only Widget + WebPI , you will find widget is best SPA container in DotNetAge3
Coordinator
Aug 14, 2013 at 2:54 AM
The Widget is a part of the webpage and it's a standalone app. Widget's has their router so the pure MVC's signification is not so important. You doesn't need controller anymore.
Aug 15, 2013 at 12:26 AM
Thanks for give me good guideline.

I am facing this error messages in resources is not find "Resources.Messages" .
AppModel.Get().NetDrive.ReadLines in this ReadLines not found? how i resolve these errors

how can i use jquery in my widget? Is it simple as simple in using in MVC/webform application?
Coordinator
Aug 15, 2013 at 1:02 AM
Oh, i'm sorry, Resources.Messages and NetDrive.ReadLines are added in v3.0.1. But i only release the v3.0.0. So you go that errors. But don't worry about that this weekend v3.0.1 will be released.

About jQuery:
you can place the code below in your widget that is also can use in any view
<script type="javascript"> $(function(){ // you script here. }); </script> DotNetAge build on jQuery so you can use jQuery anywhere and without reference it.
Aug 15, 2013 at 10:47 PM
in previous discussion you had write "But when you done ,you will find your widget can be share without assembly, that is not good for you. My recommend way is : View Only Widget + WebPI , you will find widget is best SPA container in DotNetAge3"

Did you mean by "View Only Widget + WebAPI" or "View Only Widget + WebPI" ?

Its confusing for me.
Coordinator
Aug 16, 2013 at 2:06 AM
"WebAPI" & "WebPI" are same my means "Restful API". Mm.... "WebAPI" maybe make you think other web service.
Aug 17, 2013 at 10:01 AM
Edited Aug 17, 2013 at 10:04 AM
Thanks for guiding me. i have a real estate website http://www.gtarealestates.com . i want to convert this site in dotnetage. i have some question

1- how can i create register user dashboard ?
2- how can i create new content type for some little functionality like( add to favorite,, previous history of user,......) and how i use these content types in widget.
3- In this site i have a property listing. All the property listing have a detail page.All the data of listing is coming from the csv file in db. how can i create detail page of the listing have a separate friendly URL .
4- Is it possible that all property listing is save through code (timer service) in content type and how i use these content types in widget.

5- how can i create search depending on the fields(address,price, type,....) of the property listing( if i use content type ).
Coordinator
Aug 17, 2013 at 11:25 AM
1.DotNetAge is base on MVC so you can use MVC page to complete your job but not dashboard page. Dashboard page is a special kind of pages used for settings.
DotNetAge is widget-driven platform but not page-driven, you should create a register widget because it can be create once and use anywhere.
  1. To resolve your points 2,3,5 the following video maybe help : http://www.dotnetage.com/home/en-US/quickstart/2013/07/30/custom-fields-for-your-products.html.
    Please understand what's content type and what it's should do for you first.
  2. To create dataItem by code:
var list=AppModel.Get().CurrentWeb.List["Your list name"];

//The data item is a dynamic object and it will be auto map the property value to the field which has same name.
//For example you create a contentType list that has "title,desc,price" fields

list.NewItem(new {
title="Some text",
desc="some description",
price=123
});
Aug 18, 2013 at 11:53 PM
Edited Aug 19, 2013 at 12:05 AM
Thanks for helping me allot.

i am facing an other issue .
1- I have a console application that gets data from CSV files. i want to insert this data in content type.

but i am unable to accessing the webs,

using DNA.Data;
using DNA.Mvc.ServiceModel;

var lst = AppModel.Get().Webs["http://localhost:8081"]; var lst = AppModel.Get().Webs["localhost:8081"];

object reference error. how can i access my web for inserting data in lists?

2- How can i create search ? is there any widget that create search page for me or i can create search page through content type views (edit source code section) ?

3- Is it possible to give different url of detail page that we create from the content type(products) .

Below is default url of detail page.
http://localhost:8081/home/en-US/news/2013/08/18/news1.html

I want this url ?
http://localhost:8081/news/news1.html

is it possible to change url through code/through CMS/through web config settings, our any other way.
Coordinator
Aug 19, 2013 at 12:12 AM
Edited Aug 19, 2013 at 12:49 AM
HI : Here there you made a mistake :
  1. AppModel only allow use in DotNetAge main thread. So you can’t use it in console application outside the ASP.net MVC thread. You should add a controller in DotNetAge website to instead.
  2. AppModel.Get().Webs[“This is web site name”] for eample
    var web=AppModel.Get().Webs[“home”] ; //returns the web instance for “/home”
  3. The item route URL is fixed and resolved because it’s user friendly and SEO. But you also can create a page that name “news1” and place the DataView contain to display the view data.
BTW:The URL means : http://youDomain/website-name/locale/list-Name/pub-year/pub-month/pub-day/item-name.html

In document I will post a new article to explain all the resolved URL for Page, View, Form and Items.

Here I have another example for you I hode it can be help:

public ActionResult InsertANews()
{
var web=AppModel.Get().CurrentWeb; //Get current web instance default is home 
var list=web.Lists[“news”]; //Get your 
list instance list.NewItem(new { title=”This is the first news”, body=”Here is the new body”. }); 
return new HttpCodeResult(200); 
}
Aug 19, 2013 at 9:35 AM
Thanks for helping me.

As you said that "AppModel only allow use in DotNetAge main thread" . how can I insert data in list through Console application? i am unable to get webs from console application.
Coordinator
Aug 19, 2013 at 11:28 AM
Could you see the "InsertANews()" method in my last post ?
If you must use console application pls consider to use HttpWebClient to request the InsertANew() method through HTTP request.
Aug 25, 2013 at 12:14 AM
Thanks for you quick replays.

How i create controller/Web API in dotnetage for accessing it through HTTP request?
May i create this controller/Web API on the root of the project.

Is it possible to send me some example?

usmanhabeebq@gmail.com is my email id.

i am creating some timer job that will insert data in the list.The timer job is on my system and dotnetage site is on the hosting.Timer job will insert data on the hosting machine. thats why i need controller/web API.

May i use out of the box WebApi for inserting data in list through timer Job(console application). if yes ,then how.

Is it possible to create multiple sites through dotnetage?
Coordinator
Aug 25, 2013 at 1:10 AM
Oh, i see.
  1. Could you pls wait for days that i will post the Restful API documents for ContentTypes
  2. DotNetAge can create multiple sites but in Community Edition only allow create home site.
Aug 25, 2013 at 8:11 AM
dotnetage has some paid version also ?
Coordinator
Aug 25, 2013 at 8:21 AM
Yes we will be offer a commercial version when it stable