| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/06/2009 14:34:23
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
Hi
I am trying to do the following:
I have two Grid Tables in my form, each with their own SQLDataModel
and each with a pageSize of 10.
The first Grid Table is a list of customer contracts with the Contract No. being the key. In the first column of this Grid Table, I have a button called
"Fetch Detail". This button gets the Contract No. of the row, and then finds all payments for this contract. This data is shown in a second Grid Table.
My code works fine, but only on the first page of the Grid Table. If I go to any other page, then getRowData() does not return the correct value.
Is this a bug.
My JSP Code for the first and second Grid Tables is as follows:
<e:gridtable ajax="true"
pageSize="10"
id="gridMasterTable"
keyField="contract_no"
binding="#{DataBean.gridMasterTable}"
dataModel="#{DataBean.sqlMasterDataModel}"
title="Contracts per Financial Year">
<e:dataTr>
<e:gridTd id="commandColumn"
sortable="false">
<e:button ajax="true"
id="filterButton"
style="font-size:10px"
value="Fetch Detail"
actionListener="#DataBean.filterContract}"/>
</e:gridTd>
<e:gridTd id="contract_no"
labelText="Contract No."
sortable="false"
value="#{ROW.contract_no}"/>
</e:dataTr>
</e:gridtable>
<e:gridtable ajax="true"
pageSize="10"
id="gridDetailTable"
keyField="contract_no, payment_no"
dataModel="#{DataBean.sqlDetailDataModel}"
title="Payments Per Contract">
<e:dataTr>
<e:gridTd id="contract_no"/>
<e:gridTd id="payment_no"/>
</e:dataTr>
</e:gridtable>
My Java Code to filter the sqlDetailDataModel is as follows:
public SQLDataModel getSqlMasterDataModel() {
if (sqlMasterDataModel == null) {
sqlMasterDataModel = new SQLDataModel();
sqlMasterDataModel.setSqlSelect("SELECT contract_no FROM master_table");
}
return sqlMasterDataModel;
}
public SQLDataModel getSqlDetailDataModel() {
if (sqlDetailDataModel == null) {
setSqlDetailDataModel(new SQLDataModel());
sqlDetailDataModel.setSqlSelect("SELECT contract_no, payment_no FROM detail_table");
}
return sqlDetailDataModel;
}
public void filterContract(ActionEvent e) {
sqlFieldMap = (SQLFieldMap) gridMasterTable.getRowData();
vContractNo = sqlFieldMap.get("contract_no").toString();
sqlDetailDataModel.setSqlSelect("SELECT * FROM detail_table WHERE contract_no = '" + vContractNo + "'");
}
Like I said, the above code works fine, but only on the first page of the Grid Table. As soon as I start paging through the Grid Table, the "Fetch Detail" button starts behaving unpredictably.
Is this a bug, or am I doing something wrong?
Thanks
Kuben
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/07/2009 08:37:07
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
Hi Kuben,
I've made an example based on your code, and everything works fine on my side. I attached my files below. Please run my code into your environment and let me know if you still have problems.
PS: my backingbean has session scope.
| Filename |
gridDependsOnGrid.jsp |
Download
|
| Description |
|
| Filesize |
2 Kbytes
|
| Downloaded: |
175 time(s) |
| Filename |
GridSQLDataModel.java |
Download
|
| Description |
|
| Filesize |
2 Kbytes
|
| Downloaded: |
175 time(s) |
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/07/2009 13:30:14
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
Hi Adina
I have tried running your example, and I an having the same problem. Everything works great on the first page of the Master Grid Table. As soon as I use the paging buttons and do to another page, then it does not work. It fails with a java.lang.NullPointerException on the following code:
sqlFieldMap = (SQLDataModel.SQLFieldMap) gridMasterTable.getRowData();
NB: I am using patch version .1720 of the ecruiser jar. Can this have anything to do with it. Although I have also tested it with the original jar and I still have that problem.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/08/2009 05:52:29
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
I also have tested the example with both original .jar and with patch 1720, and I couldn't reproduce the problem. I used Tomcat 6.0.18 and Sun Application Server 9.1.
Considerring this, I would like to see the full stack trace of the NPE exception, because I suspect that your problem might be related with the dataBase, and not with Ecruiser code.
BTW: what dataBase are you using?
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/09/2009 08:21:15
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
Hi
I created a new project in Netbeans, with just your JSP and Java Programs.
I no longer get the NPE, but it still does not work.
I am using an Oracle 10g Database.
Regards
Kuben
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/11/2009 07:50:26
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
It will still be useful for us to see that NPE stack trace.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/11/2009 11:18:10
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
Hi
I am not getting the NPE anymore.
I have tried your code on both Oracle and Java Derby databases.
I have also tried running page on IE, Firefox, and Netscape.
I am running Sun Glassfish V2 (Sun Application Server 9.1) on Windows XP.
The behaviour that it is exhibiting is as follows:
On the first page of the DataTable, I can click on the row, and it fetches the detail. On the second page it also returns a value on the first row, although this value is from the first page. All other rows and pages do nothing. If I debug on the client side, nothing happens when I click on a row on the second page.
Any ideas will be appreciated.
Regards
Kuben
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/12/2009 11:54:14
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
Try to run this SQL query directly in Oracle:
where vContractNo is a value from the second page of the grid and see what you get. Check if you have consistent data into your dataBase.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/13/2009 08:18:33
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
Ran the query in Oracle and n Java Derby and it works for all cases.
Is it possible for you to send me a WAR file with your code that works, and I will deploy it on my side and see what it does. If you use Netbeans, and the Java Derby database then I should be able to run it on my side. Or even if you just send me the database structure and data I need to run it, I can always create it.
Thanks
Kuben
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/13/2009 11:30:57
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
Here's my .war file. I used Hypersonic for database in this example. You can see the table's structure in nwind-acess-xp.jar/nwind-acess-xp.script.
I've made a test also on Oracle db, using this structure, and it worked fine. Try it also on your side.
Adina
| Filename |
gridModel.war |
Download
|
| Description |
|
| Filesize |
4808 Kbytes
|
| Downloaded: |
92 time(s) |
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/13/2009 21:34:11
|
kuben@itaware.co.za
Joined: 03/26/2009 05:40:00
Messages: 11
Offline
|
The .war file works. Please could you send me the source code.
I will compare with my existing project to see why mine is not working.
Thanks
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 05/14/2009 05:11:48
|
adina_mihai
Simplica Team
Joined: 04/01/2007 00:00:00
Messages: 180
Offline
|
Here's the source code.
Adina
| Filename |
GridSQLDataModel.java |
Download
|
| Description |
Source code for previous .war file |
| Filesize |
2 Kbytes
|
| Downloaded: |
117 time(s) |
|
|
|
 |
|
|