GWT Version: 2.0.3
Smart GWT Version: 2.2
I'm trying to create a new custom built FormItem that would load a text file fetched from the server by selecting a file from a drop down (SelectItem) and then populate a text box with the contents of the file. The user would edit the contents in the text box and then when the form is submitted it would read the contents of the text box. I read up a lot and found this post, http://forums.smartclient.com/showthread.php?t=11651, which helped a lot to get me started, but ultimately I've encountered a similar problem to the one mentioned in the linked thread, but in a different form.
I tried to create a custom DynamicForm that was aware of my new custom FormItem like in the example only to find out that editRecord and saveData are never being called. It was only after digging a bit more in our code that I found that the SmartGWT framework was not being used properly. What is actually happening is that when the submit button is clicked to submit the form someone decided to instead get all the values from the form through getValueAsRecord, package it into a custom component and send it to the server.
I plan to fix this mistake when I have the time but right now I am already behind schedule so I have no time left. So what I'm begging for is an explanation on how the FormItems are queried when dynamicForm.getValuesAsRecord is called? Does it call FormItem.getValue ? I would have thought so but unfortunately it isn't the case since my log statement is never triggered. Then again maybe I'm doing something wrong with how I coded my custom form. This is the code I used for the custom form.
So to summarize, I create my TextLoadingEditor, insert it into a dynamic form and then when I call getValuesAsRecord the AlertWindow.post("getValue(?)"); never shows up.
Smart GWT Version: 2.2
I'm trying to create a new custom built FormItem that would load a text file fetched from the server by selecting a file from a drop down (SelectItem) and then populate a text box with the contents of the file. The user would edit the contents in the text box and then when the form is submitted it would read the contents of the text box. I read up a lot and found this post, http://forums.smartclient.com/showthread.php?t=11651, which helped a lot to get me started, but ultimately I've encountered a similar problem to the one mentioned in the linked thread, but in a different form.
I tried to create a custom DynamicForm that was aware of my new custom FormItem like in the example only to find out that editRecord and saveData are never being called. It was only after digging a bit more in our code that I found that the SmartGWT framework was not being used properly. What is actually happening is that when the submit button is clicked to submit the form someone decided to instead get all the values from the form through getValueAsRecord, package it into a custom component and send it to the server.
I plan to fix this mistake when I have the time but right now I am already behind schedule so I have no time left. So what I'm begging for is an explanation on how the FormItems are queried when dynamicForm.getValuesAsRecord is called? Does it call FormItem.getValue ? I would have thought so but unfortunately it isn't the case since my log statement is never triggered. Then again maybe I'm doing something wrong with how I coded my custom form. This is the code I used for the custom form.
Code:
public class TextLoadingEditorItem extends CanvasItem { public TextLoadingEditorItem() { setName("TextLoadingEditorItem"); final DynamicForm dynamicForm = new DynamicForm(); SelectItem fileSelection = new SelectItem("File"); TextItem titleArea = new TextItem("File Name"); TextAreaItem textArea = new TextAreaItem("Editor"); textArea.setWidth(400); textArea.setHeight(800); textArea.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { AlertWindow.post("ChangedHandler called"); setValue(event.getValue().toString()); } }); ButtonItem safeFileButton = new ButtonItem("Save File"); dynamicForm.setItems(fileSelection, titleArea, textArea, saveFileButton); setShouldSaveValue(true); setCanvas(dynamicForm); } @Override public void setValue(String value) { AlertWindow.post("setValue("+value+")"); super.setValue(value); } @Override public Object getValue() { AlertWindow.post("getValue(?)"); return super.getValue(value); } }
Comment