Kendo UI Grid/DataSource - Global Error Handling? - kendo-ui

I've currently inherited an application which has numerous Kendo grids (and other controls) throughout, and I'm trying to fix an error which keeps cropping up now and again - specifically when the user is no longer authenticated.
I know what the solution is for a single instance of the control - return a flag to indicate authentication failed, and then detect this in the error handler and perform the authentication.
The problem is am I really going to have to handle this for every instance of a Kendo control I have? Is there not a global error handler I can hook into? Either for the data source itself (as I know this is used for all Kendo control data loading), or for the Grid specificially. I don't mind either way - just which one is a hook.
This would be a more straighforward short term solution than refactoring everything to specific error handlers, etc.

I assume you can attach a global error handler to $.ajax, which is used by the DataSource, you can check how to do it here:
http://api.jquery.com/category/ajax/global-ajax-event-handlers/
Or, you can take advanttage of that the configuration that is done in the DataSource is passed directly to the $.ajax:
http://docs.kendoui.com/api/framework/datasource#configuration-transport.read-ObjectStringFunction

For reference, someone from Telerik has provided a solution using just the DataSource. I haven't tested it, but I prefer the accepted answer above as it hooked into all Ajax on the site - not just ones that utilise the Kendo DataSource.
http://www.kendoui.com/forums/mvc/grid/global-error-handler-for-numerous-grids.aspx

Related

Vaadin UI between sessions

When I am creating a new session (or try to access from an other computer) in Vaadin Flow I get this error:
Can't move a node from one state tree to another
From this link, I read something about UI and getUIId().
However, I don't understand how I should change my application in order to fix the error.
As Denis mentioned in the forum post you linked, wrong scope sounds like the most likely culprit. In other words, you are trying to use the exact same component instance in two different UIs, when both UIs should have their own instance. It's not possible to use the same instance in two places at the same time.
You can find the documentation for Vaadin Spring scopes here: https://vaadin.com/docs/latest/flow/integrations/spring/scopes
One possible cause of errors such as that is that if you're storing a Component in a static variable. You shouldn't do that - a Component instance can only belong to a single UI. A single UI in turn (in practice) means a single browser tab.

Bootstrap ui-router states programmatically

I'm working with angular 1.
I want to load some data from server before ui-router bootstrapping all the states.
Is it possible to do so?
I would say that in this Question: AngularJS - UI-router - How to configure dynamic views and mostly in this answer you can get the answer.
The point is to use a feature of UrlRouterProvider - deferIntercept()
The deferIntercept(defer)
Disables (or enables) deferring location change interception.
If you wish to customize the behavior of syncing the URL (for example,
if you wish to defer a transition but maintain the current URL), call
this method at configuration time. Then, at run time, call
$urlRouter.listen() after you have configured your own
$locationChangeSuccess event handler.
Full description including working example is here

JSF Managed bean methods not getting called

We are currently developing a JSF 2 application and we are using OpenFaces.
One "intermittent" issue that we have been noticing is that the managed bean method "sometimes" doesn't get called.
For example:
<o:commandLink onclick="wait();" action="#{createAccountContractManagedBean.executeSave}"
execute="panGrp_createAccountContractMainTabLocal"
render="panGrp_createAccountContractLocalErrorMessages label_contractNumber pnlGrp_editCustomerGroup"
styleClass="buttonOrange"
onajaxend="wait();setTabFocus('inpHdn_contractErr','tabPane_MainLocal',3);return false;">
<span>
<h:outputLabel value="#{message['application.common.button.saveandcontinue']}"/>
</span>
</o:commandLink>
wait() is a javascript function that show a modal dialog that the request is currently in process.
setTabFocus() is a javascript function that sets the focus onto a new tab if the current save request is successful.
public void executeSave() {
if (getLoggingService().isDebugLevelEnable()) {
getLoggingService().debug(this, "executeSave");
}
// ...
}
The issue is that sometimes the managed bean method executeSave() doesn't fire at all. No log message or error.
But at the same time the onajaxend() method always fires and since there is no error, it switches the focus to the next tab.
We have tried by removing the wait(); and the setTabFocus(); methods.
All the components are in the same <h:form> element and there are no multiple forms.
What might be the possible causes when a managed bean method doesn't execute with no error trace?
May mixing JSF <h:xxx> components and <o:xxx> components in the same form cause problems?
Does mixing <o:ajax> and <f:ajax> cause problems?
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?
What might be the possible causes when a managed bean method doesn't execute with no error trace?
You could try to turn ON logging like it described here. Also you could take a look with some browser debugger tool to the ajax response from server, it probably could contain some error information.
May mixing JSF components and components in the same form cause problems?
No, in common OF have full compatibility with JSF. In some really complicated cases you could get some problems, but I don't think that the situation you've described one of them.
does mixing and cause problems?
It's normal to mix them.
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?
Of course it possible that there are some bugs in OF or even JSF, but usually you will get at list some error information in such situation. Also you could try to update to latest nightly build. Or post you problem to OF support forum.

Internet Explorer 11 has null recordset

I have a classic asp app that uses XML data binding. With the IE9 emulation setting it works fine up through version IE10. But in IE11, the recordset is always null. The values, however, are bound correctly to the input fields using #DATASRC and DATAFLD. It's just when I attempt to access a particular record via recordset.absolutePosition, it bombs.
Since data binding seems to be functioning, surely there must be a way to specify a particular row of the data.
The datasrc and datafld APIs have been removed in IE11 partly for security reasons:
Example: The following use of data binding will result in the execution of script within IE:
<xml id=cdcat><note><to>%26lt;span style=x:exp<![CDATA[r]]>ession(alert(3))%26gt;hello%26lt;/span%26gt;</to></note></xml><table border=%221%22 datasrc=%22%23cdcat%22><tr><td><span datafld=%22to%22 DATAFORMATAS=html></span></td></tr></table>
Note there is no SCRIPT tag present. There are many similar obscure script execution techniques present in all browsers.
Use the following resources to create an alternative:
How to: Implement Property Change Notification
Migrating mutation and property change events to mutation observers
IE8 XSS Filter design philosophy in-depth

strutrs2 and ajax(Displaying dynamic value on jsp)

Im pretty new to struts2 and Ajax ,Actually i have a drop down menu in JSP lets say first.jsp, When user select a choice from dropdown menu,I am calling a function of Action class lets say Method1.In this method i am fetching some value from DB(lets say:a,b,c) and one value from java memory lets say d.Then I am forwarding to second.jsp and display all the parameters(a,b,c and d) in tabular format.
Now problem is that the parameter d is dynamic ,this is updating by some other application and if its change then I have to show it on JSP wihout any action.
One solution is I use in second.jsp , so after interval of 10 second again Mehod1 will call and it will fetch value(a,b,c) from db and updated value of d from java memory. and disply it to second.jsp.But in this case i am unnecessary retrieving value from db while my purpose is just to get value d from memory.This is working but this is causing my application to slower.
Can any body suggetst some other solution? or can i do it using ajax and how?
Any other advice? any help is appreciated.try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic :I have spend hours trying to play around with this but have got nowhere
Okay... What you're asking is a little fuzzy so let me rephrase:
You have a user (USER1) who opens a web page and sees some data.
You have a second user (USER2) (who may be an application) who is able set a value from time to time.
When USER2 updates that value you want USER1 to see it change in their open browser window?
If this is the case you need to understand basic ajax. For that get these demo applications working:
This example uses dojo and perhaps the S2 ajax tag lib I don't remember I prefer not to use ajax tags (as they are deprecated and prefer jquery for ajax):
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
This example here shows a very similar application but using jquery, no tag library, upgraded to Spring 3, it still needs polish:
http://www.kenmcwilliams.com/Downloads/
Now that you know how to get data via ajax, look at the request with firebug. You'll see that the request is just like a typical function call, the browser keeps waiting for the data to come back.
What you do is simply not return from the action until new data is provided. This is called long polling see: http://en.wikipedia.org/wiki/Comet_%28programming%29#Ajax_with_long_polling
If you have not written a simple chat program, using just terminal windows I recommend you do so. Two windows per client (client-send, client-receive windows) and you'll need a server program. I remember hacking one together in a few hours using _Thinking In Java 2nd Edition (Later books took out the networking section if I remember correctly). Anyways between understanding client server interaction and long polling will let you get things working. It would be fun to extend the simple terminal based chat application to a S2 ajax chat application. Would make an awesome tutorial! PS: This is just an application of the producer/consumer problem (If you understand that then I guess you don't need to do the fun exercise).
The interfaces would look very pretty if the server was managed by spring. I know there must be nice servers already written but I am not familiar with any, but would love to hear of one.

Resources