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());