Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Define rows selection in a TableField at server side.
Define rows selection in a TableField at server side. [message #1294086] Sun, 13 April 2014 06:00 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 797
Registered: October 2011
Senior Member
Hi,

In the application I am working on, I need to control the selection in a TableField from the Scout Server.

I am wondering where I should put this information.

1/ Variable on the form (rowId as int ?)

[Problem] it is not coupled with the table Field (I need to make the field aware that it need to store the selection information in this variable)

[Problem] In the TableFieldData the rows are ordered, but after an import in the TableField, I am not sure that this order is preserved.

2/ Table Status

The current statuses are:
* STATUS_NON_CHANGED
* STATUS_INSERTED
* STATUS_UPDATED
* STATUS_DELETED

I could try to add additional status to mark which row is selected.

I don't think that it is a good idea, because those status are used internally by the table.


3/ CustomValue

With Bean based TableData, it is possible to add a custom value on the row.
The Idea is to add a custom value to mark it as selected.

row.setCustomColumnValue(ITableFieldConstants.SELECTED, selected);


To retrieve this customValue information, I need to extend the current "TableRowMapper".

I cannot set the selected values on the table before they are imported in the table. Otherwise I will get an Exception (A).

The problem is that the mapper isn't notified when the mapping is over. Even if I manage to retrieve the "Selected" value for each rowData in TableRowDataMapper.importTableRowData(ITableRow, AbstractTableRowData). I will not be able to use this information to select the corresponding rows when the rows are imported.

4/ Boolean column

I could add an undisplayable boolean Column (SelectedColumn) in the table.
I could intercept importFormFieldData on the tableField and add some code to select the rows according to the content of the SelectedColumn


(A) Execption Stack trace

When you try to import a ITableRow that is not in the table:

Caused by: java.lang.IllegalArgumentException: only accept InternalTableRow, not class org.eclipse.scout.rt.client.ui.basic.table.TableRow
	at org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.resolveRow(AbstractTable.java:3514)
	at org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.resolveRows(AbstractTable.java:3532)
	at org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.selectRows(AbstractTable.java:2021)
	at org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.selectRow(AbstractTable.java:2006)
	at org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.selectRow(AbstractTable.java:2000)

Re: Define rows selection in a TableField at server side. [message #1295333 is a reply to message #1294086] Mon, 14 April 2014 07:19 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 128
Registered: March 2010
Senior Member
Hi Jérémie

Instead of working with the row selection you could use a checkable table. Just set getConfiguredCheckable to true on the table. You can then get the checked rows by using getCheckedRows. In order to set the checked rows on the server create a boolean column and use getConfiguredCheckableColumn to link it to the table and have the values imported on importFormFieldData. Done.

Depending on your use case, using a checkable table may also improve the usability: Due to the checkbox it is more obvious to the user that something will "happen" with the checked rows. Furthermore it is easier to select (check) multiple rows and the selection doesn't get removed accidentally when the user forgets to press "ctrl".

Hope it helps
Claudio
Re: Define rows selection in a TableField at server side. [message #1295441 is a reply to message #1295333] Mon, 14 April 2014 09:14 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 797
Registered: October 2011
Senior Member
Thanks for your feedback.

- we do not have multiple selection: it is possible to tell a checkable table, that only one row is checked?
- this pattern should be used in combination with Table and GroupBox for details on row selection.

I will give your Idea to our team.

From a technical point of view, a checkable table is near to the solution 4 I have proposed, isn't it?


Re: Define rows selection in a TableField at server side. [message #1295473 is a reply to message #1295441] Mon, 14 April 2014 09:48 Go to previous message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 128
Registered: March 2010
Senior Member
Quote:
- we do not have multiple selection: it is possible to tell a checkable table, that only one row is checked?

Yes, see getConfiguredMultiCheck
Quote:
- this pattern should be used in combination with Table and GroupBox for details on row selection.

For this use case I personally would NOT use a checkable table. Instead I would try to implement the selection behaviour on the client. If you don't have all the information available I would create either a (hidden) column or a property on the table field template. I don't think the server really has to know which row should be selected on the gui.

Quote:
From a technical point of view, a checkable table is near to the solution 4 I have proposed, isn't it?

Yes.

Previous Topic:Code Recommenders specialized for Scout
Next Topic:RAP - Doesn't Start Application
Goto Forum:
  


Current Time: Fri Nov 28 18:23:36 GMT 2014

Powered by FUDForum. Page generated in 0.02008 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software