Can I use SQLContainer with Form? I saw an example where people get Item (columns is property) from SQLContainer and use it for Form. It’s understandable, but I have another situation. I have just 2 column and some rows. I need to make form where the caption of element is first column and value is second. How can I do this thing?
I need to make form that show condition part of database, just some values. When DB changes UI should be updated. I think I need to use some refresher or icepush add-ons. May be there is another solution…
Did you figure it out already? If not, I’ll take a shot:
I’m not quite sure what do you mean in practise with your other situation - does your SQLContainer always get just one row, or do you want to repeat the fields for every row, or just select one and display that in the form? - but yes, form (or formlayout, if it works better for your needs) is a good way to display data so that the captions are on left and the fields are on the right. The
sampler has some examples on forms and the
book gives a brief example on formlayout (and form as well, that’s in chapter 5.19).
Can the DB update from outside your application? If not, you should be able to manage with just valuechangelisteners (and possible other listeners between views).
I’ve solved this problem by extending Form class with this methods:
void setContainerDataSource(Container container) {
this.container = container;
refreshContainerData();
}
public void refreshContainerData() {
if (container != null) {
Collection c = container.getItemIds();
PropertysetItem itemSet = new PropertysetItem();
for (Object o : c) {
Item item = container.getItem(o);
Property pName = item.getItemProperty(nameId);
Property pValue = item.getItemProperty(valueId);
itemSet.addItemProperty(pName.getValue(), pValue);
}
setItemDataSource(itemSet);
}
}
It’s still problem for me. I don’t know how can DB update my application… and how it is possible.
As I know ItemSetChangeListener listens when values updates. When SQLContainer’s values were updated, but I don’t know will it work when DB (which my sqlcontainer refers) was updated from somewhere else(not from my sqlcontainer).