-
5 Jan 2009 10:34 AM #1
[FIXED] ComboBox issue setValue to hidden field
[FIXED] ComboBox issue setValue to hidden field
when set a value to combobox the hidden field don't received the value.. I need select the item in combobox to my hidden field receveid the value.. the problem:
my form have a combobox that have the country that the person live.. when the user go update your profile.. I need reset this field and do the user to select you country again...
TestModel.javaCode:ListStore<TestModel> store = new ListStore<TestModel>(); TestModel model = new TestModel(); model.setCodigo(1); model.setNome("name 1"); TestModel model1 = new TestModel(); model1.setCodigo(2); model1.setNome("name 2"); store.add(model); store.add(model1); FormPanel form = new FormPanel(); ComboBox<TestModel> combo = new ComboBox<TestModel>(); combo.setStore(store); combo.setFieldLabel("xxx"); combo.setDisplayField("nome"); combo.setValueField("codigo"); combo.setName("comboBox"); combo.setValue(model); form.add(combo); RootPanel.get().add(form);
Code:public class TestModel extends BaseModel { public Integer getCodigo() { return get("codigo"); } public String getNome() { return get("nome"); } public void setCodigo(Integer codigo) { set("codigo", codigo); } public void setNome(String nome) { set("nome", nome); } }
-
5 Jan 2009 10:43 AM #2
wait.. setValueField() ???? I will test
-
5 Jan 2009 10:52 AM #3
add to the code, and you can see that the hidden field continue with the value empty..
Code:combo.setValueField(model.getCodigo().toString());
-
5 Jan 2009 11:01 AM #4
-
6 Jan 2009 2:20 AM #5
In combobox...
????Code:private String loadingText = "Loading...";
in properties..
Code:# ComboBox comboBox_loading=Loading...
-
6 Jan 2009 2:25 AM #6
to solve this problem....
Code:if (valueField != null) { hiddenInput = Document.get().createHiddenInputElement().cast(); hiddenInput.setName(getName() + "-hidden"); parent.appendChild(hiddenInput); updateHiddenValue(); // add this line or use other logic }
-
6 Jan 2009 2:37 AM #7
We already have a fix for this ready. Your suggested fix isnt fixing the hole issue.
-
6 Jan 2009 2:39 AM #8
-
6 Jan 2009 3:15 AM #9
now appears other problem..
Example.javaCode:public void onModuleLoad() { ListStore<TestModel> store = new ListStore<TestModel>(); TestModel model = new TestModel(); model.setCodigo(1); model.setNome("name 1"); TestModel model1 = new TestModel(); model1.setCodigo(2); model1.setNome("name 2"); store.add(model); store.add(model1); final FormPanel form = new FormPanel(); form.setAction("Example"); form.setMethod(Method.POST); ComboBox<TestModel> combo = new ComboBox<TestModel>(); combo.setStore(store); combo.setFieldLabel("xxx"); combo.setDisplayField("nome"); combo.setValueField("codigo"); combo.setName("comboBox"); combo.setValue(model); combo.setValueField(model.getCodigo().toString()); Button button = new Button("button"); button.addSelectionListener(new SelectionListener<ComponentEvent>() { @Override public void componentSelected(ComponentEvent ce) { form.submit(); } }); form.add(combo); form.add(button); RootPanel.get().add(form); }
Click to the button, return null. OK - the bugCode:@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println(request.getAttribute("comboBox-hidden")); }
Change to "name 2" in combo box, click to the button, return null..
You can test too, with your new code this? Because when the user will go update your profile.. he can't more save... same change the value.
thanks
-
6 Jan 2009 3:22 AM #10
As i told you. Your suggested fix isnt fixing the hole issue...



Reply With Quote