PDA

View Full Version : JSON / XML 's ExtJS, is there another way



flatburger
14 Oct 2007, 2:48 AM
ExtJS implement their own JSON implementation, and this is the url for the standard

http://extjs.com/learn/Manual:Forms:Result_Format

is there another way to use another way rather than this default ?

F

evant
14 Oct 2007, 3:00 AM
Ext doesn't use it's own JSON implementation (there is no such thing as JSON, only javascript).

All it's doing is specifying a standard format for retrieving a response, is this really a problem?

flatburger
14 Oct 2007, 3:19 AM
i try the paging example, and find there is not response format like in manual

i still dont get the way of working.

can help?

Animal
14 Oct 2007, 3:20 AM
You can massage the Action's response.result object into the required format in the Form's "actioncomplete" event which is passed the Form and the Action.

The Action holds a result property which is the javascript object you returned.

You can fiddle with it to make it look like what the Action expects to deal with.

Animal
14 Oct 2007, 3:21 AM
Paging? Form?

You're confused.

flatburger
14 Oct 2007, 3:33 AM
grid paging from example :)

which read this forum in json format

i still work hard to understand how to read json :)

this is because i cannot migrate xml-form example to become json-form example.

wanna help?

Animal
14 Oct 2007, 3:38 AM
There's no such thing as json.

It's just a javascript object literal! like you would use in this statement:



var myFormResult = {
success: true,
data: {
fieldName: "Field value"
}
}
if (myFormResult.success) {
myForm.setValues(myFormResult.data);
}

mystix
14 Oct 2007, 4:12 AM
an article by IBM which might help:

http://www.ibm.com/developerworks/xml/library/x-xml2jsonphp/

refer to listing 1 and 2 of that article for short explanations on XML / JSON. it should be trivial to see the similarities between the 2, and the conversion from XML to JSON.

flatburger
14 Oct 2007, 7:47 AM
hi there,


I choose JavaME, Swing and Javascript *ExtJS, become my client for my project here. that is the basic idea of my current project.

i just think is the JSON is the best choose for my project, but 2 of them are in java, the extjs is the javascript.

Java Object in JavaME and Swing must be converted to JSON, and send to my backend, is this the good one, what dont we use xmlrpc


but i can see in ExtJS also have XML stuff, and XMLReader is the answer, but we know processing Javascript is more more reseource than java, because the VM of Firefox or Flash is slower than Java, but lighter.

any opinion?

Animal
14 Oct 2007, 8:12 AM
Use this to communicate with your Java backend: http://getahead.org/dwr/

This is what we use. It's cool. You don't need to worry about json, you call methods.

TheItalianJob
11 Jan 2008, 2:05 AM
There's no such thing as json.

It's just a javascript object literal! like you would use in this statement:



var myFormResult = {
success: true,
data: {
fieldName: "Field value"
}
}
if (myFormResult.success) {
myForm.setValues(myFormResult.data);
}



Hello Animal

when I want copy data returned from a drw call into form I must implement the code writed up?
the jsonreader don't automatically copy data into form specified?

this is my small example how I integrate your code?




Entity.readers.dettaglioProfilo=new Ext.data.JsonReader({
id:"id"
},[
{name:"nome",type:"string"},
{name:"cognome",type:"string"}
]);



Example my form:


var formPanel = new Ext.form.FormPanel({
baseCls: 'x-plain',
labelWidth: 75,
url:'/ZusersWeb/myDesktop/pages/tests/form_results.jsp',
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{xtype: 'textfield', id:'nome', fieldLabel: 'First Name', name: 'nome', allowBlank:false },
{xtype: 'textfield', id:'cognome', fieldLabel: 'Last Name', name: 'cognome', allowBlank:false }
]
});

tryanDLS
11 Jan 2008, 7:41 AM
@TheItalianJob - please don't hijack a general discussion question to ask a specific question like this. Create a new thread in Help.

TheItalianJob
11 Jan 2008, 11:41 AM
:D Excuse me...