| PageBox [message #935784] |
Sun, 07 October 2012 06:07  |
Bertin Kiekebosch Messages: 223 Registered: August 2011 |
Senior Member |
|
|
Hi
Does anyone have an example of a pagebox. I want to have a table and a detailform in it and when you select a row in the table you can edit the details of the selected item.
regards Bertin
|
|
|
|
|
|
| Re: PageBox [message #939018 is a reply to message #937955] |
Wed, 10 October 2012 06:58   |
Bertin Kiekebosch Messages: 223 Registered: August 2011 |
Senior Member |
|
|
Hi Ken
The goal is to have a table and a form that work together. I have a table page with just two columns, a number and a name and I have a form with two fields. In the execInitField of the page box these are added to the PageBox. I added a listener to the table that reacts on TYPE_ROW_CLICK.
The problem with using the TYPE_ROW_CLICK is that when you use the arrow-key to change the row nothing happens. (Tried TYPE_ROWS_SELECTED but that makes problems worse when the user selects the cancel button)
When the user selects another row in the table and data is changed, I present a messageBox "Sava changes " with Yes, No and Cancel buttons. Yes and No work fine. But cancel would mean that the row will not be changed. I do this by setting the row back to the previous selected but there is still a focus border visible on the previous selected cell.
So maybe you have some I deas to improve this, already thanks for your effort.
Regards bertin
@Order(20.0)
public class TestPageBox extends AbstractPageField {
@Override
protected String getConfiguredLabel() {
return TEXTS.get("TestPage");
}
@Override
protected void execInitField() throws ProcessingException {
LegoSetsTablePage page = new LegoSetsTablePage();
setPage(page);
LegoSetForm form = new LegoSetForm();
getDetailFormField().setInnerForm(form);
page.getTable().addTableListener(new TableListener() {
@Override
public void tableChangedBatch(TableEvent[] batch) {
}
@Override
public void tableChanged(TableEvent e) {
boolean stopTableChange = false;
if (TableEvent.TYPE_ROW_CLICK == e.getType()) {
LegoSetsTablePage.Table table = (LegoSetsTablePage.Table) e.getTable();
LegoSetForm form2 = (LegoSetForm) TestPageBox.this.getDetailFormField().getInnerForm();
LegoSetFormData formData = new LegoSetFormData();
try {
form2.exportFormData(formData);
}
catch (ProcessingException e3) {
e3.printStackTrace();
}
try {
form2.checkSaveNeeded();
if (form2.isSaveNeeded()) {
MessageBox messageBox = new MessageBox(
null,
getCancelVerificationText(),
null,
TEXTS.get("YesButton"),
TEXTS.get("NoButton"),
TEXTS.get("CancelButton")
);
messageBox.setSeverity(IProcessingStatus.INFO);
int result = messageBox.startMessageBox();
if (result == IMessageBox.YES_OPTION) {
formData = SERVICES.getService(ILegoSetProcessService.class).store(formData);
}
else if (result == IMessageBox.NO_OPTION) {
}
else {
stopTableChange = true;
}
}
}
catch (ProcessingException e2) {
e2.printStackTrace();
}
if (stopTableChange) {
Integer legoSetNr = formData.getLegoSetNr();
if (legoSetNr != null) {
for (int i = 0; i < table.getRowCount(); i++) {
if (table.getSetNrColumn().getValue(i).equals(legoSetNr)) {
table.selectRow(i);
table.scrollToSelection();
break;
}
}
}
}
else
{
form2.setLegoSetNr(table.getSetNrColumn().getValue(table.getSelectedRow()));
try {
form2.exportFormData(formData);
formData = SERVICES.getService(ILegoSetProcessService.class).load(formData);
form2.importFormData(formData);
form2.markSaved();
}
catch (ProcessingException e1) {
e1.printStackTrace();
}
}
}
}
});
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01846 seconds