GridPanel reconfigure

70 views
Skip to first unread message

hhiranan

unread,
Apr 3, 2008, 10:58:42 AM4/3/08
to GWT-Ext Developer Forum
I tried posting in my other thread, but it seems not to work, Maybe my
post was too long or something. Here we go again.

I have rewritten my code to use GridPanel.reconfigure. The problem now
is much worse. I know that reconfigure is a requisite for dynamically
loading data into GridPanel, so I am going this way. Below is all the
code that is involved.

////////////////////////////////////-----------
StatusAggregates / StatusAggregatesAsync / StatusAggregatesImpl
////////////////////
public interface StatusAggregates extends RemoteService
{
public CurrentStatusAggregatesDO[] getStatusAggregates (String
token) ;
public static class App
{
private static StatusAggregatesAsync ourInstance = null;

public static synchronized StatusAggregatesAsync getInstance()
{
if (ourInstance == null)
{
ourInstance = (StatusAggregatesAsync)
GWT.create(StatusAggregates.class);
((ServiceDefTarget)
ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() +
"com.trafficland.vqm.VQM/StatusAggregates");
}
return ourInstance;
}
}
}

////////////////////
public interface StatusAggregatesAsync
{
void getStatusAggregates(String token, AsyncCallback async);
}

////////////////////

public class StatusAggregatesImpl extends RemoteServiceServlet
implements StatusAggregates
{

public CurrentStatusAggregatesDO[] getStatusAggregates(String
token)
{
try
{
return CurrentStatusAggregatesDAO.getAggregates();
}
catch (Exception e)
{
return null ;
}
}

}

----------////////////////////////////////////

////////////////////////////////////-----------
StatusSummary & Module:
////////////////////
public class StatusSummary extends Module
{
private Panel containerPanel ;
private GridPanel tablePanel ;
private Panel chartPanel ;
private Object [][] data ;
private int[] levelChartData ;
private String[] levelChartDataLabels ;
private Store store ;

public StatusSummary()
{

this.setLayout(new FitLayout());
containerPanel = new Panel ();
containerPanel.setLayout(new HorizontalLayout(10));

tablePanel = new GridPanel () ;
tablePanel.setLayout(new FitLayout());
chartPanel = new Panel () ;

data = new Object [][] {
{"application error: remote call for data was not
made" }
};

final RecordDef recordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("count"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("level"),
}
);


final RecordDef errorRecordDef = new RecordDef(
new FieldDef[]{
new StringFieldDef("description"),
}
);

MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(errorRecordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

final ColumnConfig[] columns = new ColumnConfig[]{
//column ID is company which is later used in
setAutoExpandColumn
new ColumnConfig("Count", "count", 45, true, null,
"count"),
new ColumnConfig("Status Title", "title", 180, true,
null, "title"),
new ColumnConfig("Status Description", "description",
400, true, null, "description"),
new ColumnConfig("Status Level", "level", 70, true,
null, "level"),
};

final ColumnConfig[] errorColumns = new ColumnConfig[]{
//column ID is company which is later used in
setAutoExpandColumn
new ColumnConfig("Problem Description", "description",
400, true, null, "description"),
};

final ColumnModel columnModel = new ColumnModel(columns);

final ColumnModel errorColumnModel = new
ColumnModel(errorColumns);
tablePanel.setColumnModel(errorColumnModel);

tablePanel.setFrame(true);
tablePanel.setStripeRows(true);

tablePanel.setTitle("Status Aggregate Table");
containerPanel.add(tablePanel);

chartPanel.setTitle("Chart");

String imgurl = "http://chart.apis.google.com/chart?
cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World" ;
Image chartImage = new Image(imgurl) ;
chartPanel.add(chartImage);

containerPanel.add(chartPanel);


StatusAggregates.App.getInstance().getStatusAggregates("test",
new AsyncCallback() {

public void onFailure(Throwable caught)
{
data = new Object [][] {
{"service/network error: call to database
failed" }
};

reloadData (errorColumnModel, errorRecordDef);
}

public void onSuccess(Object result)
{
if (result == null)
{
data = new Object [][] {
{"data error: dataset returned was null or
non existant" }
};

reloadData (errorColumnModel, errorRecordDef);
}
else
{
CurrentStatusAggregatesDO[] temp =
(CurrentStatusAggregatesDO[])result;
if (temp.length > 0)
{
data = new Object [temp.length][3];
levelChartData = new int[4];
levelChartDataLabels = new String[4];
for (int i = 0 ; i < temp.length ; i ++)
{
data [i][0] = new
Integer(temp[i].getCount());
data [i][1] =
(temp[i].getStatus().getTitle());
data [i][2] =
(temp[i].getStatus().getDescription());
data [i][3] =
(temp[i].getStatus().getStatusLevelDO());


levelChartData[temp[i].getStatus().getStatusLevelDO().getId()-1] ++ ;
if
(levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
== null)

levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
=

temp[i].getStatus().getStatusLevelDO().getDescription() ;
}

reloadData (columnModel, recordDef);
}
else
{
data = new Object [][] {
{"data error: dataset returned was
empty" }
};

reloadData (errorColumnModel, errorRecordDef);
}

}


}
});

}

private void reloadData(ColumnModel columns, RecordDef recordDef)
{
if (store != null) {
store.removeAll();
}

MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();

tablePanel.reconfigure(store, columns);
}

}

////////////////////
public class Module extends Panel
{
private ModuleID moduleID ;
private String token ;

public ModuleID getModuleIdentifier ()
{
return moduleID ;
}

public void setModuleIdentifier (ModuleID mID)
{
moduleID = mID ;
}

public void setToken (String token)
{
this.token = token;
}

public String getToken ()
{
return token;
}
}

----------////////////////////////////////////


Any more info can be provided as needed. I am watching this thread
vigilantly until 5/6 PM EST US time.

Please help.

Thanks.

-H

leo_BsAs

unread,
Apr 3, 2008, 11:45:32 AM4/3/08
to GWT-Ext Developer Forum
Hi hhiranan,
Did you try to use firebug for firefox to see if you have an error?
It's very helpful...

In the other hand... I'm reviewing your code to detect some
problems...

One tip:
Sometimes... if the data in one field in one record is different of
the type that you have declared or is missing or is null, perhaps it
breaks the load/reload mechanism...

Leo

leo_BsAs

unread,
Apr 3, 2008, 11:54:19 AM4/3/08
to GWT-Ext Developer Forum
Another way to do the same:
As you know... in hte GridView there is a methos called "setEmptyText"
where set the text when there is no data to display...
You could set differents text to the GridView when you get an error
from the service... and the refresh the view...
(I could'nt test it, but sounds logic). Eg:

grid.getView().setEmptyText("ERROR!");
grid.getView().refresh();

In this way you don't have to redefine the grid every time you get an
error... Just configure it once, and the play with the setEmptyText
stuff...

I hope it helps you...

Leo

hhiranan

unread,
Apr 3, 2008, 12:47:58 PM4/3/08
to GWT-Ext Developer Forum
Thanks for the help. I'll give it a try and let you know in a few.
> ...
>
> read more »

hhiranan

unread,
Apr 3, 2008, 1:38:46 PM4/3/08
to GWT-Ext Developer Forum
Still have the same problem

Here is the new code:


public class StatusSummary extends Module
{
private Panel containerPanel ;
private GridPanel tablePanel ;
private Panel chartPanel ;
private Object [][] data ;
private int[] levelChartData ;
private String[] levelChartDataLabels ;
private Store store ;

public StatusSummary()
{

this.setLayout(new FitLayout());
containerPanel = new Panel ();
containerPanel.setLayout(new HorizontalLayout(10));

tablePanel = new GridPanel () ;
tablePanel.setLayout(new FitLayout());
chartPanel = new Panel () ;

tablePanel.getView().setEmptyText("APPLICATION ERROR: remote
call for data has not been made");

tablePanel.setTitle("Status Aggregate Table");
containerPanel.add(tablePanel);

chartPanel.setTitle("Chart");

String imgurl = "http://chart.apis.google.com/chart?
cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World" ;
Image chartImage = new Image(imgurl) ;
chartPanel.add(chartImage);

containerPanel.add(chartPanel);


StatusAggregates.App.getInstance().getStatusAggregates("test",
new AsyncCallback() {

public void onFailure(Throwable caught)
{
tablePanel.getView().setEmptyText("SERVICE/NETWORK
ERROR: call to remote service failed");
}

public void onSuccess(Object result)
{
if (result == null)
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was null or non-existant");
}
else
{
CurrentStatusAggregatesDO[] temp =
(CurrentStatusAggregatesDO[])result;
if (temp.length > 0)
{
data = new Object [temp.length][3];
levelChartData = new int[4];
levelChartDataLabels = new String[4];
for (int i = 0 ; i < temp.length ; i ++)
{
data [i][0] = new
Integer(temp[i].getCount());
data [i][1] =
(temp[i].getStatus().getTitle());
data [i][2] =
(temp[i].getStatus().getDescription());
data [i][3] =
(temp[i].getStatus().getStatusLevelDO());


levelChartData[temp[i].getStatus().getStatusLevelDO().getId()-1] ++ ;
if
(levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
== null)

levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
=

temp[i].getStatus().getStatusLevelDO().getDescription() ;
}

reloadData ();
}
else
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was empty");
}
}
}
});
}

private void reloadData()
{
final RecordDef recordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("count"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("level"),
}
);

MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

final ColumnConfig[] columns = new ColumnConfig[]{
//column ID is company which is later used in
setAutoExpandColumn
new ColumnConfig("Count", "count", 45, true, null,
"count"),
new ColumnConfig("Status Title", "title", 180, true,
null, "title"),
new ColumnConfig("Status Description", "description",
400, true, null, "description"),
new ColumnConfig("Status Level", "level", 70, true,
null, "level"),
};


final ColumnModel columnModel = new ColumnModel(columns);

tablePanel.setColumnModel(columnModel);

tablePanel.setFrame(true);
tablePanel.setStripeRows(true);
}

}


hhiranan

unread,
Apr 3, 2008, 1:42:19 PM4/3/08
to GWT-Ext Developer Forum
Also, using firebug, I get no errors on console. Furthermore, the div
that should contain all the content is completely empty

thanks again

H

On Apr 3, 11:54 am, leo_BsAs <aito...@yahoo.es> wrote:
> ...
>
> read more »

leo_BsAs

unread,
Apr 3, 2008, 3:00:53 PM4/3/08
to GWT-Ext Developer Forum
I have a few observations:

* A piece of your code is wrong... you declare a matrix of [n] x [3]
and then refers to the fourth position...

data = new Object [temp.length][3];
...
for (int i = 0 ; i < temp.length ; i ++)
{
data [i][0] = new
Integer(temp[i].getCount());
data [i][1] =
(temp[i].getStatus().getTitle());
data [i][2] =
(temp[i].getStatus().getDescription());
data [i][3] =
(temp[i].getStatus().getStatusLevelDO());

* In addition, after you set an empty message you should call:
tablePanel.getView().refresh();

* When you reload the store, try it in this way...
your code:
MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

suggestion:
MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
Store tmpStore = new Store(proxy, reader);
tmpStore.load();

tablePanel.getStore().removeAll();
tablePanel.getStore().add(tmpStore.getRecords());

I hope it work...

regards...

Leo
> ...
>
> read more »

hhiranan

unread,
Apr 3, 2008, 3:07:48 PM4/3/08
to GWT-Ext Developer Forum
Changed the code to fix the obvious problem. Nothing is adding the
table to the 'this' panel.

public class StatusSummary extends Module
{
private Panel containerPanel ;
private GridPanel tablePanel ;
private Panel chartPanel ;
private Object [][] data ;
private int[] levelChartData ;
private String[] levelChartDataLabels ;
private Store store ;

public StatusSummary()
{

this.setLayout(new FitLayout());
containerPanel = new Panel ();
containerPanel.setLayout(new HorizontalLayout(10));

tablePanel = new GridPanel () ;
tablePanel.setLayout(new FitLayout());
chartPanel = new Panel () ;

tablePanel.getView().("APPLICATION ERROR: remote call for data
has not been made");

tablePanel.setTitle("Status Aggregate Table");
containerPanel.add(tablePanel);

this.add(tablePanel);

StatusAggregates.App.getInstance().getStatusAggregates("test",
new AsyncCallback() {

public void onFailure(Throwable caught)
{
tablePanel.getView().setEmptyText("SERVICE/NETWORK
ERROR: call to remote service failed");
}

public void onSuccess(Object result)
{
if (result == null)
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was null or non-existant");
}
else
{
CurrentStatusAggregatesDO[] temp =
(CurrentStatusAggregatesDO[])result;
if (temp.length > 0)
{
data = new Object [temp.length][3];
levelChartData = new int[4];
levelChartDataLabels = new String[4];
for (int i = 0 ; i < temp.length ; i ++)
{
data [i][0] = new
Integer(temp[i].getCount());
data [i][1] =
(temp[i].getStatus().getTitle());
data [i][2] =
(temp[i].getStatus().getDescription());
data [i][3] =
(temp[i].getStatus().getStatusLevelDO());


levelChartData[temp[i].getStatus().getStatusLevelDO().getId()-1] ++ ;
if
(levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
== null)

levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
=

temp[i].getStatus().getStatusLevelDO().getDescription() ;
}

loadData ();
}
else
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was empty");
}
}
}
});
}

private void loadData()
{
RecordDef recordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("count"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("level"),
}
);

MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

ColumnConfig[] columns = new ColumnConfig[]{
//column ID is company which is later used in
setAutoExpandColumn
new ColumnConfig("Count", "count", 45, true, null,
"count"),
new ColumnConfig("Status Title", "title", 180, true,
null, "title"),
new ColumnConfig("Status Description", "description",
400, true, null, "description"),
new ColumnConfig("Status Level", "level", 70, true,
null, "level"),
};


ColumnModel columnModel = new ColumnModel(columns);

tablePanel.setColumnModel(columnModel);

tablePanel.setFrame(true);
tablePanel.setStripeRows(true);

}
}

hhiranan

unread,
Apr 3, 2008, 3:19:26 PM4/3/08
to GWT-Ext Developer Forum
I moved from reloading data every time status changes occurred to only
loading it once, and put all the suggestions you made, other than the
store refactoring, in place.

I also did some testing with the RPC to see what's going on there. I
got what I expected.

Now, for no apparent reason, whenever i try to load this panel, I see
it start to load, with no content, and then suddenly the page
refreshes.

Odd behavior. I am working on debugging it right now.


Below is the current state of my code.

Thanks again for taking a look.

_H



public class StatusSummary extends Module
{
private Panel containerPanel ;
private GridPanel tablePanel ;
private Panel chartPanel ;
private Object [][] data ;
private int[] levelChartData ;
private String[] levelChartDataLabels ;
private Store store ;

public StatusSummary()
{

this.setLayout(new FitLayout());
containerPanel = new Panel ();
containerPanel.setLayout(new HorizontalLayout(10));

tablePanel = new GridPanel () ;
tablePanel.setLayout(new FitLayout());
chartPanel = new Panel () ;

tablePanel.getView().setEmptyText("APPLICATION ERROR: remote
call for data has not been made");

tablePanel.setTitle("Status Aggregate Table");
containerPanel.add(tablePanel);

this.add(tablePanel);

StatusAggregates.App.getInstance().getStatusAggregates("test",
new AsyncCallback() {

public void onFailure(Throwable caught)
{
tablePanel.getView().setEmptyText("SERVICE/NETWORK
ERROR: call to remote service failed");
tablePanel.getView().refresh();
}

public void onSuccess(Object result)
{
if (result == null)
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was null or non-existant");
tablePanel.getView().refresh();
}
else
{
CurrentStatusAggregatesDO[] temp =
(CurrentStatusAggregatesDO[])result;
if (temp.length > 0)
{
data = new Object [temp.length][4];
levelChartData = new int[4];
levelChartDataLabels = new String[4];
for (int i = 0 ; i < temp.length ; i ++)
{
data [i][0] = new
Integer(temp[i].getCount());
data [i][1] =
(temp[i].getStatus().getTitle());
data [i][2] =
(temp[i].getStatus().getDescription());
data [i][3] =
(temp[i].getStatus().getStatusLevelDO());


levelChartData[temp[i].getStatus().getStatusLevelDO().getId()-1] ++ ;
if
(levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
== null)

levelChartDataLabels[temp[i].getStatus().getStatusLevelDO().getId()-1]
=

temp[i].getStatus().getStatusLevelDO().getDescription() ;
}

loadData ();
}
else
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was empty");
tablePanel.getView().refresh();
}
}
}
});
}

private void loadData()
{
RecordDef recordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("count"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("level"),
}
);

MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

ColumnConfig[] columns = new ColumnConfig[]{
//column ID is company which is later used in
setAutoExpandColumn
new ColumnConfig("Count", "count", 45, true, null,
"count"),
new ColumnConfig("Status Title", "title", 180, true,
null, "title"),
new ColumnConfig("Status Description", "description",
400, true, null, "description"),
new ColumnConfig("Status Level", "level", 70, true,
null, "level"),
};

ColumnModel columnModel = new ColumnModel(columns);
tablePanel.setColumnModel(columnModel);

tablePanel.setFrame(true);
tablePanel.setStripeRows(true);
}

}

leo_BsAs

unread,
Apr 3, 2008, 3:41:26 PM4/3/08
to GWT-Ext Developer Forum
Did you try this suggestion?

* When you reload the store, try it in this way...
your code:
MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);
store = new Store(proxy, reader);
store.load();
tablePanel.setStore(store);

suggestion:
MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);

Store tmpStore = new Store(proxy, reader);
tmpStore.load();

tablePanel.getStore().removeAll();
tablePanel.getStore().add(tmpStore.getRecords());

Instead of setting a new Store every time you call your reload method,
try to create a new Store to load the data, and then pass to the grid
store the new records...

hhiranan

unread,
Apr 3, 2008, 4:33:00 PM4/3/08
to GWT-Ext Developer Forum
Thanks for all the help so far. I tried your most recent suggestion.
Every variation of it failed and caused the same problem. The page
would reload every time the StatusSummary panel is loaded. I am
certain this is due to the fact that I no longer reload data. I only
loads it once. If it's not loaded, I assume that the EmptyText is what
will be shown.

LEO: Thanks again for helping me out so much. I'm going to continue to
work on it.

If there's anything else you see that may be suspicious in the code,
let me know.

-H

leo_BsAs

unread,
Apr 3, 2008, 5:05:59 PM4/3/08
to GWT-Ext Developer Forum
Well... I rewrite your code according as I have been working with grid
panel... Try it...


public class StatusSummary extends Module
{
private Panel containerPanel ;
private GridPanel tablePanel ;
private Panel chartPanel ;
private Object [][] data = new Object[0][0] ;
private int[] levelChartData ;
private String[] levelChartDataLabels ;
private Store store ;

private RecordDef recordDef;

public StatusSummary()
{

setLayout(new FitLayout());
containerPanel = new Panel ();
containerPanel.setLayout(new HorizontalLayout(10));

initTable();
containerPanel.add(tablePanel);

chartPanel = new Panel () ;

this.add(containerPanel);

StatusAggregates.App.getInstance().getStatusAggregates("test",
new AsyncCallback() {

public void onFailure(Throwable caught)
{
tablePanel.getView().setEmptyText("SERVICE/NETWORK
ERROR: call to remote service failed");
tablePanel.getView().refresh();
data = new Object[0][0];
loadData();
}

public void onSuccess(Object result)
{
if (result == null)
{
tablePanel.getView().setEmptyText("DATA ERROR:
dataset returned was null or non-existant");
tablePanel.getView().refresh();
data = new Object[0][0];
loadData();
data = new Object[0][0];
loadData();

}
}
}
});
}

private void loadData()
{
MemoryProxy proxy = new MemoryProxy(data);
ArrayReader reader = new ArrayReader(recordDef);

if(store == null) {
store = new Store(proxy, reader);
store.load();
} else {
Store tmpStore = new Store(proxy, reader);
tmpStore.load();
tablePanel.getStore().removeAll();
tablePanel.getStore().add(tmpStore.getRecords());
}

}

public void initTable() {
recordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("count"),
new StringFieldDef("title"),
new StringFieldDef("description"),
new StringFieldDef("level"),
}
);

ColumnConfig[] columns = new ColumnConfig[]{
new ColumnConfig("Count", "count", 45, true, null,
"count"),
new ColumnConfig("Status Title", "title", 180, true,
null, "title"),
new ColumnConfig("Status Description", "description",
400, true, null, "description"),
new ColumnConfig("Status Level", "level", 70, true,
null, "level"),
};

loadData();
ColumnModel columnModel = new ColumnModel(columns);
tablePanel = new GridPanel("grid-id", 600, 400, store,
columnModel);
tablePanel.setLayout(new FitLayout());
tablePanel.setTitle("Status Aggregate Table");
tablePanel.setFrame(true);
tablePanel.setStripeRows(true);

GridView view = new GridView();
view.setEmptyText("APPLICATION ERROR: remote call for data has
not been made");
tablePanel.setView(view);
}


I hope it work... :)

Leo

hhiranan

unread,
Apr 7, 2008, 9:04:31 AM4/7/08
to GWT-Ext Developer Forum
Leo:

You are the man. Thank you for helping me resolve the issue.

-H

leo_BsAs

unread,
Apr 7, 2008, 1:52:57 PM4/7/08
to GWT-Ext Developer Forum
Did it work?

hhiranan

unread,
Apr 9, 2008, 4:49:04 PM4/9/08
to GWT-Ext Developer Forum
Fantastically. Everything worked well, i added some more custom code
to get it to look as per reqs.

I took that code and used it again, this time for a different
application and I'm having the same problem, where the page refreshes
every time the gridpanel is loaded. I tested the surrounding code, and
everything loads successfully. I have included the class in question
for your review. If/when you/anyone gets the chance to take a look. I
also tested the service/etc. I took the code directly from your
example, and my previously working code, so I was confident it should
work. Check it out. Right now i add the grid to the main panel to make
testing simpler, but give it a look.

CODE:

public class Search extends Module
{
private Panel searchPanel ;
private Panel queryPanel ;
private Panel execPanel ;
private FormPanel historicalFilters;

private GridPanel statusFilters;
private RecordDef statusRecordDef;
private Store statusStore;

private FormPanel locationFilters;
private FormPanel lengthFilters;
private FormPanel stateFilters;
private Panel resultsPanel ;
private Button searchExecButton ;

private Object [][] statusList = new Object [0][0];

private static Integer HP_TYPE_CURRENT = new Integer (0);
private static Integer HP_TYPE_SO_FAR = new Integer (1);
private static Integer HP_TYPE_TO_DATE = new Integer (2);
private static Integer HP_TYPE_CUSTOM_OF_DATE = new Integer (3);
private static Integer HP_TYPE_CUSTOM_BEFORE_DATE = new Integer
(4);
private static Integer HP_TYPE_CUSTOM_AFTER_DATE = new Integer
(5);
private static Integer HP_TYPE_CUSTOM_BETWEEN_DATES = new Integer
(6);
private static Integer HP_TYPE_CUSTOM_ALL_TIME = new Integer (7);

public Search()
{
initModule() ;
}

public Search(String qString)
{
initModule() ;
}

private void initModule ()
{
this.setLayout(new BorderLayout ());

queryPanel = new Panel ();
queryPanel.setLayout(new AccordionLayout());
queryPanel.setTitle("Search Filters");
historicalFilters = new FormPanel () ;
historicalFilters.setBorder(false);
historicalFilters.setPaddings(5);
final Store historicalPresetsStore = new SimpleStore(new
String [] {"label","value","type"}, getHistoricalPresets());

final ComboBox historicalPresets = new ComboBox () ;
historicalPresets.setForceSelection(false);
historicalPresets.setFieldLabel("Presets");
historicalPresets.setDisplayField("label");
historicalPresets.setStore(historicalPresetsStore);
historicalPresets.setMode(ComboBox.LOCAL);
historicalPresets.setEmptyText("Presets");
historicalPresets.setLoadingText("Searching...");
historicalPresets.setSelectOnFocus(true);
historicalPresets.setWidth(200);

DateField includeDate = new DateField ("Include Date",
"includeDate", 200);
includeDate.setDisabled(true);
DateField startDate = new DateField ("Start Date",
"startDate", 200);
startDate.setDisabled(true);
DateField endDate = new DateField ("End Date", "endDate",
200);
endDate.setDisabled(true);

historicalFilters.add(historicalPresets);
historicalFilters.add(includeDate);
historicalFilters.add(startDate);
historicalFilters.add(endDate);

historicalPresets.addListener(new ComboBoxListenerAdapter() {

public void onSelect(ComboBox comboBox, Record record, int
i)
{
super.onSelect(comboBox, record, i); //To change
body of overridden methods use File | Settings | File Templates.
}
});

initStatusTable();


//
// lengthFilters = new FormPanel () ;
// lengthFilters.setBorder(false);
// lengthFilters.setPaddings(5);
//
// stateFilters = new FormPanel () ;
// stateFilters.setBorder(false);
// stateFilters.setPaddings(5);
//
// locationFilters = new FormPanel () ;
// locationFilters.setBorder(false);
// locationFilters.setPaddings(5);
//
//
Panel historicalFilterPanel = new Panel () ;
Panel statusFilterPanel = new Panel () ;
statusFilterPanel.setLayout(new FitLayout());
// Panel lengthFilterPanel = new Panel () ;
// Panel stateFilterPanel = new Panel () ;
// Panel locationFilterPanel = new Panel () ;
//
historicalFilterPanel.setTitle ("Historical Filters");
statusFilterPanel.setTitle("Status Filters");
// lengthFilterPanel.setTitle("Status Length Filters");
// stateFilterPanel.setTitle("State Filters");
// locationFilterPanel.setTitle("Location Filters");
//
historicalFilterPanel.add(historicalFilters);
// statusFilterPanel.add(statusFilters);
// locationFilterPanel.add(locationFilters);
// lengthFilterPanel.add(lengthFilters);
// stateFilterPanel.add(stateFilters);
//

queryPanel.add(historicalFilterPanel);
// queryPanel.add(statusFilterPanel);
// queryPanel.add(locationFilterPanel);
// queryPanel.add(lengthFilterPanel);
// queryPanel.add(stateFilterPanel);

resultsPanel = new Panel ();
resultsPanel.add(new HTML("TEST"));

searchPanel = new Panel () ;
execPanel = new Panel () ;
execPanel.setTitle("");
execPanel.setHeight(60);
execPanel.setLayout(new HorizontalLayout (10)) ;

searchExecButton = new Button ("Execute Search",new
ButtonListenerAdapter () {
public void onClick(Button button, EventObject
eventObject)
{

}
});
searchExecButton.setIconCls("search-icon");
searchExecButton.setStyle("margin: 4px;");

execPanel.add(searchExecButton);

searchPanel.setLayout(new BorderLayout());
BorderLayoutData queryPanelLayoutData = new
BorderLayoutData(RegionPosition.CENTER);
BorderLayoutData execPanelLayoutData = new
BorderLayoutData(RegionPosition.SOUTH);

searchPanel.add(queryPanel, queryPanelLayoutData);
searchPanel.add(execPanel, execPanelLayoutData);
searchPanel.setCollapsible(true);
searchPanel.setWidth(330);
searchPanel.setTitle("Search Controls");

BorderLayoutData searchPanelLayoutData = new
BorderLayoutData(RegionPosition.WEST);
this.add(searchPanel, searchPanelLayoutData);

BorderLayoutData resultsPanelLayoutData = new
BorderLayoutData(RegionPosition.CENTER);
this.add(statusFilters, resultsPanelLayoutData);

// getStatusList();


}

private Object[][] getHistoricalPresets()
{
return new Object[][]{
new Object[]{"Currently", "now", HP_TYPE_CURRENT},
new Object[]{"Today", "this_day", HP_TYPE_SO_FAR},
new Object[]{"This Week", "this_week", HP_TYPE_SO_FAR},
new Object[]{"This Month", "this_month",
HP_TYPE_SO_FAR},
new Object[]{"This Quarter", "this_quarter",
HP_TYPE_SO_FAR},
new Object[]{"This Year", "this_year", HP_TYPE_SO_FAR},
new Object[]{"Last 24 Hours", "to_date_day",
HP_TYPE_TO_DATE},
new Object[]{"Last 7 Days", "to_date_week",
HP_TYPE_TO_DATE},
new Object[]{"Last 30 Days", "to_date_month",
HP_TYPE_TO_DATE},
new Object[]{"Last 90 Days", "to_date_quarter",
HP_TYPE_TO_DATE},
new Object[]{"Last 365 Days", "to_date_year",
HP_TYPE_TO_DATE},
new Object[]{"Interval of Date", "of_date",
HP_TYPE_CUSTOM_OF_DATE},
new Object[]{"Interval After Date", "after_date",
HP_TYPE_CUSTOM_BEFORE_DATE},
new Object[]{"Interval Before Date", "before_date",
HP_TYPE_CUSTOM_AFTER_DATE},
new Object[]{"Between Dates", "date_range",
HP_TYPE_CUSTOM_BETWEEN_DATES},
new Object[]{"Since the Dawn of Time", "forever",
HP_TYPE_CUSTOM_ALL_TIME}
};
}
private void getStatusList()
{
Status.App.getInstance().getAll(new AsyncCallback() {

public void onFailure(Throwable caught)
{
statusFilters.getView().setEmptyText("SERVICE/NETWORK
ERROR: call to remote service failed");
statusFilters.getView().refresh();
statusList = new Object[0][0];
loadStatusData();
}

public void onSuccess(Object result)
{
if (result instanceof StatusDO[])
{
StatusDO[] statuses = (StatusDO[]) result ;
statusList = new Object [statuses.length][4] ;
for (int i = 0 ; i < statuses.length ; i ++)
{
statusList[i][0] = new Integer
(statuses[i].getId());
statusList[i][1] = statuses[i].getTitle();
statusList[i][2] =
statuses[i].getStatusLevelDO().toString();
statusList[i][3] =
statuses[i].getDescription();
}

loadStatusData();
statusFilters.getView().refresh();

}
}
});
}

public void initStatusTable() {
statusRecordDef = new RecordDef(
new FieldDef[]{
new IntegerFieldDef("sid"),
new StringFieldDef("title"),
new StringFieldDef("level"),
new StringFieldDef("description"),
}
);

ColumnConfig[] columns = new ColumnConfig[]{ // make
renderers
// new ColumnConfig("ID", "sid", 50, true, null,
"sid"),
// new ColumnConfig("Name", "title", 180, true, new
Renderer(){
//
// public String render(Object object, CellMetadata
cellMetadata, Record record, int i, int i1, Store store)
// {
// if
(record.getAsString("level").endsWith("critical"))
// {
// cellMetadata.setHtmlAttribute("style=
\"background:#FFCCCC\"");
// }
// if
(record.getAsString("level").endsWith("error"))
// {
// cellMetadata.setHtmlAttribute("style=
\"background:#FFDD99\"");
// }
// if
(record.getAsString("level").endsWith("warning"))
// {
// cellMetadata.setHtmlAttribute("style=
\"background:#CCCCFF\"");
// }
// if
(record.getAsString("level").endsWith("green"))
// {
// cellMetadata.setHtmlAttribute("style=
\"background:#CCFFCC\"");
// }
// return record.getAsString("title"); //To
change body of implemented methods use File | Settings | File
Templates.
// }
// }, "title"),
new ColumnConfig("SID", "sid", 80, true, null, "sid"),
new ColumnConfig("Title", "title", 80, true, null,
"title"),
new ColumnConfig("Level", "level", 80, true, null,
"level"),
new ColumnConfig("Description", "description", 80,
true, null, "description")
};

// columns[0].setHidden(true);
// columns[2].setHidden(true);

loadStatusData();
ColumnModel columnModel = new ColumnModel(columns);
statusFilters = new
GridPanel("status_grid_"+this.getModuleIdentifier().getModuleTabID(),
250, 300, statusStore, columnModel);
statusFilters.setLayout(new FitLayout());
statusFilters.setPaddings(5);
statusFilters.setTitle("Select Status(es)");
statusFilters.setFrame(true);
statusFilters.setStripeRows(true);

/*
Toolbar top = new Toolbar () ;

ToolbarButton refreshButton = new ToolbarButton ("Refresh",
new ButtonListenerAdapter() {
public void onClick(Button button, EventObject
eventObject)
{
statusFilters.getEl().mask("Loading", "x-mask-
loading");
Timer timer = new Timer() {
public void run() {
tablePanel.getEl().unmask();
}
};
timer.schedule(500);
fetchLoadData () ;
}
});
refreshButton.setIconCls("refresh-icon");
top.addButton(refreshButton);


top.addSeparator();

ToolbarButton chartButton = new ToolbarButton ("View Chart",
new ButtonListenerAdapter() {
public void onClick(Button button, EventObject
eventObject)
{
if (chartWindow != null)
chartWindow.show();
}
});
chartButton.setIconCls("pie-chart-icon");
top.addButton(chartButton);

tablePanel.setTopToolbar(top);
*/

GridView view = new GridView();

view.setEmptyText("APPLICATION ERROR: remote call for data has
not been made");
statusFilters.setView(view);
}

private void loadStatusData()
{
MemoryProxy proxy = new MemoryProxy(statusList);
ArrayReader reader = new ArrayReader(statusRecordDef);

if(statusStore == null) {
statusStore = new Store(proxy, reader);
statusStore.load();
} else {
Store tmpStore = new Store(proxy, reader);
tmpStore.load();
statusFilters.getStore().removeAll();
statusFilters.getStore().add(tmpStore.getRecords());

leo_BsAs

unread,
Apr 10, 2008, 1:57:55 PM4/10/08
to GWT-Ext Developer Forum
Hi,
at first sight the only thing that I found was this:

resultsPanel = new Panel ();
resultsPanel.add(new HTML("TEST"));

try to set a FitLayout (or other) before add anything, eg:

resultsPanel = new Panel ();
resultsPanel.setLayout(new FitLayout());
resultsPanel.add(new HTML("TEST"));

Anyway... I'm reviewing deeper...

Leo

hhiranan

unread,
Apr 10, 2008, 4:55:51 PM4/10/08
to GWT-Ext Developer Forum
Thanks leo.

Even though i forgot the resultsPanel layout, it still worked. I've
been testing it, and the only thing that doesn't work is the darn
grid. Thing is driving me up the wall. I don't even know what's
missing/causing the error.

Thanks again.

_H

leo_BsAs

unread,
Apr 11, 2008, 5:03:05 PM4/11/08
to GWT-Ext Developer Forum
After many reviews... I don't get anything but the follows....
Try to replace all the time that you initialize the data matrix
(statuslist) as empty in this form 0xn
statuslist = new Object[0][4];

instead of

statuslist = new Object [0][0];


perhaps it is a problem of matching the column definitions with the
data...

I don't know if it works... but try...

Leo

hhiranan

unread,
Apr 14, 2008, 1:19:24 AM4/14/08
to GWT-Ext Developer Forum
I was able to fix it earlier today. Dumb mistake on my part. Although
the advice you give makes sense, i'll probably put it in place just to
be on the safe side.

Check out my most recent post. I employed a nice little trick with css/
gridpanel to shade my rows. You may like it.

Thanks a bunch for all your help.

-H
Reply all
Reply to author
Forward
0 new messages