I'm working on converting NerdDinner to Spark and have everything except the mobile views (which I'm not worrying about) and some code that uses Page. Here is one of the locations that is hanging up - but there are a couple of others due to the View not having a Page ...
In asp.net mvc the code looks like this:
<link rel="Stylesheet" type="text/css" href="<%=Page.ClientScript.GetWebResourceUrl(typeof(DotNetOpenAuth.OpenId.RelyingParty.OpenIdSelector), "DotNetOpenAuth.OpenId.RelyingParty.OpenIdSelector.css")%>" />
The "Page.ClientScript.GetWebResourceUrl" call fails with an error about there not being a Page. Is this true?
I've worked around this one with adding an action that will return the resource as a FileStreamResult ... but there is another call using an open auth library that has a constraint check for a Page object ... so it fails due to the same problem - and unless I hack that code, I can't seem to find away around it. Is there anyway to get a Page in a Spark View?
In my project that uses Spark I am retrieving resources by use of a handler.
In reference to the other call, no there is no Page. A Page object is actually just a special HttpHandler that renders the markup to the response. So since MVC uses a different handler to create the Controller and render the View, there is no Page handler.
I would think the Open Auth library needs to be updated to work better with MVC.
Related
I know that the webpage that is opened by the user is part of the view. This one is easy, but what about js code calling the server to retrieve data via ajax? Is this part of the controller or still the view?
Can the view request data like this?
Thank you very much for any help.
Javascript, including Ajax, is a client-side technology. Therefore, in the context of MVC, any js script must be part of a template file.
Note that a template file is not the view (the V in MVC), but a part of it. The view should incorporate both server-side components (classes, interfaces, etc) and client-side components (html, js, css, images, etc). For example, an instance of a view class could read some data from the domain model and then load and render a certain template file, injecting the fetched data into it (formatted), in order to be printed on the screen.
So, an ajax object should be defined in a template file. Its request to the server is handled either by the controller, or by the server-side components of the view, depending on the MVC approach that you are choosing to implement. Though, the server response should always be created by the server-side components of the view.
I'm developping a jqm application with spring mobile in the back-end.
Whenever I hit the browser refresh button on my mobile phone the page is completely devastated afterwards. Browsers back-button works properly.
The data are still available due prg pattern (flashAttributes in Spring) after refresh. Only the view is malformed.
Any ideas how to solve this problem?
From jQuery Mobile docs :
The simplest approach when building a jQuery Mobile site is to reference the same set of stylesheets and scripts in the head of every page. If you need to load in specific scripts or styles for a particular page, we recommend binding logic to the pageinit event (details below) to run necessary code when a specific page is created (which can be determined by its id attribute, or a number of other ways). Following this approach will ensure that the code executes if the page is loaded directly or is pulled in and shown via Ajax
So what happens is - in jQuery Mobile, the scripts and styles defined in the head are loaded only once. So, in normal conditions, it works fine, as all the pages will use the scripts loaded from the first page.
But. When you refresh a page in-between, it triggers a page-reload instead of the ajax navigation model thatjqm uses. So all the scripts and styles loaded from the first page will not be included from here on out.
What you need to do is "reference the same set of stylesheets and scripts in the head of every page", so that even if you hit refresh in the middle, the scripts and styles that had been loaded from the head of the first page are loaded again.
I recommend you read the docs from the above link fully to gain a better understanding.
I'm looking for a NodeJS MVC framework that allows rendering partial views on client side using Ajax (without whole page refreshing).
As far as I know, you can declare partial views on server with almost any Framework (Express, Sails...), but this will lead to refresh the whole page even if there's only a small portion of your page that really changes. This problem doesn't exist with a SPA Framework (this one would just load the partial html file in a container via ajax).
I believe Microsoft ASP.NET MVC was able to handle this case, by comparing the previous version of the page with the new requested page, and just returning the portion of the page that really changed. This may be time and CPU-consuming but it just works.
Is any Node MVC Framework managing a similar thing today ? Or is it mandatory to use an SPA Framework when a reactive user interface is required (without any whole page refresh) ?
Thanks in advance !
sails.js! It supports partials as you requested. You don't need to refresh the page, if you send ajax-request or handle the stuff via websockets dynamically.
Our test team came across an issue with their automation scripts using WebDriver. They were using a wait for $.active == 0 to determine that all ajax requests had finished before proceeding. However, with certain partial view loads, the active variable was not decrementing, thereby making the automation very difficult.
I investigated and found that the issue only arose when partial views were being loaded that had an include of a .js file and were loaded via an ajax call. However, it did not happen for all views that included a file. This is how we were including the additional js.
<script type="text/javascript" src="#Url.Script("Internal/People/CommitteeMembership.js")" />
The problem views had one common issue. The script include was defined near the top of the partial view. When I moved this down to the bottom of the partial view, the issue went away and the $.active variable correctly decrements and ends up at 0 after the ajax call to get the partial view.
My question is, can anyone explain why this is happening? I have found no instructions to put the js includes at the bottom of the partial view anywhere? At the least the problem is fixed and our automation tests can continue, but I would really like to know the why...
This has strictly nothing to do with ASP.NET MVC. ASP.NET MVC usually spits HTML. This HTML contains markup and in your case javascript. So if you are saying that the position of the javascript inclusion makes a difference, that's because that's how your scripts are organized and dependent between them.
Personally I tend to include all javascript towards the end of the lmarkup, just before the closing </body> tag.
Greeting to the community. This is my very first question.
I had in mind to add Livezilla live support in my MVC website, but I realised that there are some problems.
First of all, it is written in php and mysql, so is it possible to comply with MVC and sql server?
Does anybody know a similar solution (like livezilla) in my case?
PS. Excuse my poor english...
you could even look into using an iFrame to run livezilla inside of an mvc3 page if you wanted.
or, you could roll your own. if you wanted to try implementing a live response mvc3 page look into jquery and ajax asynchronous calls such as $.post and also look into the extension for controller AsyncController, and [AsyncTimeout(XXX)]. you will also have to read up on sending and receiving json objects in ajax and from a controller to the view.
Simple psuedo:
View:
setTimeOut calls a javascript function every X milliseconds
the javascript function uses json to wrap page data and pass it to the controller inside a $.post() call
Controller:
recieves page data as an model object in a post
determines if page is out of sync or not
returns relevant sync data in a json object back to the view
View:
the same javascript function receives the json object from controller
updates the page based on relevant sync data
Problem solved. I just uploaded the folder given from livezilla in the root folder of my website. Then the only need to met is to have a Mysql server to create the database for livezilla. After that php and mvc runs together with no problem.