| Summary: | Use public column index constant in AbstractTableFieldData | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Jeremie Bresson <dev> | ||||
| Component: | Scout | Assignee: | Project Inbox <scout.sdk-inbox> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | dev, mvi, zimmermann | ||||
| Version: | unspecified | Flags: | zimmermann:
juno+
|
||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 204327 [details]
patch for this bug
Add a patch that does the proposed feature.
Please review it. I am not sure I used correctly the IImportValidator in my ConstantIntSourceBuilder.
Patch modified and applied. Thank you Jeremie. ticket closed. deliverd as part of eclipse scout 3.8.0 (juno release train) |
I would like to have constant for column index in AbstractTableFieldData. I already have some Table Utility (server side) that rely on this index given as int. The index is used in getValueAt or setValueAt... This is usefull when you use a table formdata object extending AbstractTableFieldData in an other way than with a select into, or if you want to check something (eg a uniqueness constraint in java) and reuse the code between different column/table. Having just an integer (even if it is declared a constant in my code) is dangerous, because if I remove a column in the client, my code wont be broken in the server (as it can be with a FormData-statement-builder if I remove a field). Here is how the generated code looks like now: public class Questions extends AbstractTableFieldData { private static final long serialVersionUID = 1L; public Questions() { } public void setQuestionNr(int row, Integer questionNr) { setValueInternal(row, 0, questionNr); } public Integer getQuestionNr(int row) { return (Integer) getValueInternal(row, 0); } public void setQuestionText(int row, String questionText) { setValueInternal(row, 1, questionText); } public String getQuestionText(int row) { return (String) getValueInternal(row, 1); } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { switch (column) { case 0: return getQuestionNr(row); case 1: return getQuestionText(row); default: return null; } } @Override public void setValueAt(int row, int column, Object value) { switch (column) { case 0: setQuestionNr(row, (Integer) value); break; case 1: setQuestionText(row, (String) value); break; } } } Here is what I am expecting from the SDK: public class Questions extends AbstractTableFieldData { private static final long serialVersionUID = 1L; public static final int QUESTION_NR_COLUMN_INDEX = 0; public static final int QUESTION_TEXT_COLUMN_INDEX = 1; public Questions() { } public void setQuestionNr(int row, Integer questionNr) { setValueInternal(row, QUESTION_NR_COLUMN_INDEX, questionNr); } public Integer getQuestionNr(int row) { return (Integer) getValueInternal(row, QUESTION_NR_COLUMN_INDEX); } public void setQuestionText(int row, String questionText) { setValueInternal(row, QUESTION_TEXT_COLUMN_INDEX, questionText); } public String getQuestionText(int row) { return (String) getValueInternal(row, QUESTION_TEXT_COLUMN_INDEX); } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { switch (column) { case QUESTION_NR_COLUMN_INDEX: return getQuestionNr(row); case QUESTION_TEXT_COLUMN_INDEX: return getQuestionText(row); default: return null; } } @Override public void setValueAt(int row, int column, Object value) { switch (column) { case QUESTION_NR_COLUMN_INDEX: setQuestionNr(row, (Integer) value); break; case QUESTION_TEXT_COLUMN_INDEX: setQuestionText(row, (String) value); break; } } }