Menu
  • HOME
  • TAGS

Sencha/Extjs rest call with all parameters

Tag: json,rest,extjs,sencha-touch

I'm using ExtJs 5.1.1 and I've written a simple view with a grid, and selecting one row the corresponding model property are editable in some text fields. When editing is completed the button 'save' call Model.save() method, which use the rest proxy configured to write the changes on the server.

The call made by the proxy are two, first is OPTIONS call to know which method are allowed, second call is a PUT. My problem is PUT json contains only the changed attributes. I would like that my application sends all the attributes in PUT, instead only the changed subset.

Is this a proxy configuration, or should I use another kind of proxy, like ajax?

Some code snippet:

Model:

Ext.define('myApp.model.CvModel', {
    extend: 'Ext.data.Model',
    alias: 'viewmodel.cv',  

    idProperty : 'code',
    proxy: {
        type: 'rest',

        url: 'http://localhost:8080/CV/resource/rest/cvs/CodeSystem/Domain',
        paramsAsJson: true,
        reader: {
            type: 'json',
            rootProperty: 'Test_data'
        }

    },


    fields: [{
        ...

Controller:

onSave: function () {
            var selCv = this.getViewModel().get('selectedCv');
            selCv.save();
            ....

Best How To :

You need to specify a writer config on your proxy with writeAllFields: true. By default it's false, and the default writer itself is just {type: 'json'}.

do calculation inside JSONArray in Java

java,arrays,json

Here's what I would do. Replace <JSON STRING HERE> with the JSON String you were going to parse: ArrayList<ArrayList<Integer>> resultList = new ArrayList<ArrayList<Integer>>(); JSONArray arr = new JSONArray(<JSON STRING HERE>); for(int i = 0; i < arr.length(); i ++) { JSONObject obj = arr.getJSONObject(i); JSONArray valueArray = obj.getJSONArray("values"); ArrayList<Integer> dataList...

why i don't get return value javascript

javascript,jquery,html,json,html5

the first "A" in AJAX stands for "Asynchronous" that means, it is not executed right after it has been called. So you never get the value. Maybe you could first, get the os list and then output what you need, like this: function createCheckBoxPlatform(myDatas) { $.ajax({ url: "/QRCNew/GetOS", type: "post",...

Fatal error catched by register_shutdown_function and update json_encode

php,json,fatal-error

Why move one array to another array and then echo the second array. Why not just do this function shutdown(){ $error = error_get_last(); echo json_encode($error); } Or even this function shutdown(){ echo json_encode(error_get_last()); } Apart form the use of an unnecessary array, this will give you all the information available...

How to work with django-rest-framework in the templates

json,django,django-templates,django-rest-framework

model.py: class Day(models.Model): date = models.DateField(default=date.today) def get_todo_list(self): return self.day_todo_set.order_by('-id')[:5] class ToDo(models.Model): date = models.ForeignKey(Day, related_name="day_todo_set") name = models.CharField(max_length=100) very_important = models.BooleanField(default=False) finished = models.BooleanField(default=False) In serializers.py class ToDoSerializer(serializers.ModelSerializer): class Meta: model = ToDo field = ('id', 'date', 'name', 'very_important', 'finished') class...

Can't save json data to variable (or cache) with angularjs $http.get

json,angularjs,web-services,rest

$http.get is asynchronous. When cache.get or return result are executed, HTTP request has not completed yet. How are you going to use that data? Display in UI? E.g. try the following: // Some View <div>{{myData}}</div> // Controller app.controller('MyController', function ($scope) { $http.get('yoururl').success(function (data) { $scope.myData = data; }); }); You...

Unable to select values from the select list

javascript,jquery,rest

Here is the working fiddle: https://jsfiddle.net/64djszjf/14/ If you take a look at the source js file: https://aui-cdn.atlassian.com/aui-adg/5.8.13/js/aui-experimental.js, there are few lines that sets unselectable class: populateResults: function(container, results, query) { var populate, id=this.opts.id; populate=function(results, container, depth) { var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted; results =...

Sencha/Extjs rest call with all parameters

json,rest,extjs,sencha-touch

You need to specify a writer config on your proxy with writeAllFields: true. By default it's false, and the default writer itself is just {type: 'json'}.

REST Jersey server JAX-RS 500 Internal Server Error

java,rest,jersey,jax-rs

IllegalAnnotationException: Class has two properties of the same name "list" Look at your two model classes XmlMessageBean and ResponseList. Do you see any difference? The main difference (and the cause for the error), is the @XmlAccessorType(XmlAccessType.FIELD) annotation (or lack there of). JAXB by default will look for the public...

JQuery mutiple post in the same time

javascript,php,jquery,json

You can use the jQuery when function (https://api.jquery.com/jquery.when/) to wait for all three promises to resolve. You only need to make sure you also return the promise in your nb1, nb2, nb3 functions. function nb1() { return $.post("p1.php", { action: 1 }, function(data) { console.log(data); }, "json") .fail(function(data) { console.log("error");...

Uncaught error: Invalid type for google table column

javascript,json,google-maps,google-visualization

You should change your row data.addColumn('String', 'sitecode'); to data.addColumn('string', 'sitecode'); (non capital "s" in "string"), of course this applies to all of your added columns. Javascript is case-sensitive....

'utf8' codec can't decode byte 0xf3

python,json,character-encoding

Your file is not encoded in UTF-8, and the error occurs at the fp.read() line. You must use: import io io.open(filename, encoding='latin-1') And the correct, not platform-dependent usage for joining your paths is: os.path.join(root, f) ...

Sorting in Ruby on rails

ruby-on-rails,json,sorting

You're not getting the results you want because you're not assigning the sorted user_infos back into the user_infos variable. You can do the following: user_infos = user_infos.sort {|a, b| - (a['can_go'] <=> b['can_go']) } # -or- user_infos.sort! {|a, b| - (a['can_go'] <=> b['can_go']) } The first version of sort creates...

Response 200 OK but Jquery shows error?

javascript,jquery,json

The code you've supplied, by itself, works fine. It breaks if you try to force the use of JSONP because the server you are making the request to doesn't support that. It does support CORS (which is the modern replacement for JSONP), and you don't need to do anything special...

Replacing elements in an HTML file with JSON objects

javascript,json,replace

obj.roles[0] is a object {"name":"with whom"}. you cant replace string with object. you need to refer to property "name" in the object obj.roles[0].name Another problem is that var finalXML get a new value every line. you need to add a new value to the variable, not replcae it. var finalXML...

REST api : correctly ask for an action

api,rest,endpoint

Try to separate API from your application logic. From API you GET the quote and API from now on shouldn't care what you do with that data. The same with marking quotes as favorites. It's your application's and user db's problem how to mark something. Again, API should care only...

How to parse JSON array of string arrays

c#,json

Simple - you can use JsonConvert.DeserializeObject to deserialize it to a string[][]: using System; using System.IO; using Newtonsoft.Json; class Test { static void Main() { var json = File.ReadAllText("test.json"); string[][] array = JsonConvert.DeserializeObject<string[][]>(json); Console.WriteLine(array[1][3]); // FirstValue4 } } ...

Ruby on Rails - Help Adding Badges to Application

ruby-on-rails,ruby,rest,activerecord,one-to-many

Take a look at merit gem. Even if you want to develop your own badge system from scratch this gem contains plenty of nice solutions you can use. https://github.com/merit-gem/merit

REST API with token based authentication

angularjs,codeigniter,api,rest,token

You can use an API key, however - as you wrote - it's pure protection and easily accessible value - potential abuser just needs to view the source or investigate the queries. In general REST APIs are secured with tokens. At the beginning of the session (not in traditional meaning...

How can I get json objects without the object number?

javascript,jquery,json,rest

Create an object. Loop over the array Get the name of each member of the array Copy each member into the object using a property name that is the same as the name you just got Then just use the object instead of the array. You might want to...

SwiftyJSON Reading JSON Array issue

json,swift,swifty-json

json["Cars"] is an array, so for example to get the first item via SwiftyJSON: println(json["Cars"][0]["Brand"].stringValue) In a JSON string, { and } are delimiters for dictionaries, whereas [ and ] are delimiters for arrays. EDIT: Following your comment, yes, you can loop over the array: if let cars = json["Cars"].array...

@RestController throws HTTP Status 406

java,spring,rest,maven

The issue is with the dependencies that you have in pom.xml file. In Spring 4.1.* version the pom.xml dependency for Jackson libraries should include these: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.1.1</version> </dependency> You...

Why i get can not resolve method error in class android?

android,json

You didn't create setName() method in Person class. public class Person { private String name; private String country; private String twitter; //getters & setters.... public void setName(String pName) { this.name = pName; } public void getName() { return this.name; } } ...

Codeigniter Select JSON, Insert JSON

json,codeigniter,select,insert,routing

You want to return json object in response, so it's required to set json type in response header. As given here public function select(){ $data['query'] = $this->users->select(); $this->output ->set_content_type('application/json') ->set_output(json_encode($data['query'])); } It is required to encode part as below for insert part. so you can use this generated url to...

Parsing Google Custom Search API for Elasticsearch Documents

json,python-2.7,elasticsearch,google-search-api

here is a possible answer to your problem. def myfunk( inHole, outHole): for keys in inHole.keys(): is_list = isinstance(inHole[keys],list); is_dict = isinstance(inHole[keys],dict); if is_list: element = inHole[keys]; new_element = {keys:element}; outHole.append(new_element); if is_dict: element = inHole[keys].keys(); new_element = {keys:element}; outHole.append(new_element); myfunk(inHole[keys], outHole); if not(is_list or is_dict): new_element = {keys:inHole[keys]}; outHole.append(new_element);...

Check for duplicates in JSON

javascript,jquery,json,duplicates

var asset = [ { value1: "1", value2: "2", value3: "3" }, { value1: "1", value2: "5", value3: "7" }, { value1: "6", value2: "9", value3: "5" }, { value1: "6", value2: "9", value3: "5" } ]; function countEqual(oo, pp) { var count = 0; oo.forEach(function (el) { var i,...

Deserializing Json data to c# for use in GridView - Error Data source is an invalid type

c#,json,gridview,serialization,.net-4.5

You're binding the container object, not the list itself. Change it to: GridView1.DataSource = personDetail.PersonDetails; And it should work....

Serializing a java bean into a cookie: Is it bad?

java,json,cookies

I guess the answer depends on your answer to these questions: Since you can never trust ANYTHING that comes in a client request, are there any harmful effects that could come by a hacker spoofing the pojo value? By sending the object to the client, does this expose any internal...

How to rearrange CSV / JSON keys columns? (Javascript)

javascript,json,csv,papaparse

Papa Parse allows to specify order of fields in the unparse() function: var csv = Papa.unparse({ fields: ["ID", "OrderNumber", "OrderStatus", "StartTime", "FinishTime", "canOp", "OpDesc", "UOM"], data: [{ OrderStatus: "Good", canOp: "True", OpDesc: "Good to go", ID: "100", OrderNumber: "1000101", FinishTime: "20:50", UOM: "K", StartTime: "18:10" }, // ... ] });...

Link to another resource in a REST API: by its ID, or by its URL?

json,api,rest,api-design,hateoas

DO include absolute entity URIs in your responses (such as /customers/12 or even http://www.example.com/customers/12). DO NOT include just an entity's ID (such as 12) in a response, because that way you're forcing clients to put together resource URIs themselves. In order to do that, they would need to have prior...

access the json encoded object returned by php in jquery

php,jquery,ajax,json

Try: $.ajax({ url: "functions.php", dataType: "JSON", data: {id: id}, type: 'POST', success: function(json){ for(var i=0;i<json.length;i++){ alert(json[i].fname); } } }); ...

Unable to upload file to Sharepoint @ Office 365 via REST

javascript,ajax,rest,sharepoint,office365

To me it just seems a bit light, visit this link https://msdn.microsoft.com/en-us/library/office/dn769086.aspx on technet, and compare your upload function to this: // Add the file to the file collection in the Shared Documents folder. function addFileToFolder(arrayBuffer) { // Get the file name from the file input control on the page....

Deserializing JSON into c# class

c#,json,couchdb

You could create a custom JsonConverter for this: [JsonConverter(typeof(ClickConverter))] public class Click { public DateTime Date { get; set; } public string Code { get; set; } public string Url { get; set; } public int Count { get; set; } } public class ClickConverter : JsonConverter { public override...

Insert data in collection at Meteor's startup

javascript,json,meteor,data,startup

Ok, you'll want to check out Structuring your application. You'll have to make the file with the definition load earlier, or the one with the fixture later. Normally you have your collections inside lib/ and your fixtures inside server/fixtures.js. So if you put your insert code into server/fixtures.js it'll work....

Create n:m objects using json and sequelize?

javascript,json,node.js,sequelize.js

Have a look at nested creation (the feature is not documented yet) Store.create({ name:'corner store', address: '123 Main Street', products: [ { name: 'string beans' }, { name: 'coffee' }, { name: 'milk' } ] }, { include: [Product] }); This will create both stores and products and associate the...

Nested JSON structure to build side-by-side d3.js charts

javascript,json,d3.js

No, you don't need to use .nest here. The easiest way to build the required data structure is as you suggest (d3 always wants an array to iterate over): var nestedData = [ years[0].chartOne, years[0].chartTwo ]; After that, it's as simple as cleaning up the accessor functions for your data...

KendoUI Grid - Complex JSON with inconsistent keys

javascript,json,kendo-ui,kendo-grid

You can use column templates: columns: [ { field: "id", title: "User Id" }, { field: "name", title: "User Name", }, { field: "type", title: "User Type", template: function(dataItem) { return dataItem.type ? kendo.htmlEncode(dataItem.type) : ""; } }, { field: "address", title: "Street 1", template: function(dataItem) { return dataItem.address.street1 ?...

String comparison in AngularJS

javascript,json,angularjs,ionic-framework,string-comparison

You are iterating over wrong node:) for(var i=0;i<$rootScope.items.length;i++) { alert("Inside for loop"); if (name === $rootScope.items[i].names) // you iterate over items, not names, which it an Json property inside item { alert("If condition satisfied"); } } ...

How use jquery getJSON with a local variable

javascript,jquery,ajax,json,ace-editor

JSON is JavaScript Object Notation, so this: [] or {} is JSON. I guess you only need: getCompletions: function(editor, session, pos, prefix, callback) { if (prefix.length === 0) { callback(null, []); return; } callback(null, wordList.map(function(ea) { return {name: ea.word, value: ea.word, meta: "optional text"} })); } $.getJSON will call the...

Using .update with nested Serializer to post Image

django,rest,django-models,django-rest-framework,imagefield

As noted in the docs, .update() doesn't call the model .save() or fire the post_save/pre_save signals for each matched model. It almost directly translates into a SQL UPDATE statement. https://docs.djangoproject.com/en/1.8/ref/models/querysets/#update Finally, realize that update() does an update at the SQL level and, thus, does not call any save() methods on...

Call function on Server from iOS app - Objective C

ios,objective-c,json,server,backend

You just need to POST data to your server. Port could be anything you want, should be 80. Host your script with a domain url so that you can make network request publicly. You can try this function: -(NSData *)post:(NSString *)postString url:(NSString*)urlString{ //Response data object NSData *returnData = [[NSData alloc]init];...

php array returns undefined but print_r shows otherwise [duplicate]

php,arrays,json,undefined

The array you're looping looks like this: Array ( [0] => Array ( [mstatus] => 1 [mhearingnum] => first [mminutes] => adakjaflafjlarjkelfkalfkd;la ) [1] => Array ( [mhearingnum] => second [mminutes] => ) [2] => Array ( [mhearingnum] => third [mminutes] => ) ) Only the sub array at the...

Parse JSON output from AlamoFire

json,swift,nsurlrequest

If I believe the println of aStatus, the property title is a String, not a Dictionary. Change this part in your code (cast as String instead of as NSDictionary): if let user = aStatus["title"] as? String { println( "TITLE \(user)") } ...

Getting front value from array/json

php,arrays,json

You can use $array["image_intro"],this will give you the value of image_intro. check out the manual

Use JSON file to insert data in database

javascript,json,mongodb,meteor,data

Simple use underscores _.extend function. Like this: var newProfile = _.extend( JSON.parse(Assets.getText('test.json')), {user: id} ) Profiles.insert(newProfile) ...

convert from json to array

javascript,php,json

First off, your associative array is flipped. You need to change array($wholeNumber['DocumentNbr'] => 'Number', $wholeNumber['DocumentRevision'] => 'Revision'); to array('Number' => $wholeNumber['DocumentNbr'], 'Revision' => $wholeNumber['DocumentRevision']); You need that in order to access the elements of the JSON. Then, in your loop, you would use wholeNumberData[i].Number to get the number and wholeNumberData[i].Revision...

LineChart with C3 using JSON

json,c3

Your JSON seems to be invalid. The 3rd element is missing an open parentheses. Include double quotes around the property names Change your single quotes to double quotes The following JSON works [ { "round":"1", "val":1000 }, { "round":"2", "val":1000 }, { "round":"3", "val":1000 }, { "round":"4", "val":1000 }, {...