CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Bug (?) in API when dealing with editable grids

Print topic Send  topic

Author Message
rashid11

Posts: 5
Posted: 06/26/2004, 11:36 AM

I have a bulk insert form, where a number of rows can be added to a table. Now, as I add ea new row to TableA (when form is posted and the code is executing on the server), I want to also insert a row, with different data, into TableB. To that end I have created an "After Insert " code. In the code I need to figure out what values certain Controls have FOR THAT PARTICULAR row.

I tried this code:

((Control)(e.getPage().getGrid("ASSET2").currentRow().get("ASSET_SERIAL"))).getFormattedValue() to get value of "ASSET_SERIAL" control for ea row of the grid. I do get a value back, but it doesn't change and is always that of the LAST RECORD in the grid. This is a bug ....

I tried go get it also via e.getPage.getGrid("GRIDNAME").getControl("ASSET_SERIAL") and still with the same result - value of the Control in the last row of the grid.

View profile  Send private message
Anton Hinxman
Posted: 06/28/2004, 12:47 AM

No, I do not think that this is a bug. Fortunately :-), most of the bugs are in the CCS IDE not in the generated code. What I think is going on is that, in the MVC paradigm, you are referring to the view portion which is spent whereas what you need to do is look at the grids data model instead – try this diagnostic code:

// AfterExecuteInsert event
Object assertSerialVal = e.getParameter("ASSET_SERIAL").getObjectValue();
CCLogger.getInstance().debug("The rows model data: "+ assertSerialVal);

// You can build secondary insert SQL code from the values previously submitted for // update of the master (primary key?) row data.

long result = -1;
JDBCConnection conn = e.getCommand().getJdbcConnection();
DbRow row = conn.getOneRow(“SELECT LAST_INSERT_ID() as lastPkInsert”);
try {
if(row != null && row.get("lastPkInsert") instanceof Number) {
result = ((Number) row.get("lastPkInsert")).longValue();
} else {
CCLogger.getInstance().error("Bad number from LAST_INSERT_ID()”);
}
} catch (Exception ex){
CCLogger.getInstance().error(“NaN from row.lastPKInsert: ”+ ex.getMessage());
}
conn.closeConnection();

I suppose that the ASSET_SERIAL is your master PK for your data but using the avove you can have standard numeric autoincrement keys for this.

The above assumes MySQL but SQL-Server will have @@IDENTITY in place of LAST_INSERT_ID instead.

Rgds

Anton

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.