Hi,
I’m using the smartclient 1.0b.2.jars.
I have a TreeGrid NachrichtenGrid with binding to a RestDataSource. My service needs the parameter “korbid”. The NachrichtenGrid is filled when a node in another TreeGrid (EingangTree) is clicked. I found in the forum and documentation, that I have to call invalidateCache() befor fetching the new data. But this invalidateCache also makes a server call - without the parameter “korbid”. So my service returns no data. After that a second server call for my fetchData(criteria) is made. In debugging I set in my service manual different values for “korbid” those 2 calls. The interesting part of this is: always the result of invalidateCache() is displayed in my TreeGrid. Is this a bug or works as desing?
If this works as designed, How can I set the parameter “korbid” for the invalidateCache-Call?
public class NachrichtenGrid extends TreeGrid {
public NachrichtenGrid() {
PendenzenDS ds = PendenzenDS.getInstance();
this.setEmptyCellValue("--");
this.setDataSource(ds);
this.setAutoFetchData(true);
TreeGridField paragraph = new TreeGridField("paragraph", 100);
TreeGridField type = new TreeGridField("type", 150);
TreeGridField source = new TreeGridField("source", 100);
TreeGridField sender = new TreeGridField("sender", 100);
TreeGridField details = new TreeGridField("details", 100);
TreeGridField receive_time = new TreeGridField("receive_time", 100);
TreeGridField korbid = new TreeGridField("korbid", 10);
details.setWidth("*");
this.setFields(paragraph, type, source, sender, details, receive_time, korbid);
this.setNodeIcon(null);
this.setCanDragRecordsOut(true);
}
}
public class ContainerClickHandler implements ClickHandler {
private TreeGrid control;
public ContainerClickHandler(TreeGrid treeGrid) {
control = treeGrid;
}
public void onClick(ClickEvent event) {
Object source = event.getSource();
if (source instanceof EingangTree) {
updateNachhrichtenGrid((EingangTree) source);
}
}
private void updateNachhrichtenGrid(EingangTree source) {
ListGridRecord selectedRecord = source.getSelectedRecord();
Integer korbid = selectedRecord.getAttributeAsInt("id");
PendenzenDS instance = PendenzenDS.getInstance();
// TODO: Daten über Kriteria holen funktioniert leider nicht. Hier nachforschen
Criteria crit = new Criteria();
crit.addCriteria("korbid", new Integer(korbid));
control.invalidateCache();
instance.fetchData(crit);
}
}
public class PendenzenService extends JsonController<Pendenz> {
Logger logger = LoggerFactory.getLogger(PendenzenkorbService.class);
@Autowired
private PendenzBusiness pendenzBusiness;
@RequestMapping(value = "/pendenz/all", method = RequestMethod.GET)
public void getPendenzenkoerbe(HttpServletResponse response, Integer korbid) throws IOException {
List<Pendenz> pendenzen = pendenzBusiness.findAll( korbid);
JSONSerializer out = new JSONSerializer();
String result = out.prettyPrint( pendenzen);
writeHttpResponse(response, result);
}
}
public class PendenzenDS extends RestDataSource {
private static PendenzenDS instance = null;
public static PendenzenDS getInstance(){
if (instance == null) {
instance = new PendenzenDS();
}
return instance;
}
TreeGridField paragraph = new TreeGridField("paragraph", 100);
TreeGridField type = new TreeGridField("type", 150);
TreeGridField source = new TreeGridField("source", 100);
TreeGridField sender = new TreeGridField("sender", 100);
TreeGridField details = new TreeGridField("details", 100);
TreeGridField receive_time = new TreeGridField("receive_time", 100);
TreeGridField korbid = new TreeGridField("korbid", 10);
private PendenzenDS() {
this.setID("PendenzenDS");
DataSourceIntegerField objectID = new DataSourceIntegerField("ID");
objectID.setValueXPath("id");
objectID.setPrimaryKey(true);
objectID.setHidden(true);
DataSourceIntegerField korbid = new DataSourceIntegerField("korbid");
korbid.setIgnore(true);
korbid.setValueXPath("pendenzenkorb/id");
DataSourceTextField paragraph = new DataSourceTextField("paragraph");
paragraph.setValueXPath("class");
DataSourceTextField type = new DataSourceTextField("type");
type.setValueXPath("ablauf/meldung/class");
DataSourceTextField source = new DataSourceTextField("source");
source.setValueXPath("ablauf/meldung/meldungskanal/name");
DataSourceTextField sender = new DataSourceTextField("sender");
sender.setValueXPath("meldung/name");
DataSourceTextField details = new DataSourceTextField("details");
details.setValueXPath("notiz");
DataSourceDateTimeField erstellung = new DataSourceDateTimeField("receive_time");
erstellung.setValueXPath("erstellungszeit");
DataSourceIntegerField parent = new DataSourceIntegerField("parent");
parent.setValueXPath("parent");
parent.setHidden(true);
parent.setForeignKey(this.getID() + ".ID");
parent.setRootValue(0);
this.setFields(paragraph, type, source, sender, details, erstellung);
this.setDataFormat(DSDataFormat.JSON);
this.setRecordXPath("/");
this.setDataURL("/resources/pendenz/all");
}
}