There you go:
Declare a primary key in your DataSource.
01:48:44.868:TMR8:WARN:Log:findByKeys: dataSource 'isc_OID_18' does not have primary keys declared, can't find record
public class TipiVoceBaseDS extends GwtRpcDataSource { public static String DATA_SOURCE_ID = "TipiVoceBaseDS"; private static TipiVoceBaseDS _instance = null; public static TipiVoceBaseDS getInstance() { if (_instance == null) { _instance = new TipiVoceBaseDS(DATA_SOURCE_ID); } return _instance; } public TipiVoceBaseDS (String p_id) { setID(p_id); DataSourceTextField _hiddenTxtF = new DataSourceTextField("hidden"); _hiddenTxtF.setPrimaryKey(true); _hiddenTxtF.setHidden(true); addField(_hiddenTxtF); .... (snip other fields)
public class VociBudgetBaseDS extends GwtRpcDataSource { public static String DATA_SOURCE_ID = "VociBudgetBaseDS"; private static VociBudgetBaseDS _instance = null; private static TipiVoceBaseDS _tvbDS = null; public static VociBudgetBaseDS getInstance() { if (_instance == null) { _instance = new VociBudgetBaseDS(DATA_SOURCE_ID); } if (null == _tvbDS) { _tvbDS = new TipiVoceBaseDS(TipiVoceBaseDS.DATA_SOURCE_ID); } return _instance; } public VociBudgetBaseDS (String p_id) { setID(p_id); DataSourceTextField _hiddenTxtF = new DataSourceTextField("hidden"); _hiddenTxtF.setPrimaryKey(true); _hiddenTxtF.setHidden(true); addField(_hiddenTxtF); .... (snip other fields)
/** * Returns the entire record object associated with the current value for this item (or null if no matching record exists * in the PickList data). Most commonly used for databound pickListItems to retrieve the values of other fields in the record. * * @return the selected record or null */ public native ListGridRecord getSelectedRecord() /*-{ var self = this.@com.smartgwt.client.core.DataClass::getJsObj()(); var ret = self.getSelectedRecord(); if(ret == null || ret === undefined) return null; var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); if(retVal == null) { retVal = @com.smartgwt.client.widgets.grid.ListGridRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); } return retVal; }-*/;
ButtonItem buttonItem = new ButtonItem("bi", "Get Record"); buttonItem.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Record categoryRecord = categoryItem.getSelectedRecord(); Record itemRecord = itemName.getSelectedRecord(); String selectedCategory = categoryItem.getAttribute("categoryName"); String selectedItem = itemRecord.getAttribute("itemName"); } }); form.setItems(categoryItem, itemName, buttonItem);
Uncaught JavaScript exception [com.google.gwt.core.client.JavaScriptException: (TypeError): Object doesn't support this property or method number: -2146827850 description: Object doesn't support this property or method at net.esteh.acc.client.ui.util.ComboBoxItem.getSelectedRecord(Native Method)
final SelectItem _funzIdCbo = new SelectItem(_funzIdLGF.getName()); _funzIdCbo.setOptionDataSource(FunzionalitaBaseDS.getInstance()); _funzIdCbo.setEmptyDisplayValue("{vuoto}"); _funzIdCbo.setDisplayField(FunzionalitaBase.REF + Constants.PROPERTY_SEPARATOR+FunzionalitaBase.PROP_FUNZ_DESCRIZIONE); _funzIdCbo.setValueField(FunzionalitaKey.REF + Constants.PROPERTY_SEPARATOR+FunzionalitaKey.PROP_FUNZ_ID); _funzIdCbo.setAllowEmptyValue(true); DataSourceField[] _dsFields = FunzionalitaBaseDS.getInstance().getFields(); ListGridField[] _comboFields = new ListGridField[_dsFields.length]; int _totWidth = 0; for (int c = 0; c < _comboFields.length; c++) { int f; if (_dsFields[c].getName().equals(_funzIdCbo.getDisplayField())) { f = 0; } else { if (null == _comboFields[0]) { f = c+1; } else { f = c; } } _comboFields[f] = new ListGridField(_dsFields[c].getName()); _comboFields[f].setHidden(_dsFields[c].getHidden()); _comboFields[f].setWidth(SSBListGrid.calculateWidth(_dsFields[c])); if(!_dsFields[c].getHidden()) { _totWidth = _totWidth + Integer.parseInt( _comboFields[f].getWidth()); } } _funzIdCbo.setPickListFields(_comboFields); _funzIdCbo.setPickListWidth(_totWidth + 20 ); _funzIdCbo.addChangedHandler(new ChangedHandler(){ public void onChanged(ChangedEvent event) { // TODO Auto-generated method stub Util.debug("cbo changed: new " +event.getValue(), false); Util.debug("changed getSelectedRecord", false); ListGridRecord _lgr; final FunzionalitaBaseLGR _recFUNZ; try { _lgr = _funzIdCbo.getSelectedRecord(); } catch (Exception ex) { Util.debug(ex.getMessage(), false); StackTraceElement[] _st = ex.getStackTrace(); for (int s=0; s < _st.length; s++) { Util.debug(_st[s].getClassName()+ _st[s].getMethodName() + _st[s].getLineNumber(), false); } Util.errore(ex.getMessage(), false); ex.printStackTrace(); try { _lgr = new FunzionalitaBaseLGR(new FunzionalitaBase(event.getValue().toString())); } catch (StringValueSettingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DateValueSettingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NumberValueSettingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }});
... 20:25:47.312:MUP5:WARN:Log:cbo changed: new TIPO_EVE7 20:25:47.331:MUP5:WARN:Log:changed getSelectedRecord 20:25:47.357:MUP5:WARN:Log:(TypeError): Proprietà o metodo non supportati dall'oggetto number: -2146827850 description: Proprietà o metodo non supportati dall'oggetto 20:25:47.378:MUP5:WARN:Log:com.smartgwt.client.widgets.form.fields.SelectItemgetSelectedRecord-2 20:25:47.401:MUP5:WARN:Log:com.digitalage.ssb.client.datapanel.FunzRelAppEDPanel$4onChanged334 20:25:47.457:MUP5:WARN:Log:com.smartgwt.client.widgets.form.fields.events.ChangedEventdispatch96 20:25:47.473:MUP5:WARN:Log:com.smartgwt.client.widgets.form.fields.events.ChangedEventdispatch1 20:25:47.488:MUP5:WARN:Log:com.google.gwt.event.shared.HandlerManager$HandlerRegistryfireEvent65 20:25:47.506:MUP5:WARN:Log:com.google.gwt.event.shared.HandlerManager$HandlerRegistryaccess$153 20:25:47.522:MUP5:WARN:Log:com.google.gwt.event.shared.HandlerManagerfireEvent178 20:25:47.537:MUP5:WARN:Log:com.smartgwt.client.core.DataClassfireEvent190 ...
20:37:54.947:WARN:Log:cbo changed: new HELP8 20:37:54.950:WARN:Log:changed getSelectedRecord 20:37:54.971:WARN:Log:(TypeError): c.getSelectedRecord is not a function fileName: http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html lineNumber: 6721 stack: Awi([object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:6721 wpc([object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:510 Bxi([object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:6738 o6f([object Object],[object Object],false) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:4610 z6f([object Object],[object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:4601 Dqh([object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:247 ([object Object],[object Object],"HELP8") @http://localhost:8888/com.digitalage.ssb.MainSSB/0206CF919B62311A37C65A28E352302C.cache.html:306 ("HELP8",(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0)) @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1054 ("SelectItem","handleChanged","HELP8",(void 0),(void 0),(void 0)) @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:246 ("HELP8") @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Grids.js:1361 ("HELP8") @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1053 () @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1632 ("HELP8",true) @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1627 ("HELP8") @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1661 ([object Object]) @http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1508 ([object Object],[object Object],9,[object Object],0,"Aiuto","Aiuto") @http://localhost:8888/com.digital
Comment