Originally posted by mnenchev
I do not have deployable sample at the moment but here is the code connected with the problem:
I have asset:newsDays one to many relationship
KeyValueJsonAsyncCallback just transforms json key:value to Record
My AssetJsonDataSource is tested and working with SelectItems.
I have asset:newsDays one to many relationship
Code:
//view final DynamicForm newsDayForm = new DynamicForm(); newsDayForm.setDataSource(NewsDaysDataSource.getInstance()); // newsDaysDS public NewsDaysDataSource() { setClientOnly(true); pk = new DataSourceIntegerField("id", "News Day Id"); pk.setPrimaryKey(true); pk.setHidden(true); addField(pk); assetField = new DataSourceIntegerField("assetId"); assetField.setCanEdit(true); assetField.setEditorType(new WebSelectItem(AssetJsonDataSource.getInstance())); assetField.setForeignKey("assetsDS.key"); assetField.setRequired(true); addField(assetField); dateField = new DataSourceDateField("date", "Date"); final DateRangeValidator validator = new DateRangeValidator(); validator.setMin(new Date()); dateField.setRequired(true); dateField.setValidators(validator); addField(dateField); intervalField = new DataSourceIntegerField("interval", "Interval"); final IntegerRangeValidator integerValidator = new IntegerRangeValidator(); integerValidator.setMin(0); intervalField.setValidators(integerValidator); intervalField.setRequired(true); addField(intervalField); } // AssetDS protected DataSourceIntegerField key; protected DataSourceField value; public AssetJsonDataSource() { key = new DataSourceIntegerField("key"); key.setHidden(true); key.setPrimaryKey(true); addField(key); value = new DataSourceTextField("value"); addField(value); setClientOnly(true); this.setID("assetsDS"); } @Override protected void executeAdd(String requestId, DSRequest request, DSResponse response) { } @Override protected void executeFetch(final String requestId, DSRequest request, final DSResponse response) { final AssetServiceAsync service = ServiceUtils.getAssetServiceAsync(); service.getAssetsMap(new KeyValueJsonAsyncCallback() { @Override public void responseFailure(Throwable e) { SC.warn("ERROR : " + e.getMessage(), null); response.setStatus(RPCResponse.STATUS_FAILURE); processResponse(requestId, response); } @Override public void responseSuccess(Record[] records) { response.setData(records); processResponse(requestId, response); } }); } @Override protected void executeRemove(String requestId, DSRequest request, DSResponse response) { // TODO Auto-generated method stub } @Override protected void executeUpdate(String requestId, DSRequest request, DSResponse response) { // TODO Auto-generated method stub } @Override protected Object getValueOf(String from, String fieldName) { return null; }
My AssetJsonDataSource is tested and working with SelectItems.
I would need to see all your code to understand what you're doing...
It looks like you're using JSON and client side only I'm using RPC and Objects (server side only).
Your declarations are a lot different from what I have so I would have to see it all.
Comment