EnablingJSONIN: Difference between revisions

m
no edit summary
m (Created page with "Here's how to generate there required files for enabling JSON in your webservice. #Know where your project files are. #Grab DBXRay here : ftp://ftp.stureaps.dk/ #Choose the wor...")
 
mNo edit summary
Line 43: Line 43:


<code lang="vdf">
<code lang="vdf">
Struct meta
  Struct meta
     Boolean success
     Boolean success
     String msg  
     String msg    
End_Struct
  End_Struct


Struct tReview
  Struct tReview
     Integer id
     Integer id
     Integer productId
     Integer productId
     String comment
     String comment
     String author
     String author
End_Struct
  End_Struct


Struct tProduct
  Struct tProduct
     Integer id
     Integer id
     String name
     String name
     String company     
     String company     
     tReview[] reviews
     tReview[] reviews
End_Struct
  End_Struct


Struct tAddProductRequest
  Struct tAddProductRequest
     String token
     String token
     tProduct product
     tProduct product
End_Struct
  End_Struct


Struct tGetProductResponse
  Struct tGetProductResponse
     Meta meta
     Meta meta
     tProduct product
     tProduct product
End_Struct
  End_Struct


Struct tRequest
  Struct tRequest
     String token
     String token
     Integer identifier
     Integer identifier
End_Struct
  End_Struct


Struct tResponse
  Struct tResponse
     Meta meta
     Meta meta
     Integer id   
     Integer id   
End_Struct
  End_Struct
 
</code>
 
Then you will be able to communicate with ExtJS 4 using the following model definition:
 
<code lang="javascript">
  Ext.regModel('Acme.Product', {
    idProperty: 'id',
    successProperty: 'meta.success',
    fields: [
        {name:'id', type:'int'},
        {name: "name", type:"string"},
        {name: "company", type:"string"}
    ],
    hasMany: {model:'Acme.Review', name: 'reviews', associationKey: 'reviews'}
});
 
Ext.regModel('Acme.Review', {
  idProperty: 'id',
    fields: [
            'id',
            'product_id',
            'comment',
            'author'
    ],
    belongsTo:'Acme.Product'
});
 
</code>
 


</pre>


You will be able to send tAddProductRequest as JSON from the client side as the request parameter
You will be able to send tAddProductRequest as JSON from the client side as the request parameter
1,134

edits