Hi Martin,
Since you have your own test framework, my previous mail about ULC Test
Framework is of no use to you.
Please see the snippet below. It shows how to fetch unuploaded rows on the
client. It extends ULCTable and uses isLoaded() and load() methods on the
client side proxy to fetch unuploaded rows to the client. See UIMyTable's
loadRow() method in the snippet.
In the snippet, enter a row number and press on Print button. If the row
is not uploaded, "null" will be printed on the adjoining label. Now press
Get Row and then press Print, the value of the 1st column will be printed
on the label on the client side.
Thanks and regards,
Janak
-----------------------------------------
Janak Mulani
email: [EMAIL PROTECTED]
url: http://www.canoo.com
Beyond AJAX - Java Rich Internet Applications
http://www.canoo.com/ulc
-----------------------------------------
-----Original Message-----
From: Martin Moser [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2008 3:11 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: ULCTable and lazy loading
Hi Janak,
>> I would like to access all rows of a table and not only the loaded
ones.
>> Example: If a table has 400 rows, but the first fifty are shown, I
would
>> like to access the "last" row, which is not the 50th row but the 400th
>> row.
> Where would you like to access all rows?
I would like to access the rows on the client-side.
The exact requirement is following:
I am part of a team, which developes a GUI-test tool for Java-GUI
clients. If you create a test for tables with our tool, it should be
possible, that the user implements the following:
Select the 200. row or select the specific row with the value "meier"
for column "name".
It's important for us, that the current scroll-status doesn't impact this
selection. As you can image, this works fine for normal JTables, but not
for ULCTables due to lazy loading.
I am looking for a solution of that problem.
Regards,
Martin
--On Montag, Februar 25, 2008 10:00:11 +0100 Martin Moser
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> As I know ULCTable objects don't load the whole data, which belongs to
> the table. They load only the data, which can be seen and some more
rows.
>
> I would like to access all rows of a table and not only the loaded
> ones. Example: If a table has 400 rows, but the first fifty are shown,
> I would like to access the "last" row, which is not the 50th row but
> the 400th row.
>
> Is there any possibility to access all rows programmatically? Perhaps
> sending events or calling specific methods or something like that?
>
> Thanks in advance!
>
> Best Regards,
> Martin
--
Martin Moser
---------------
package tableDecoratorisLoaded;
import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCLabel;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.client.UILabel;
import com.ulcjava.base.client.UITable;
import com.ulcjava.base.development.DevelopmentRunner;
public class TableLoadDesiredRowSnippet extends AbstractApplication {
public void start() {
final ULCMyTable table = new ULCMyTable(new SnippetTableModel(20,
2));
ULCScrollPane scp = new ULCScrollPane(table);
ULCBoxPane content = new ULCBoxPane();
content.set(0, 0, 2, 1, ULCBoxPane.BOX_EXPAND_EXPAND, scp);
final ULCTextField text = new ULCTextField(4);
content.set(0, 1, 1, 1, ULCBoxPane.BOX_EXPAND_CENTER, text);
ULCButton button = new ULCButton("Get Row");
button.addActionListener(new IActionListener() {
public void actionPerformed(ActionEvent event) {
try {
int row = Integer.parseInt(text.getText());
table.loadRow(row);
} catch (Exception e) {
}
}
});
content.set(1, 1, 1, 1, ULCBoxPane.BOX_EXPAND_CENTER, button);
final ULCLabel label = new ULCLabel();
content.set(0, 2, 1, 1, ULCBoxPane.BOX_EXPAND_CENTER, label);
ULCButton button1 = new ULCButton("Print Row");
button1.addActionListener(new IActionListener() {
public void actionPerformed(ActionEvent event) {
try {
int row = Integer.parseInt(text.getText());
table.printRow(row, label);
} catch (Exception e) {
}
}
});
content.set(1, 2, 1, 1, ULCBoxPane.BOX_EXPAND_CENTER, button1);
ULCFrame frame = new ULCFrame("TableDecoratorSnippet");
frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
frame.add(content);
frame.setSize(300, 150);
frame.setVisible(true);
}
public static void main(String[] args) {
DevelopmentRunner.setApplicationClass(TableLoadDesiredRowSnippet.class);
DevelopmentRunner.run();
}
private static class SnippetTableModel extends DefaultTableModel {
public SnippetTableModel(int rowCount, int columnCount) {
super(createRows(rowCount, columnCount),
createColumnNames(columnCount));
}
private static Object[][] createRows(int rowCount, int
columnCount) {
Object[][] result = new Object[rowCount][];
for (int i = 0; i < rowCount; i++) {
result[i] = new Object[columnCount];
for (int j = 0; j < columnCount; j++) {
result[i][j] = i + ":" + j + " AAAa";
}
}
return result;
}
private static String[] createColumnNames(int columnCount) {
String[] result = new String[columnCount];
for (int i = 0; i < columnCount; i++) {
result[i] = Integer.toString(i);
}
return result;
}
}
public static class ULCMyTable extends ULCTable {
public ULCMyTable(SnippetTableModel model) {
super(model);
}
protected String typeString() {
return UIMyTable.class.getName();
}
public void loadRow(int row) {
invokeUI("loadRow", new Object[] { new Integer(row) });
}
public void printRow(int row, ULCLabel label) {
invokeUI("printRow", new Object[] { new Integer(row), label
}); }
}
public static class UIMyTable extends UITable {
public void loadRow(int row) {
Object value = getBasicTable().getValueAt(row, 0);
if (!getBasicTable().isLoaded(row, row, 0,
getModel().getColumnCount() - 1)) {
getBasicTable().load(row, row, 0,
getModel().getColumnCount() - 1);
}
}
public void printRow(int row, UILabel label) {
Object value = getBasicTable().getValueAt(row, 0);
label.getBasicLabel().setText(value != null ?
value.toString() : "null");
}
}
}