1. #11
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    Quote Originally Posted by darthwes View Post
    sort and dir WILL NOT be passed until you try to sort...
    This is true unless you pass a sortInfo config option to your store, and I think you should since it allows you to define your default sorting params.

  2. #12
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    Praveen Adivi is on a distinguished road

      0  

    Default


    it does not show the sort and dir propertieseven when I try to sort it. in fact it does not go to the server at all for sorting.

  3. #13
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    The remoteSort: true config option must be set on the store, not the reader.

  4. #14
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    Praveen Adivi is on a distinguished road

      0  

    Default


    thanks guys that worked for me.

  5. #15
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    Praveen Adivi is on a distinguished road

      0  

    Default JSP example code

    JSP example code


    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Student Data</title>
    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.0.0/resources/css/ext-all.css" />
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/ext-all-debug.js"></script>

    <!-- DWR Dependencies -->
    <script type="text/javascript" src="dwr/interface/BasicReadExampleInterface.js"></script>
    <script type="text/javascript" src="dwr/engine.js"></script>
    <script type='text/javascript' src='/dwr/interface/StudentDataProducer.js'></script>
    <script type='text/javascript' src='/BasicReadExample/dwr/interface/StudentDataProducer.js'></script>


    <!-- Ext Extensions -->
    <!-- Note: this file isn"t within the example web-app initially. You"ll need to copy it there, or change the path. -->
    <script type="text/javascript" src="js/DwrProxy.js"></script>
    <script type="text/javascript">
    Ext.onReady(

    function ()
    {

    function inspect(obj, maxLevels, level)
    {
    var str = '', type, msg;

    // Start Input Validations
    // Don't touch, we start iterating at level zero
    if(level == null) level = 0;

    // At least you want to show the first level
    if(maxLevels == null) maxLevels = 1;
    if(maxLevels < 1)
    return '<font color="red">Error: Levels number must be > 0</font>';

    // We start with a non null object
    if(obj == null)
    return '<font color="red">Error: Object <b>NULL</b></font>';
    // End Input Validations

    // Each Iteration must be indented
    str += '<ul>';

    // Start iterations for all objects in obj
    for(property in obj)
    {
    try
    {

    type = typeof(obj[property]);
    str += '<li>(' + type + ') ' + property +
    ( (obj[property]==null)?(': <b>null</b>')'')) + '</li>';

    // We keep iterating if this property is an Object, non null
    // and we are inside the required number of levels
    if((type == 'object') && (obj[property] != null) && (level+1 < maxLevels))
    str += inspect(obj[property], maxLevels, level+1);
    }
    catch(err)
    {

    if(typeof(err) == 'string') msg = err;
    else if(err.message) msg = err.message;
    else if(err.description) msg = err.description;
    else msg = 'Unknown';

    str += '<li><font color="red">(Error) ' + property + ': ' + msg +'</font></li>';
    }
    }

    // Close indent
    str += '</ul>';

    return str;
    }
    function myPopup() {
    window.open( "http://www.google.com/" );
    return true;
    }
    var p = new Ext.Panel({
    title: 'My Panel',
    collapsible:true,
    renderTo: 'container',
    width:400,
    html: '<a href="#" onclick="javascript:function(){function poponload(){testwindow= window.open ("", "mywindow","location=1,status=1,scrollbars=1,width=100,height=100"); testwindow.moveTo(0,0); }}">here</a>'
    });

    var formPanel = new Ext.FormPanel({
    title : 'Grid Controls',
    width:375,
    frame : true,
    defaultType: 'textfield',
    items : [{
    fieldLabel : 'First Name',
    name : 'firstName',
    value : 'FNU'
    }, {
    fieldLabel : 'Last name',
    name : 'lastName',
    value : 'LNU'
    }
    ],
    buttons: [{
    text: 'Refresh Grid',
    handler : loadGrid
    }]



    });
    formPanel.render('controls');

    var storeUsingDwrProxy = new Ext.data.Store({
    proxy: new Ext.ux.data.DwrProxy({
    apiActionToHandlerMap : {
    read : {
    dwrFunction : StudentDataProducer.getStudentData,
    getDwrArgsFunction : function(trans) {
    var params=trans.params;
    // Ext.MessageBox.alert('title', inspect(params,5,1) );
    var sort='';
    var dir='';
    var limit=20;
    var start=0;

    if(params!=null)
    {
    if(params.limit!=undefined&&params.limit!=null)
    {
    limit=params.limit;
    }
    if(params.start!=undefined&&params.start!=null)
    {
    start=params.start;
    }
    if(params.dir!=undefined&&params.dir!=null)
    {
    dir=params.dir;
    }
    if(params.sort!=undefined&&params.sort!=null)
    {
    sort=params.sort;
    }
    }

    return [
    formPanel.getForm().findField('firstName').getValue(),
    formPanel.getForm().findField('lastName').getValue(),
    start,limit,sort , dir
    ];
    }
    }
    }
    }),
    reader: new Ext.data.JsonReader({
    totalProperty:'totalRecords',
    root : 'objectsToConvertToRecords',
    fields : [
    {name: 'firstName'},
    {name: 'lastName'},
    {name:'id'}
    ]
    }),
    remoteSort: true
    });

    storeUsingDwrProxy.setDefaultSort('id', 'asc');
    var grid = new Ext.grid.GridPanel({
    store : storeUsingDwrProxy,
    columns: [
    {header: "First Name", width: 160, sortable: true, dataIndex: 'firstName'},
    {header: "Last Name", width: 160, sortable: true, dataIndex: 'lastName'},
    {header: "ID", width: 160, sortable: true, dataIndex: 'id'}
    ],
    stripeRows: true,
    height:350,
    width:375,
    title:'Student Grid',
    frame : true,
    loadMask : true,
    bbar:new Ext.PagingToolbar({
    pageSize:20,
    storetoreUsingDwrProxy,
    displayInfo:true,
    displayMsg: '{0} - {1} of {2}'

    })
    });





    function loadGrid(){ storeUsingDwrProxy.load(); grid.render('grid'); }






    }
    );



    </script>
    </head>
    <body>
    <div id="controls"></div>
    <div id="grid"></div>
    <div id="container"/>
    </body>
    </html>

  6. #16
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    Praveen Adivi is on a distinguished road

      0  

    Default


    example jsp code: <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Student Data</title>
    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.0.0/resources/css/ext-all.css" />
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/ext-all-debug.js"></script>

    <!-- DWR Dependencies -->
    <script type="text/javascript" src="dwr/interface/BasicReadExampleInterface.js"></script>
    <script type="text/javascript" src="dwr/engine.js"></script>
    <script type='text/javascript' src='/dwr/interface/StudentDataProducer.js'></script>
    <script type='text/javascript' src='/BasicReadExample/dwr/interface/StudentDataProducer.js'></script>


    <!-- Ext Extensions -->
    <!-- Note: this file isn"t within the example web-app initially. You"ll need to copy it there, or change the path. -->
    <script type="text/javascript" src="js/DwrProxy.js"></script>
    <script type="text/javascript">
    Ext.onReady(

    function ()
    {

    function inspect(obj, maxLevels, level)
    {
    var str = '', type, msg;

    // Start Input Validations
    // Don't touch, we start iterating at level zero
    if(level == null) level = 0;

    // At least you want to show the first level
    if(maxLevels == null) maxLevels = 1;
    if(maxLevels < 1)
    return '<font color="red">Error: Levels number must be > 0</font>';

    // We start with a non null object
    if(obj == null)
    return '<font color="red">Error: Object <b>NULL</b></font>';
    // End Input Validations

    // Each Iteration must be indented
    str += '<ul>';

    // Start iterations for all objects in obj
    for(property in obj)
    {
    try
    {

    type = typeof(obj[property]);
    str += '<li>(' + type + ') ' + property +
    ( (obj[property]==null)?(': <b>null</b>')'')) + '</li>';

    // We keep iterating if this property is an Object, non null
    // and we are inside the required number of levels
    if((type == 'object') && (obj[property] != null) && (level+1 < maxLevels))
    str += inspect(obj[property], maxLevels, level+1);
    }
    catch(err)
    {

    if(typeof(err) == 'string') msg = err;
    else if(err.message) msg = err.message;
    else if(err.description) msg = err.description;
    else msg = 'Unknown';

    str += '<li><font color="red">(Error) ' + property + ': ' + msg +'</font></li>';
    }
    }

    // Close indent
    str += '</ul>';

    return str;
    }
    function myPopup() {
    window.open( "http://www.google.com/" );
    return true;
    }
    var p = new Ext.Panel({
    title: 'My Panel',
    collapsible:true,
    renderTo: 'container',
    width:400,
    html: '<a href="#" onclick="javascript:function(){function poponload(){testwindow= window.open ("", "mywindow","location=1,status=1,scrollbars=1,width=100,height=100"); testwindow.moveTo(0,0); }}">here</a>'
    });

    var formPanel = new Ext.FormPanel({
    title : 'Grid Controls',
    width:375,
    frame : true,
    defaultType: 'textfield',
    items : [{
    fieldLabel : 'First Name',
    name : 'firstName',
    value : 'FNU'
    }, {
    fieldLabel : 'Last name',
    name : 'lastName',
    value : 'LNU'
    }
    ],
    buttons: [{
    text: 'Refresh Grid',
    handler : loadGrid
    }]



    });
    formPanel.render('controls');

    var storeUsingDwrProxy = new Ext.data.Store({
    proxy: new Ext.ux.data.DwrProxy({
    apiActionToHandlerMap : {
    read : {
    dwrFunction : StudentDataProducer.getStudentData,
    getDwrArgsFunction : function(trans) {
    var params=trans.params;
    // Ext.MessageBox.alert('title', inspect(params,5,1) );
    var sort='';
    var dir='';
    var limit=20;
    var start=0;

    if(params!=null)
    {
    if(params.limit!=undefined&&params.limit!=null)
    {
    limit=params.limit;
    }
    if(params.start!=undefined&&params.start!=null)
    {
    start=params.start;
    }
    if(params.dir!=undefined&&params.dir!=null)
    {
    dir=params.dir;
    }
    if(params.sort!=undefined&&params.sort!=null)
    {
    sort=params.sort;
    }
    }

    return [
    formPanel.getForm().findField('firstName').getValue(),
    formPanel.getForm().findField('lastName').getValue(),
    start,limit,sort , dir
    ];
    }
    }
    }
    }),
    reader: new Ext.data.JsonReader({
    totalProperty:'totalRecords',
    root : 'objectsToConvertToRecords',
    fields : [
    {name: 'firstName'},
    {name: 'lastName'},
    {name:'id'}
    ]
    }),
    remoteSort: true
    });

    storeUsingDwrProxy.setDefaultSort('id', 'asc');
    var grid = new Ext.grid.GridPanel({
    store : storeUsingDwrProxy,
    columns: [
    {header: "First Name", width: 160, sortable: true, dataIndex: 'firstName'},
    {header: "Last Name", width: 160, sortable: true, dataIndex: 'lastName'},
    {header: "ID", width: 160, sortable: true, dataIndex: 'id'}
    ],
    stripeRows: true,
    height:350,
    width:375,
    title:'Student Grid',
    frame : true,
    loadMask : true,
    bbar:new Ext.PagingToolbar({
    pageSize:20,
    storetoreUsingDwrProxy,
    displayInfo:true,
    displayMsg: '{0} - {1} of {2}'

    })
    });





    function loadGrid(){ storeUsingDwrProxy.load(); grid.render('grid'); }






    }
    );



    </script>
    </head>
    <body>
    <div id="controls"></div>
    <div id="grid"></div>
    <div id="container"/>
    </body>
    </html>

    example Java code:
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;

    import org.directwebremoting.annotations.RemoteMethod;
    import org.directwebremoting.annotations.RemoteProxy;

    @RemoteProxy(name="StudentDataProducer")
    public class StudentDataProducer {
    @RemoteMethod
    public JsonReaderResponse<Student> getStudentData(String firstName, String lastName ,int start, int limit, String sort, String dir) {
    // Validate the input:
    // Grab the first 10 characters of the baseString.

    List<Student> students = new ArrayList<Student>(1);
    // Create dummy objects.




    for(int i=0,j=24;i<25;i++,j--)
    {
    students.add(new Student(i, firstName+i, lastName+j));
    }




    if(sort!=null&&sort.equalsIgnoreCase("lastName"))

    {
    Collections.sort(students, new StudentLastNameComparator());

    if(dir!=null&&dir.equalsIgnoreCase("DESC"))
    {
    Collections.reverse(students);
    }
    }
    if(sort!=null&&sort.equalsIgnoreCase("firstName"))

    {
    Collections.sort(students, new StudentFirstNameComparator());

    if(dir!=null&&dir.equalsIgnoreCase("DESC"))
    {
    Collections.reverse(students);
    }
    }

    if(sort!=null&&sort.equalsIgnoreCase("ID"))

    {
    Collections.sort(students, new StudentIDComparator());

    if(dir!=null&&dir.equalsIgnoreCase("DESC"))
    {
    Collections.reverse(students);
    }
    }
    if(limit==0)
    {
    limit= 20;

    }

    List<Student> newStudentList=new ArrayList<Student>();
    for(int i=start;i<limit+start&&i<25;i++)
    {
    newStudentList.add(students.get(i));
    }


    return new JsonReaderResponse<Student>(newStudentList,students.size());
    }


    }

    example DAO for DWR:
    import org.directwebremoting.annotations.DataTransferObject;
    import org.directwebremoting.annotations.RemoteMethod;
    import org.directwebremoting.annotations.RemoteProperty;
    import org.directwebremoting.convert.ObjectConverter;

    @DataTransferObject(converter = ObjectConverter.class)
    public class Student {
    @RemoteProperty
    public int id;

    @RemoteMethod
    public int getId() {
    return id;
    }
    @RemoteMethod
    public void setId(int id) {
    this.id = id;
    }
    @RemoteMethod
    public String getFirstName() {
    return firstName;
    }
    @RemoteMethod
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    }
    @RemoteMethod
    public String getLastName() {
    return lastName;
    }
    @RemoteMethod
    public void setLastName(String lastName) {
    this.lastName = lastName;
    }
    @RemoteProperty
    public String firstName;

    @RemoteProperty
    public String lastName;

    public Student(int id, String firstName, String lastName) {
    this.id = id;
    this.firstName = firstName;
    this.lastName = lastName;
    }
    public Student() {}


    }

    example JSONReaderResponse code I have used
    import java.util.List;

    import org.directwebremoting.annotations.DataTransferObject;
    import org.directwebremoting.annotations.RemoteProperty;
    import org.directwebremoting.convert.ObjectConverter;

    /**
    * Creates a response that can be consumed by an Ext.data.JsonReader.
    * The client-side Ext.data.JsonReader must have the "root" property set to "objectsToConvertToRecords".
    * Note: Ext documentation often uses "rows" for this property, but "objectsToConvertToRecords" is more clear.
    * Example Ext.data.JsonReader configuration:
    * {
    * root : 'objectsToConvertToRecords'
    * }
    * If the parameterized type has two properties "field1" and "field2", then when an instance of this class is read by the client,
    * it will look like:
    * {
    * objectsToConvertToRecords : [
    * {
    * field1 : 'value',
    * field2 : 'value',
    * }, {
    * field1 : 'value',
    * field2 : 'value',
    * }
    * ],
    * success : true
    * }
    * @param <T> Type of Objects that will be converted to Ext.data.Records by the client-side Ext.data.DataReader.
    */
    @DataTransferObject(converter = ObjectConverter.class)
    public class JsonReaderResponse<T> {

    @RemoteProperty
    public List<T> objectsToConvertToRecords;

    /**
    * @see Ext.data.JsonReader.successProperty
    */
    @RemoteProperty
    public boolean success;

    @RemoteProperty
    public int totalRecords;
    /**
    * Creates a {@link #success}ful JsonReaderResponse with the provided {@link #objectsToConvertToRecords}.
    * @param objectsToConvertToRecords
    */
    public JsonReaderResponse(List<T> objectsToConvertToRecords) {
    this.objectsToConvertToRecords = objectsToConvertToRecords;
    success = true;
    }

    public JsonReaderResponse(List<T> objectsToConvertToRecords,int totalRecords) {
    this.objectsToConvertToRecords = objectsToConvertToRecords;
    success = true;
    this.totalRecords=totalRecords;
    }
    /**
    * Creates an un{@link #success}ful JsonReaderResponse with null {@link #objectsToConvertToRecords}.
    * This signals the case where the client established a connection with the server,
    * but the server couldn't fulfill it (e.g., user doesn't have proper user credentials).
    * @param objectsToConvertToRecords
    */
    public JsonReaderResponse() {
    this.objectsToConvertToRecords = null;
    success = false;
    }
    }

  7. #17
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    @Praveen Adivi, when posting code, you should wrap it in CODE tags (use the # button of editor) or PHP tags.

  8. #18
    Sencha User
    Join Date
    Oct 2010
    Posts
    18
    Vote Rating
    0
    Praveen Adivi is on a distinguished road

      0  

    Default


    k will keep that in mind

Similar Threads

  1. Map JSON to a server side Java Object
    By ddanet in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 28 Sep 2010, 12:04 PM
  2. Grid, state and server side sorting
    By zerkms in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 20 Apr 2010, 1:49 PM
  3. Thoughts on dwr or json for java server side
    By sfwalter in forum Community Discussion
    Replies: 18
    Last Post: 27 Jan 2008, 7:51 AM
  4. Server-side sorting for grid (EXT ver1.1.1)
    By shr1975 in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 18 Oct 2007, 9:20 PM
  5. Access to grid from the server side Java Code
    By ash9122 in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 3 Jan 2007, 1:01 AM

Thread Participants: 3

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi