Because in the Calendar, the custom field is not
the real one showed in the browser. Your variant
treatStart or time or others are copied to be real
FormItem at the run time.
So, what you need is :
event.getForm().getField( "treatStart")
The getField method can only return TextItem class, you should
convert it to SelectItem if you need one:
SelectItem task = new SelectItem( event.getForm().getField( "xxx").getJsObj());
Announcement
Collapse
No announcement yet.
X
-
Hi,
I have a similar problem, and I have created a stand-alone test case. I'm running this in hosted mode on a Mac with Safari 4.0.2, GWT 1.7.0, SmartGWT revision 630.
What happens with this sample is that initially it works fine, transformRequest is called, and the data is loaded from the server. However, under certain circumstances the combobox will send an empty query, and transformRequest won't be called after that point.
The combobox does not normally request empty queries, but I've found two reasons why this could happen:
1) With an empty combobox, force the pick-list to be shown by pressing Alt-Arrow down.
2) Enter a two character string, for example "aa", and remove both characters fast. The request is triggered by removing the first character, but because of the delay the request will be empty.
Code:public class Test implements EntryPoint { final static String DATA_URL = "test_livesearch.php"; public void onModuleLoad() { if (!GWT.isScript()) { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new KeyCallback() { public void execute(String keyName) { SC.showConsole(); } }); } VLayout layout = new VLayout(); layout.setHeight100(); layout.setWidth100(); DataSourceEnumField searchTypeField = new DataSourceEnumField("type", "Type"); searchTypeField.setValueMap("category","subcategory"); DataSourceIntegerField searchIdField = new DataSourceIntegerField("id","Id"); DataSourceTextField searchNameField = new DataSourceTextField("name", "Name"); OperationBinding fetchOperation = new OperationBinding(); fetchOperation.setOperationType(DSOperationType.FETCH); fetchOperation.setDataProtocol(DSProtocol.POSTMESSAGE); SearchForm form = new SearchForm(); form.setNumCols(4); final ComboBoxItem searchBox = new ComboBoxItem("name"); searchBox.setShowPickerIcon(false); searchBox.setShowTitle(false); RestDataSource liveSearchDS = new RestDataSource() { @Override protected Object transformRequest(DSRequest dsRequest) { GWT.log("transformRequest",null); return super.transformRequest(dsRequest); } }; liveSearchDS.setOperationBindings(fetchOperation); liveSearchDS.setFields(searchTypeField, searchIdField, searchNameField); liveSearchDS.setDataURL(DATA_URL); liveSearchDS.setPreventHTTPCaching(true); liveSearchDS.setCriteriaPolicy(CriteriaPolicy.DROPONCHANGE); searchBox.setOptionDataSource(liveSearchDS); searchBox.setShowOptionsFromDataSource(true); searchBox.setShowPickListOnKeypress(true); searchBox.setFilterLocally(false); SubmitItem searchButton = new SubmitItem(); searchButton.setStartRow(false); searchButton.setTitle("Search"); form.setFields(searchBox, searchButton); form.setSaveOnEnter(true); form.addSubmitValuesHandler(new SubmitValuesHandler() { public void onSubmitValues(SubmitValuesEvent submitValuesEvent) { GWT.log("onSubmitValues " + searchBox.getSelectedRecord(),null); } }); layout.addMember(form); layout.draw(); } }
Code:<request> <data> <isc_OID_3> <name>aa</name> </isc_OID_3> </data> <dataSource>isc_OID_3</dataSource> <operationType>fetch</operationType> <operationId></operationId> <startRow>0</startRow> <endRow>75</endRow> <sortBy></sortBy> <textMatchStyle>startsWith</textMatchStyle> <componentId>isc_PickListMenu_7</componentId> <oldValues></oldValues> </request> <request> <data> <isc_OID_3/> </data> <dataSource>isc_OID_3</dataSource> <operationType>fetch</operationType> <operationId></operationId> <startRow>0</startRow> <endRow>75</endRow> <sortBy></sortBy> <textMatchStyle>startsWith</textMatchStyle> <componentId>isc_PickListMenu_7</componentId> <oldValues></oldValues> </request>
Leave a comment:
-
According to this report: http://forums.smartclient.com/showthread.php?t=6348 someone else is having problems with a combo that does not call to transformResponse but it could be another case.
Anyway, I modified the example. Now I've putted a button below the calendar that shows a popup with the exact same combo. In that case, the combo gets the values correctly.
Also, I've modified the GWT RPC Datasource class to get a window.alert everytime transformResponse is called. Only when the combo is shown in the popup, the transformResponse is executed, but not when the combo is shown in the event editor window.
About the hide issue: As I'm putting the combo in the calendar editor directly through calendar.setEventEditorFields, I don't know how to access the form from the calendar and so, I don't know how to get the combo by getItem() function, as the calendar does not have either a getItem() method or a getEventEditorForm method.
I can only get the error in the smartclient console in Firefox, but not in IE so I can't post the stack trace. In the IE case, the field is not hidden but the error is only shown in the developer console window (the one from IE, equivalent to firebug, not the smartclient one) and the error is the same (a.hide is not a function).
Leave a comment:
-
On the hide(), try accessing the item by way of form.getItem() instead of directly accessing it. With any JS error, always post a stack trace from the Developer Console in IE.
On the DataSource issue, first verify the DataSource works independently, and as an optionDataSource for a form that is independent of the Calendar.
Leave a comment:
-
This is a slightly modified version of the custom event editor from the showcase. Instead of using fixed values in the repeats field, I'm getting them from a GWT RPC Datasource and once you select a value in the reminder units it tries to hide the reminder value field.
It fails in both. The first does not get the values, as it does not call to fetch in the datasource (maybe the problem is that it does not call transformRequest?) and the second gives a javascript error about e.hide() operation being nonexistent.
Leave a comment:
-
I'll try to make a test case once I have enough time but now I need to comply with a deadline.
As this error is only produced when using the default event editor, I'm trying to use my own event editor window which seems to work as expected. I've managed to successfully replace the editor when clicking on an event (via addEventClickHandler) and when clicking on the month view days (via addDayBodyClickHandler) but I can't find how to replace it when clicking on the "Add Event" button and when clicking on a day in the week and day view. What is the method that I have to use to add my handler? Is there any easier method to replace the default event editor? I mean, apart from the setEditorFields that don't work for me.
Leave a comment:
-
Please structure your code as a complete sample, with an onModuleLoad() method that we can copy-paste-run locally.
Leave a comment:
-
I've found another example of different behavior of a dynamic form in the calendar editor. I've set this code in a popup window:
Code:public DynamicForm getTestForm(String user) { DynamicForm form = new DynamicForm(); form.setDataSource(MedicationsDataSource.getInstance(user)); final DateItem treatStart = new DateItem(MedicationsDataSource.START_TREATMENT, "From"); treatStart.setUseTextField(true); treatStart.setShowPickerIcon(true); final TimeItem time = new TimeItem(MedicationsDataSource.START_TREATMENT_TIME, "At"); time.setShowTitle(true); final DateItem treatEnd = new DateItem(MedicationsDataSource.END_TREATMENT, "To"); treatEnd.setUseTextField(true); treatEnd.setShowPickerIcon(true); IntegerItem doseItem = new IntegerItem(); doseItem.setName(MedicationsDataSource.DOSE); doseItem.setTitle("Dose"); ComboBoxItem unitsItem = new ComboBoxItem(); unitsItem.setName(MedicationsDataSource.UNITS); LinkedHashMap<String, String> unitValues = new LinkedHashMap<String, String>(); unitValues.put("tablet", "Tablet"); unitValues.put("sachet", "Sachet"); unitsItem.setValueMap(unitValues); unitsItem.setShowTitle(false); final FloatItem freqItem = new FloatItem(); freqItem.setName(MedicationsDataSource.FREQUENCY); freqItem.setTitle("Every"); ComboBoxItem periodItem = new ComboBoxItem(MedicationsDataSource.PERIOD); LinkedHashMap<String, String> periodValues = new LinkedHashMap<String, String>(); for (PeriodType period : PeriodType.values()) { periodValues.put(period.toString(), period.toString().toLowerCase()); } periodItem.setValueMap(periodValues); periodItem.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent event) { String strValue = (String) event.getValue(); //Window.alert("Selected "+strValue); boolean enable = true; if (PeriodType.ONCE.toString().equals(strValue)) { enable = false; treatStart.hide(); time.hide(); treatEnd.hide(); freqItem.disable(); } else { treatStart.show(); time.show(); treatEnd.show(); freqItem.enable(); } } }); periodItem.setShowTitle(false); periodItem.setColSpan(2); form.setItems(doseItem,unitsItem,freqItem,periodItem, treatStart,time,treatEnd); return form; } ............... final com.smartgwt.client.widgets.Window popup = new com.smartgwt.client.widgets.Window(); popup.setAutoCenter(true); popup.setAutoSize(true); popup.addItem(getTestForm(user)); Button popupButton = new Button("Popup"); popupButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.show(); } });
Code:Calendar cal = new Calendar(); .............. exactly the same fields description .............. cal.setEventEditorFields(descItem,doseItem,unitsItem,freqItem,periodItem, treatStart,time,treatEnd);
16:41:22.401:INFO:Log:isc.Page is loaded16:46:12.994:WARN:Log:TypeError: com_smartgwt_client_widgets_form_fields_FormItem_$hide__Lcom_smartgwt_client_widgets_form_fields_FormItem_2_self_0.hide is not a function
I get the same error in the disable function, if I put it first.
Leave a comment:
-
Well, the request is not exactly failing. The problem is that it's not even executed. I've set a Window.alert message on the client side of my fetch operation and I see the message when the combobox is at the root of the page. When I put the combobox in the calendar editor, then the message is not shown and Firebug does not show any network usage (while in the former case, it shows the request/response of GWT RPC). So the problem is that, it doesn't even try to get the elements from the datasource.
I think I've found a bug. If I have enough time, I'll try to compose a simple test project.
Leave a comment:
-
There's no problem with your usage. The question is why the request is failing. As for any other failed request, checked for JavaScript errors, use the RPC tab in the Developer Console to look at the request and response.
If you think you've discovered a bug, please put together a standalone test case demonstrating the issue.
Leave a comment:
-
Just to test, I've created a DynamicForm out of the calendar page and I've enganged it to my datasource DSA. Then, I've added a SelectItem item enganged to DSAF and with the same configuration as the one in the calendar.
To better reflect the behavior of the calendar, I've added the dynamic form to a Window which will show clicking on a button.
Code:final SelectItem item = new SelectItem(DSAF); item.setDisplayField(DSBF1); item.setValueField(DSBF2); item.setOptionDataSource(DSB.getInstance()); DynamicForm form = new DynamicForm(); form.setDataSource(DSA.getInstance()); form.setItems(item); final com.smartgwt.client.widgets.Window popup = new com.smartgwt.client.widgets.Window(); popup.addChild(form); Button popupButton = new Button("Popup"); popupButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.centerInPage(); popup.show(); } });
With this test, I think that it may be a bug or a limitation of the calendar. Can I make what I want with the custom fields of a calendar editor? Can I use databound items to edit my custom fields?
Leave a comment:
-
I've tried putting the Window.alert message in the transformOperation method from the GWT RPC Datasouce class and I'm getting it every time a datasource loads but not when I show the combo or when I click on it, it only shows the "Loading data..." message. Is anything more needed to load a combo from a remote datasource?
Leave a comment:
-
ComboBox not getting data from datasource
Hello, I have a calendar bound to a datasource (let's call it DSA). One of those fields (DSAF) must be set with a fixed set of values, so I've bound it to a combobox. That values are retrieved from a datasource (DSB) so I made the following:
Code:Calendar cal = new Calendar(); cal.setDataSource(DSA.getInstance()); ...................................................... ComboBoxItem item = new ComboBoxItem(DSAF); item.setDisplayField(DSBF1); item.setValueField(DSBF2); item.setOptionDataSource(DSB.getInstance()); item.setAutoFetchData(true); TextItem descItem = new TextItem("description"); cal.setEventEditorFields(descItem,item);
I tried bounding this datasource to a list grid and it gets filled, but for the combo it does not call even the fetch operation. I've set the datasource to show a message with Window.alert on every fetch and I get it when it's called from the list but not when I open the combobox list.
Both datasources are GWT RPC Datasources and I'm using GWT 1.6.4 with SmartGwt 1.1.Tags: None
Leave a comment: