Hi Roma
Sorry for the late reply; I was yesterday travelling.
2+3) I did adapt the program, so it creates now one record, if he does not exist
public class CompanyDetailView extends StandardDetailView<Company>
{
@Autowired
private DataManager dataManager;
@Subscribe
public void onInit(final InitEvent event)
{
Company company = dataManager.create(Company.class);
try {
dataManager.load(Company.class)
.id(1)
.one();
} catch (NoResultException e) {
// company does not exist, create one
company.setId(1);
company.setCompany("new Company created");
dataManager.save(company);
}
}
}
- I can change the program easily to use a UUID. BUT
→ in menu.xml
you have to tell the application, which record to show
<item view="Company.detail" title="Company">
<routeParameters>
<parameter name="id" value="1"/>
</routeParameters>
</item>
you see the parameter 1
If you use an UUID, this UUID will be different every time you or the system create a new record.
If you do not mention the parameter and just show the first record you find, this will not be reliable, as there might be more then one record
Later you want to make something with this entity, where you will have to pass the paramter for the id.
As you see, you will face a lot of problems and it is easier to handle a fix record id ( which can be anything you wish, even a string “paymentID”).
Still want a sample with UUID ?
Regards
Felix
PayWindowPayroll.zip (1.0 MB)