Re: DropDownChoice with ChoiceRenderer
:) yes, that was it: @Override public String getObject(String paramString, IModel> paramIModel) { return paramString; } solved it:) On Fri, Oct 14, 2016 at 4:03 PM, Per Newgro wrote: > Hello ganea, > > can you please investigate the method below? > > Hope that helps > Per > > Am 14.10.2016 um 14:52 schrieb ganea iulia: > >> @Override >> public String getObject(String paramString, IModel> extends >> String>> paramIModel) { >> // TODO Auto-generated method stub >> return null; >> } >> > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: DropDownChoice with ChoiceRenderer
Hello ganea, can you please investigate the method below? Hope that helps Per Am 14.10.2016 um 14:52 schrieb ganea iulia: @Override public String getObject(String paramString, IModel> paramIModel) { // TODO Auto-generated method stub return null; } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
DropDownChoice with ChoiceRenderer
Hello, I'm using Wicket 7. I have this simple use case where I need to have a dropdownchoice, where to display some values, but the model should retain other values. I have done the following, however, the model always retains null. So my dropdownchoice should display Code1 and Code2 but save in the model the values C1 or C2. Instead it always saves null. ==HTML== Name: Code: [Code] ==JAVA== public TestPage(IModel model) { super(model); TestForm tst = new TestForm("testForm", model); tst.setOutputMarkupId(true); add(tst); } class TestForm extends Form { /** * */ private static final long serialVersionUID = 1L; public TestForm(String id, IModel model) { super(id, model); TextField txtName = new TextField("txtName", new PropertyModel(getModelObject(), "name")); add(txtName); txtName.setOutputMarkupId(true); //choice List lst = new ArrayList(); lst.add("C1"); lst.add("C2"); ChoiceRenderer renderer = new ChoiceRenderer("code") { private static final long serialVersionUID = 8875819661197521211L; @Override public Object getDisplayValue(String arg0) { return (arg0.equals("C1") ? "Code1" : "Code2"); } @Override public String getIdValue(String arg0, int arg1) { return arg0; } @Override public String getObject(String paramString, IModel> paramIModel) { // TODO Auto-generated method stub return null; } }; DropDownChoice code = new DropDownChoice("code", lst, renderer); code.setOutputMarkupId(true); code.setModel(new PropertyModel(getModelObject(), "code")); add(code); } @Override protected void onSubmit() { logger.info("OnSubmit"); System.out.println("Code=" + getModelObject().getCode()); } } ==Bean for the MODEL== public class TestBean implements Serializable{ /** * */ private static final long serialVersionUID = 1L; private String name; private String code; private Integer id; public TestBean(String name, String code, Integer id) { this.name = name; this.code = code; this.id = id; } public TestBean() { this.name = ""; this.code = ""; this.id = null; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } }
Re: DropdownChoice with ChoiceRenderer does not use idValue for setting Model
You can also use property files for holding label values. - Wicket-Java -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropdownChoice-with-ChoiceRenderer-does-not-use-idValue-for-setting-Model-tp4115836p4118392.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropdownChoice with ChoiceRenderer does not use idValue for setting Model
Ok. Now im holding a map, using its keys as choices and a choicerenderer gives the values for rendering.. its working... nice Thanks! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropdownChoice-with-ChoiceRenderer-does-not-use-idValue-for-setting-Model-tp4115836p4116029.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropdownChoice with ChoiceRenderer does not use idValue for setting Model
Hi Philipp, DropDownChoice is supposed to work exactly as you described it, nothing wrong there. If you want to have it the other way around, you have to provide ids in your choices model and use the ChoiceRenderer to display readable strings. Hope this helps Sven Am 28.11.2011 17:41, schrieb Philipp Schreiber: Hi, I got some strange behavior with a DropdownChoice and a ChoiceRenderer. I got a List of Stings as choices and a Renderer which splits these strings into Name and Id part. Inside the Browser the value attrib and text is set correctly. But after a submit the whole String is set in the Model. I thought only the idValue gets set. -> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/markup/html/form/ChoiceRenderer.html Dropdownchoice API Whats wrong here?? Thanks Philipp -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DropdownChoice-with-ChoiceRenderer-does-not-use-idValue-for-setting-Model-tp4115836p4115836.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org