Hi,
SC_SNAPSHOT-2011-03-17/EVAL Deployment
FireFix 3.6.15
I'm don't know what I'm doing wrong, but I get this exception/warning when calling the showPicker() on the comboBoxItem.
Use case: when user puts focus in a combo box item, the picker icon and list must be shown immediately.
When not focused, picker icon should be hidden again.
Issue that I'm seeing is that the drop down list is drawn in the top left hand corner (hence the getLeft() returning 0).
The issue can be reproduced with the standalone test case below.
Repo case: just click a few times (more then 4 times) between the dummy text field and the combo box and you'll see that sometimes the drop down list is drawn in the left hand-side corner (I also added a screenshot).
SC_SNAPSHOT-2011-03-17/EVAL Deployment
FireFix 3.6.15
I'm don't know what I'm doing wrong, but I get this exception/warning when calling the showPicker() on the comboBoxItem.
Use case: when user puts focus in a combo box item, the picker icon and list must be shown immediately.
When not focused, picker icon should be hidden again.
Issue that I'm seeing is that the drop down list is drawn in the top left hand corner (hence the getLeft() returning 0).
The issue can be reproduced with the standalone test case below.
Repo case: just click a few times (more then 4 times) between the dummy text field and the combo box and you'll see that sometimes the drop down list is drawn in the left hand-side corner (I also added a screenshot).
Code:
12:13:22.593 [ERROR] [standalone] 12:13:22.607:IFCS4:WARN:DynamicForm:isc_DynamicForm_0:getLeft() Unable to determine position for enumeration_id. This method is not supported by items of type [Class ComboBoxItem] - returning zero. com.smartgwt.client.core.JsObject$SGWT_WARN: 12:13:22.607:IFCS4:WARN:DynamicForm:isc_DynamicForm_0:getLeft() Unable to determine position for enumeration_id. This method is not supported by items of type [Class ComboBoxItem] - returning zero. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.widgets.form.fields.FormItem.showPicker(FormItem.java) at testcase.client.Standalone$4.onFocus(Standalone.java:558) at com.smartgwt.client.widgets.form.fields.events.FocusEvent.dispatch(FocusEvent.java:98) at com.smartgwt.client.widgets.form.fields.events.FocusEvent.dispatch(FocusEvent.java:1) at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65) at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178) at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:248) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Unknown Source)
Code:
public class Standalone implements EntryPoint { private static Canvas masterPanel = null; public void onModuleLoad() { //masterPanel should be a Layout masterPanel = new Canvas(); masterPanel.setHeight100(); masterPanel.setWidth100(); masterPanel.setStyleName("pageBackground"); //background style from skin masterPanel.addChild(testCase10()); masterPanel.draw(); } public VLayout testCase10() { //add extra field to have some more stuff on the form TextItem dummyField = new TextItem("dummy", "inputField"); VLayout test = new VLayout(); test.setWidth100(); test.setHeight100(); //static data for this comboBox ListGridRecord[] records = new ListGridRecord[3]; records[0] = new ListGridRecord(); records[0].setAttribute("enumeration_id", 1); records[0].setAttribute("enumerationValue", "Red"); records[0].setAttribute("forUpdate", true); records[1] = new ListGridRecord(); records[1].setAttribute("enumeration_id", 2); records[1].setAttribute("enumerationValue", "Green"); records[1].setAttribute("forUpdate", false);//selecting green is not allowed records[2] = new ListGridRecord(); records[2].setAttribute("enumeration_id", 3); records[2].setAttribute("enumerationValue", "Blue"); records[2].setAttribute("forUpdate", true); DataSourceIntegerField pkDS = new DataSourceIntegerField("enumeration_id"); // pkDS.setHidden(true); pkDS.setPrimaryKey(true); DataSourceTextField enumValueDS = new DataSourceTextField("enumerationValue"); DataSourceBooleanField forUpdateDS = new DataSourceBooleanField("forUpdate"); final DataSource datasource = new DataSource(); datasource.setID("testDS"); datasource.setFields(pkDS, enumValueDS, forUpdateDS); datasource.setCacheData(records); datasource.setClientOnly(true); ListGrid pickListProperties = new ListGrid(); pickListProperties.setAutoFetchData(false); pickListProperties.setDataSource(datasource); pickListProperties.setRecordCanSelectProperty("forUpdate"); pickListProperties.setShowHeader(false); pickListProperties.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { Boolean forUpdate = record.getAttributeAsBoolean("forUpdate"); String enumValue = record.getAttribute("enumerationValue"); if(forUpdate)//blue return "<span style='color:#113377'>" + enumValue + "</span>"; else//grey return "<i><span style='color:#aaaaaa'>" + enumValue + "</span></i>"; } }); ListGridField valueField1 = new ListGridField("enumerationValue"); ComboBoxItem combo =new ComboBoxItem("enumeration_id"); combo.setShowPickerIcon(false); combo.setOptionDataSource(datasource); combo.setValueField("enumeration_id"); combo.setDisplayField("enumerationValue"); combo.setPickListProperties(pickListProperties); combo.setPickListFields(valueField1); combo.setAddUnknownValues(false); combo.setCompleteOnTab(true); combo.setRejectInvalidValueOnChange(true); combo.setWidth("*"); combo.setTextBoxStyle("textItem");//this draws the field as we want when picker is not showing!!! combo.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { // if the user cleared the value, reset to the previous value. // Since addUnkonwnValues is false this also handles the // user entering a value that isn't present in the valueMap if (event.getValue() == null) event.cancel(); else { Integer enum_id = JSOHelper.getAttributeAsInt((JavaScriptObject) event.getValue(), "enumeration_id"); //search in list and cancel event!!! //retrieve the records for this enumeration => cached datasource Record[] values = datasource.getCacheData(); for(int i=0; i < values.length; i++){ if(enum_id.equals(values[i].getAttributeAsInt("enumeration_id"))){ if(!values[i].getAttributeAsBoolean("forUpdate")){ event.cancel(); } break; } } } } }); combo.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { //if picker is showing, do nothing... if(event.getItem().getShowPickerIcon()){ event.getItem().showPicker(); } else{ event.getItem().setShowPickerIcon(true); event.getItem().setAttribute("myFocus", true); event.getItem().redraw();//need to redraw to show picker icon => but calls blur event event.getItem().showPicker(); } } }); combo.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { Boolean redrawing = event.getItem().getAttributeAsBoolean("myFocus"); //ignore if(redrawing != null && redrawing){ event.getItem().setAttribute("myFocus", false); return; } //if picker is showing, do nothing... if(event.getItem().getShowPickerIcon()){ event.getItem().setShowPickerIcon(false); event.getItem().redraw();//hide picker again } } }); combo.setInputTransformer(new FormItemInputTransformer() { public Object transformInput(DynamicForm form, FormItem item, Object value, Object oldValue) { if(value == null){ SC.logWarn("Value in inputtransformer is NULL");//why?!? return item.getValue();//fallback in this case } //return the transformed value (newId) JavaScriptObject jsObject = JSOHelper.createObject(); JSOHelper.setAttribute(jsObject, "enumeration_id", (Integer) value); JSOHelper.setAttribute(jsObject, "dataType", 9); return jsObject; } }); combo.setEditorValueFormatter(new FormItemValueFormatter() { public String formatValue(Object value, Record record, DynamicForm form, FormItem item) { if (value == null) { return ""; } if (value instanceof JavaScriptObject) { JavaScriptObject jsObject = (JavaScriptObject) value; String id = JSOHelper.getAttribute(jsObject, "enumeration_id"); Integer enumeration_id = new Integer(id); if (enumeration_id.equals(Integer.MIN_VALUE)) { return ""; } //retrieve the records for this enumeration => cached datasource Record[] values = datasource.getCacheData(); for(int i=0; i < values.length; i++){ if(enumeration_id.equals(values[i].getAttributeAsInt("enumeration_id"))) return values[i].getAttribute("enumerationValue"); } return id;//unknown value } return (String) value; } }); DynamicForm form = new DynamicForm(); form.setHeight(300); form.setWidth(500); form.setFields(dummyField, combo); //initialised values => pay attention to the MIN_VALUE JavaScriptObject jsObject = JSOHelper.createObject(); JSOHelper.setAttribute(jsObject, "enumeration_id", 3); JSOHelper.setAttribute(jsObject, "dataType", 9); form.setValue("enumeration_id", jsObject); test.addMember(form); return test; } }
Comment