PDA

View Full Version : Html Layout Use Ext components ! !



sunder
19 Aug 2010, 2:48 AM
Hi

One question. Instead of placing the HTML inline in the code with the "HTML" con fig, how can I reference an HTML table from some other file? The reason I ask is that it is much cleaner (especially on a complex table) to have this in a separate file.

Thanks.


Sunder

Condor
19 Aug 2010, 3:05 AM
You could use autoLoad to the the HTML fragment or you could use your server-side language to import the HTML fragment into your main HTML file.

sunder
3 Sep 2010, 3:49 AM
Hi,

I am new to extjs. I want to make a web application based on EXTJS application with struts1.2.
My problem is that:-

I have a page (html) which have some textfield and create this with FormPanel. (register.js)
Textfields are firstname, lastname, city, state, country.
I have action class (RegisterAction.java)
I got all textfied value and perform some business logic inside action class after getting those values I want to display those values on the page.

So please anybody tell me the possible way how I can display those values on the page.

I tried it on my end with the help of JSON.
I am writing some code of my point of view which I had tried, please anybody tell me how much this code is fine. If I am wrong please give me suggestions how I can display these values on page.
I got all textfied value in action class and I add these values in Arraylist and that Arraylist I convert into json object.
1.RegisterAction.java
List list=new Arraylist ();
list.add(firstname);
list.add(lastname);
list.add(email);
list.add(state);
list.add(city);
list.add(country);

JSONArray jsonArray = JSONArray.fromObject (list);
String showJsonObject=jsonArray.toString ();

PrintWriter pw=response.getWriter ();
pw.write (showJsonObject);

Now I want display that json object on other page (showData.js).
I read EXTJS API through this I understood that we can do it through Ext.data.Store and Ext.data.JsonReader.

I tried it on my code but I am unable to display json objects on the page.

2.ShowData.js
Ext.onReady(function()
{
var myReader = new Ext.data.JsonReader(
{root: 'showjsonObject'}, ['firstname','lastname','email','city','state','country']
);

var dataFromServer = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'/register.do'}),
reader: myReader
});


dataFromServer.on('load', function() {


var grid = new Ext.grid.GridPanel({
store: dataFromServer,
columns: [
{header: 'FirstName', width: 90, sortable: true, dataIndex: 'firstname'},
{header: 'LastName', width: 90, sortable: true, dataIndex: 'lastname'},
{header: 'Email', width: 90, sortable: true, dataIndex: 'email'},
{header: 'City', width: 90, sortable: false, dataIndex: 'city'},
{header: 'State', width: 90, sortable: false, dataIndex: 'state'},
{header: 'Country', width: 90, sortable: false, dataIndex: 'country'}
]
});
});

dataFromServer.load();
});
Can anybody tell me what code should be written inside show.js?
What code should be needed to display json object on the page.

Anybody please give me sample code and some guidance so that I can make application.