This comes from a book I read about reading files from the server,
might be what you are looking for.  It reads a simple text file

                RequestBuilder requestBuilder = new RequestBuilder
( RequestBuilder.GET, "movies.txt" );
                try {
                        requestBuilder.sendRequest( null, new RequestCallback(){

                                public void onError(Request request, Throwable 
exception) {
                                        GWT.log( "failed getting movie list", 
exception );
                                }

                                public void onResponseReceived(Request request, 
Response response)
{
                                        words = response.getText().split("\n");
                                        startGame();
                                }} );
                } catch (RequestException e) {
                        GWT.log( "failed getting movie list", e );
                }


The book is called Goolge Web Toolkit Applications, the only problem
is the code is written for 1.5 not the latest.  I have not tried this
on 1.6


On Apr 20, 9:49 am, Gabriel Ernesto Gutierrez Añez
<[email protected]> wrote:
> perhaps, fetchData() and then create()
>
> Regards,
> _____________________
> Ing. Gabriel Gutiérrez
>
> On Mon, Apr 20, 2009 at 9:48 AM, Gabriel Ernesto Gutierrez Añez <
>
>
>
> [email protected]> wrote:
> > sure, but you are using a DataSource class from smartgwt
>
> >http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/...
>
> > try doin create() at the end...
>
> > Regards,
> > _____________________
> > Ing. Gabriel Gutiérrez
>
> > On Mon, Apr 20, 2009 at 9:08 AM, Neo <[email protected]> wrote:
>
> >> Gabriel,
> >> I guess we can keep Smart GWT out of discussion ... What is the
> >> general way of creating and readings file in GWT ?
> >> Any suggestions ?
>
> >> On Apr 20, 7:01 pm, Gabriel Ernesto Gutierrez Añez
> >> <[email protected]> wrote:
> >> > Hum... I see, well... I've never worked with smartgwt. i think you can
> >> do
> >> > this in a less complicated way.
>
> >> > Regards,
> >> > _____________________
> >> > Ing. Gabriel Gutiérrez
>
> >> > On Mon, Apr 20, 2009 at 8:52 AM, Neo <[email protected]> wrote:
>
> >> > > I thought of this option but even that wont work out. I have a
> >> > > TreeGrid object and to populate it I have created a class which
> >> > > extends DataSource.
>
> >> > > TreeGrid treeGrid = new TreeGrid();
> >> > > TaskXmlDS taskXmlDS = TaskXmlDS.getInstance();
> >> > > treeGrid.setDataSource(taskXmlDS);
>
> >> > > import com.smartgwt.client.data.DataSource;
> >> > > import com.smartgwt.client.data.fields.DataSourceIntegerField;
> >> > > import com.smartgwt.client.data.fields.DataSourceTextField;
>
> >> > > public class TaskXmlDS extends DataSource {
>
> >> > >    private static TaskXmlDS instance = null;
>
> >> > >    public static TaskXmlDS getInstance() {
> >> > >        if (instance == null) {
> >> > >            instance = new TaskXmlDS("taskXmlDS");
> >> > >        }
> >> > >        return instance;
> >> > >    }
>
> >> > >    public TaskXmlDS(String id) {
>
> >> > >            setID(id);
> >> > >            setRecordXPath("/tasks/task");
>
> >> > >                DataSourceTextField taskNameField = new
> >> DataSourceTextField
> >> > > ("taskName", "Task Name" , 128);
> >> > >                DataSourceTextField taskNameDesc = new
> >> DataSourceTextField
> >> > > ("taskDesc", "Description", 100);
> >> > >                DataSourceTextField taskStartTime = new
> >> DataSourceTextField
> >> > > ("taskStartTime", "Start Time", 80);
> >> > >                DataSourceTextField taskEndTime = new
> >> DataSourceTextField
> >> > > ("taskEndTime", "End Time", 80);
>
> >> > >                DataSourceIntegerField taskIdField = new
> >> > > DataSourceIntegerField
> >> > > ("taskId", "Task ID");
> >> > >                taskIdField.setPrimaryKey(true);
> >> > >                taskIdField.setRequired(true);
>
> >> > >                DataSourceIntegerField taskParentId = new
> >> > > DataSourceIntegerField
> >> > > ("taskParentId", "Parent ID");
> >> > >                taskParentId.setRequired(true);
> >> > >                taskParentId.setForeignKey(id + ".taskId");
> >> > >                taskParentId.setRootValue("1");
>
> >> > >                setFields(taskIdField, taskParentId, taskNameField,
> >> > > taskNameDesc,
> >> > > taskStartTime, taskEndTime);
> >> > >                setDataURL("tasks.data.xml");
> >> > >                setClientOnly(true);
> >> > >    }
> >> > > }
>
> >> > > In the second last line of code I need to pass the name of an XML
> >> > > file.
> >> > > This is why I want to create a XML file.
>
> >> > > On Apr 20, 6:43 pm, Gabriel Ernesto Gutierrez Añez
> >> > > <[email protected]> wrote:
> >> > > > You don't have to create it, you can return the hole XML as an
> >> String.
>
> >> > > > Regards,
> >> > > > _____________________
> >> > > > Ing. Gabriel Gutiérrez
>
> >> > > > On Mon, Apr 20, 2009 at 8:28 AM, Neo <[email protected]>
> >> wrote:
>
> >> > > > > Hi,
>
> >> > > > > In my server side code I fetch some data from the database and
> >> create
> >> > > > > an ArrayList. The list holds the database's data. Next, I  create
> >> a
> >> > > > > XML file using the data in the arraylist. When I try to create a
> >> file
> >> > > > > the file gets created in the project's root directory instead of
> >> > > > > getting created in the current directory ,i.e, the "server"
> >> directory.
> >> > > > > This is the line of code I am using :
>
> >> > > > > package com.myorg.gwt.desk.server;
>
> >> > > > > public class ProdDeskServerUtil {
>
> >> > > > >         public static void writeListToFile(List<Task> taskList)
> >> > > > >         {
> >> > > > >                 Iterator<Task> taskListIterator =
> >> taskList.iterator();
> >> > > > >                 PrintWriter out = null;
> >> > > > >                 try
> >> > > > >                 {
> >> > > > >                        out = new PrintWriter(new
> >> > > > > FileOutputStream("tasks.data.xml"));
> >> > > > >                         ......
> >> > > > >                 }
> >> > > > >        }
> >> > > > > }
>
> >> > > > > How can i create a file in the current directory  ?
>
> >> > > > > Once the file gets created how should i read the file from the
> >> client
> >> > > > > side code ?
>
> >> > > > > My aim is to feed this XML file into  a TreeView widget.- Hide 
> >> > > > > quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to