Page 1 of 5 123 ... LastLast
Results 1 to 10 of 44

Thread: xml reader- not able to trace my issue-help!

  1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    21

    Question xml reader- not able to trace my issue-help!

    Hi,

    This is my first stabb at ext

    Ext.onReady
    (
    function()
    {
    var RecordDef = Ext.data.Record.create([
    {name: 'Author', mapping: 'Author'}, // "mapping" property not needed if it's the same as "name"
    {name: 'Title', mapping: 'Title'},
    {name: 'Manufacturer', mapping: 'Manufacturer'},
    {name: 'ProductGroup', mapping: 'ProductGroup'} // This field will use "occupation" as the mapping.
    ]);
    var myReader = new Ext.data.XmlReader({

    record: "Item" // The repeated element which contains row information

    }, RecordDef);


    var dataStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
    reader: myReader
    });



    dataStore.load();
    var colModel = new Ext.grid.ColumnModel([
    {header: "Appraisal #", width: 120, dataIndex: 'Author'},
    {header: "Title", width: 180, dataIndex: 'Title'},
    {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
    {header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
    ]);


    var grid = new Ext.grid.Grid('grid-example', {ds: dataStore, cm: colModel});


    grid.render();

    Ext.MessageBox.show({msg: grid.getDataSource().getTotalCount() });


    //grid.getSelectionModel().selectFirstRow();



    }
    );




    This is my server side code which flushes out xml..

    PrintWriter out = response.getWriter();
    out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");


    out.write("<Item> "+
    " <Author>Sidney Sheldon</Author> " +
    " <Title>Are You Afraid of the Dark?</Title> " +
    " <Manufacturer>Warner Books</Manufacturer> " +
    " <ProductGroup>Book</ProductGroup> " +
    " </Item>");

    response.setHeader("Cache-Control", "no-cache");
    response.setContentType("text/xml");
    out.flush();

    I am able to see the xml returning from the server via firebug but the xml reader does not seem to be parsing becuase I see the table structure displayed but no records ( only one in my case) gets displayed.

    Any help appreciated.

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Looks OK. I think you just need to call load() last.

  3. #3
    Ext User
    Join Date
    Aug 2007
    Posts
    21

    Exclamation

    Thanks for your response.

    Tried the load() last. Still no avail.


    Ext.onReady(function() {

    var dataStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
    reader: new Ext.data.XmlReader({
    record: 'Item'

    }, [
    'Author', 'Title', 'Manufacturer', 'ProductGroup'
    ])
    });

    var colModel = new Ext.grid.ColumnModel([
    {header: "Author", width: 120, dataIndex: 'Author'},
    {header: "Title", width: 180, dataIndex: 'Title'},
    {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
    {header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
    ]);



    var grid = new Ext.grid.Grid('mygrid', {
    ds: dataStore,
    cm: colModel
    });
    grid.render();

    dataStore.load();


    });


    Server side code..

    import javax.servlet.http.*;

    public class AssignmentDownloadAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionErrors errors = new ActionErrors();
    ActionMessages msgs = new ActionMessages();

    // return value

    PrintWriter out = response.getWriter();
    out.write("<?xml?>");


    out.write("<dataset> <Item> "+
    " <Author>Sidney Sheldon</Author> " +
    " <Title>Are You Afraid of the Dark?</Title> " +
    " <Manufacturer>Warner Books</Manufacturer> " +
    " <ProductGroup>Book</ProductGroup> " +
    " </Item> </dataset>");

    response.setHeader("Cache-Control", "no-cache");
    response.setContentType("text/xml");
    out.flush();
    return null;

    }
    }




    Also another note, is it possible to get a ext 2.0 for evaluation. We are very interested but we need to prove the concept to management to get buy in.

    Thanks.

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    The only thing I can think of is that it didn't parse your XML response correctly.

    What does the response look like in Firebug's "Net" tab?

    What does http://extjs.com/deploy/ext/docs/out...r.html#xmlData look like in Firebug?

  5. #5
    Ext User
    Join Date
    Aug 2007
    Posts
    21

    Exclamation Attached pic from firebug returning good xml

    Current JS file

    Code:
    Ext.onReady(function() {
    
    var dataStore = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
            reader: new Ext.data.XmlReader({
                   record: 'Item'
                   
               }, [
                   'Author', 'Title', 'Manufacturer', 'ProductGroup'
               ])
        });
    
        	var colModel = new Ext.grid.ColumnModel([
    		{header: "Author", width: 120, dataIndex: 'Author'},
    		{header: "Title", width: 180, dataIndex: 'Title'},
    		{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
    		{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
    	]);
        
        
        
        var grid = new Ext.grid.Grid('mygrid', {
            ds: dataStore,
            cm: colModel
        });
        grid.render();
    
       
        dataStore.load();
        
         Ext.Msg.alert({msg: dataStore.reader.xmlData});
        });


    Current Server side


    Code:
    import java.io.PrintWriter;
    import java.util.*;
    
    import org.apache.struts.action.*;
    
    
    
    
    import javax.servlet.http.*;
    
    public class AssignmentDownloadAction extends Action {
    
    	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    		ActionErrors errors = new ActionErrors();
    		ActionMessages msgs = new ActionMessages();
    		
    		// return value
    		
    		PrintWriter out = response.getWriter();	
    			out.write("<?xml?>");
    		
    		
    		out.write("<dataset>  <Item> "+
    			"			<Author>RC Sproull</Author> " +
    			"		<Title>Are You Afraid of the Dark?</Title> " +
    			" 		<Manufacturer>Warner Books</Manufacturer> " +
    			"		<ProductGroup>Book</ProductGroup>  </Item>	" +
    		"		 <Item> 	<Author>Monergism </Author> " +
    		"		<Title>Commentary</Title> " +
    		" 		<Manufacturer>Warner Books</Manufacturer> " +
    		"		<ProductGroup>Book</ProductGroup> 	" +
    		
    			"	</Item> </dataset>");
    			
    		response.setHeader("Cache-Control", "no-cache");	
    		response.setContentType("text/xml");
    		out.flush();
    		return null;
    
    	}
    }
    Attached Images Attached Images
    Last edited by ajay; 21 Aug 2007 at 5:08 AM. Reason: pics not clear

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Yes, but is it successfully parsing that XML?

    You need to stop in Firebug and examine http://extjs.com/deploy/ext/docs/out...r.html#xmlData

  7. #7
    Ext User
    Join Date
    Aug 2007
    Posts
    21

    Exclamation

    I expanded all the fields under "reader" which is the instance of XMLReader in Firebug but could not find the xmlData field that you pointed me to.

    My guess is that it is not parsing the xml file.


    However as I pointed out earlier the XML is returning from the server side as seen in the net tab of firebug.

    Would you know under what other subfield xmlData could be hidden in?

    Thanks.
    Attached Images Attached Images
    Last edited by ajay; 21 Aug 2007 at 5:23 AM. Reason: missing word

  8. #8
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Post

    try:

    Code:
    grid.render();
    
    Ext.Ajax.on( {'requestexception',function(){console.log(['requestexception',arguments])}
    ,{'requestcomplete',function(){console.log(['requestcomplete',arguments])}
       });
       
        dataStore.load();
    Then, start snooping at the response object's responseXML property and see if you have any 'parsererror' nodes in the XML doc. Are the XML result well-formed ?
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    If you examined that after the load, then it's definitely not parsing it.

    Copy the XML text from the Firebug response tab and paste it into an XML editor to check it's OK.

    But it could be to do with your content type.

    Try "application/xml"

    Something in here about "text/xml" and unspecified character encoding...

    http://www.rfc-editor.org/rfc/rfc3023.txt

  10. #10
    Ext User
    Join Date
    Aug 2007
    Posts
    21

    Default Missing propertyId

    Could go any further..see pic

    Thanks.
    Attached Images Attached Images

Page 1 of 5 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •