Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Scout/Tutorial/3.8/Minicrm/Table Field"
(→Form: participants column screenshot) |
(→Form: link button) |
||
Line 79: | Line 79: | ||
[[Image:Minicrm Participants.png]] | [[Image:Minicrm Participants.png]] | ||
+ | |||
+ | == Make it Editable == | ||
+ | |||
+ | What do we need to make this table editable? We need a way to '''add a new row'''. | ||
+ | |||
+ | Add a new '''link button''' to the '''VisitForm''' and call it '''NewParticipantButton'''. | ||
+ | |||
+ | Use this '''execClickAction''': | ||
+ | |||
+ | <source lang="java"> | ||
+ | @Override | ||
+ | protected void execClickAction() throws ProcessingException { | ||
+ | getParticipantsField().getTable().addRowByArray( | ||
+ | new Object[]{null}); | ||
+ | } | ||
+ | </source> |
Revision as of 11:06, 25 October 2012
The Scout documentation has been moved to https://eclipsescout.github.io/.
What is this chapter about?
We will build a new table page for the Minicrm. It will list visits (or appointments, if you want). We will build a new form to edit visits. This form will contain a table field listing the people participating.
This chapter assumes that you're pretty proficient at creating tables, forms and services. No more hand-holding. :)
Database
The Apache Derby example database already contains the following tables:
VISIT VISIT_PARTICIPANT --------------- ----------------- VISIT_NR VISIT_NR EVT_FROM PERSON_NR EVT_TO RESPONSIBLE_NR CONTACT_NR
If you want to take a look at the database using a command line tool, check this section of the tutorial.
Table Page
Start with VisitTablePage and a few columns: VisitNrColumn, StartColumn, EndColumn and OrganizerColumn.
Result:
(Note: We switched the Swing client to the Rayo Look & Feel.)
Form
Create a VisitForm with a GroupBox (this just looks better). Inside the group box, add two fields: StartField and EndField, both of them dates.
Finally, add a ParticipantsField of type TableField. Use Grid H 4. More if you typically have large meetings. :)
Add a NewVisitMenu and a EditVisitMenu to the VisitTablePage.
Don't forget to pass the selected visit to the ModifyHandler in your edit menu:
@Override protected void execAction() throws ProcessingException { VisitForm form = new VisitForm(); form.setVisitNr(getTable().getVisitNrColumn().getSelectedValue()); form.startModify(); form.waitFor(); if (form.isFormStored()) { reloadPage(); } }
Result:
Note how we did not add a column to the ParticipantsField. Before we do that, we need to write a PersonLookupCall. In the PersonLookupService, use the following SQL statement:
return "" + "SELECT P.PERSON_NR, " + " P.LAST_NAME ||', '|| P.FIRST_NAME " + "FROM PERSON P " + "WHERE 1=1 " + "<key> AND P.PERSON_NR = :key </key> " + "<text> AND UPPER(P.LAST_NAME ||', '|| P.FIRST_NAME) LIKE UPPER(:text||'%') </text> " + "<all> </all> ";
Using this, we can create a ParticipantsColumn for the ParticipantsField. Make it a Smart Column and provide the PersonLookupCall we just created. Make sure the ParticipantsField table has Auto Resize Columns checked.
Result:
Make it Editable
What do we need to make this table editable? We need a way to add a new row.
Add a new link button to the VisitForm and call it NewParticipantButton.
Use this execClickAction:
@Override protected void execClickAction() throws ProcessingException { getParticipantsField().getTable().addRowByArray( new Object[]{null}); }