Clear input form values
Hello, I'm using Wicket 7. Please help me with the following. I have a test form, with only one input text field on it. When pressing on a link, I need to have the values in the form cleared out. This is the html and java code, but I could not make it work, the input field just won't clear. Name: public TestPage(IModel model, final ReturnObjectPage returnPage) { super(model); this.returnPage = returnPage; add(new TestForm("testForm", model)); } 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.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(txtName); } }); txtName.setOutputMarkupId(true); AjaxLink clearLink = new AjaxLink("clearLink", model) { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { model.setObject(new TestBean()); TestForm.this.clearInput(); target.add(TestForm.this); target.add(txtName); } }; add(clearLink); } @Override protected void onSubmit() { logger.info("OnSubmit"); } }
Repeat every 2 rows in a table
Hello, I have in the html file, a table where I need to repeat every two rows. So, my table is backed by a bean, where the bean values fill 2 rows of the table. When new bean instance is created, I need to add new 2 rows to the table. Thank you
Re: Clear input form values
Hello, The txtName field has the .setOutputMarkupId(true). I have also added it to the form. But it doesn't work howevere. I have event tested adding it to the txtLink, but still no change. However, the issue appears to come from the txtName.add(new AjaxFormComponentUpdatingBehavior("change") {...} If I comment out this part, the clear is done. But I need to have this behaviour kept. Could you please advise? Thank you On Fri, Oct 14, 2016 at 10:10 AM, Martin Grigorov wrote: > On Fri, Oct 14, 2016 at 9:01 AM, ganea iulia > wrote: > > > Hello, > > > > I'm using Wicket 7. > > > > Please help me with the following. > > > > I have a test form, with only one input text field on it. > > When pressing on a link, I need to have the values in the form cleared > out. > > > > This is the html and java code, but I could not make it work, the input > > field just won't clear. > > > > > > > width="100%"> > > > > Name: > > > > > > > > > > > > > > > name="btnClear" /> > > > > > > > > > > > > > > > > public TestPage(IModel model, final ReturnObjectPage > returnPage) > > { > > super(model); > > this.returnPage = returnPage; > > > > Don't keep references to other pages. > Use PageReference instead. > > > > > > add(new TestForm("testForm", model)); > > > > } > > > > 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.add(new AjaxFormComponentUpdatingBehavior("change") { > > private static final long serialVersionUID = 1654345477970524731L; > > > > @Override > > protected void onUpdate(AjaxRequestTarget target) { > > target.add(txtName); > > } > > > > }); > > txtName.setOutputMarkupId(true); > > AjaxLink clearLink = new AjaxLink("clearLink", > model) > > { > > /** > > * > > */ > > private static final long serialVersionUID = 1L; > > > > @Override > > public void onClick(AjaxRequestTarget target) { > > model.setObject(new TestBean()); > > TestForm.this.clearInput(); > > target.add(TestForm.this); > > target.add(txtName); > > > > 1. There is no need to add 'txtName' to the target because its parent > (TestForm) is added > 2. Neither of them have .setOutputMarkupId(true), so Wicket won't be able > to update them in the DOM. It should even complain about this. > > > > } > > > > }; > > add(clearLink); > > } > > @Override > > protected void onSubmit() { > > > > logger.info("OnSubmit"); > > > > } > > } > > >
Re: Clear input form values
Hello, But that was it. The code contained both the txtName.setOutputMarkupId(true) and the txtName.add(new AjaxFormComponentUpdatingBehavior("change") { ... I will paste all the code again (I have now only added the txtLink.setOutputMarkupId(true) and the TestForm.setOutputMarkupId(true); ) Thank you ==HTML code== Name: ==JAVA CODE== public class TestPage extends WebPage { private static final long serialVersionUID = 311508940740808005L; private static final Logger logger = LogManager.getLogger(TestPage.class); 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); txtName.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(txtName); } }); AjaxLink clearLink = new AjaxLink("clearLink", model) { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { model.setObject(new TestBean()); TestForm.this.clearInput(); target.add(TestForm.this); } }; clearLink.setOutputMarkupId(true); add(clearLink); } @Override protected void onSubmit() { logger.info("OnSubmit"); } } } ==THE BEAN== import java.io.Serializable; public class TestBean implements Serializable{ /** * */ private static final long serialVersionUID = 1L; private String name; private String code; private Integer id; 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; } } On Fri, Oct 14, 2016 at 10:43 AM, Martin Grigorov wrote: > We can only advise on the code that you give us. > Your real code may not work for many other reasons but since you give us > some incomplete copies of it we have no idea what is wrong. > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Fri, Oct 14, 2016 at 9:33 AM, ganea iulia > wrote: > > > Hello, > > > > The txtName field has the .setOutputMarkupId(true). > > I have also added it to the form. > > But it doesn't work howevere. > > I have event tested adding it to the txtLink, but still no change. > > > > However, the issue appears to come from the > > txtName.add(new AjaxFormComponentUpdatingBehavior("change") {...} > > > > If I comment out this part, the clear is done. > > But I need to have this behaviour kept. > > > > Could you please advise? > > Thank you > > > > > > On Fri, Oct 14, 2016 at 10:10 AM, Martin Grigorov > > wrote: > > > > > On Fri, Oct 14, 2016 at 9:01 AM, ganea iulia > > > wrote: > > > > > > > Hello, > > > > > > > > I'm using Wicket 7. > > > > > > > > Please help me with the following. > > > > > > > > I have a test form, with only one input text field on it. > > > > When pressing on a link, I need to have the values in the form > cleared > > > out. > > > > > > > > This is the html and java code, but I could not make it work, the > input > > > > field just won't clear. > > > > > > > > > > > > > > > width="100%"> > > > > > > > > Name: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > name="btnClear" /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > public TestPage(IModel model, final ReturnObjectPage > > > returnPage) > > > > { > > > > super(model); > > > > this.returnPage = returnPage; > > > > > > > > > > Don't keep references to other pages. > > > Use PageReference instead. > > > > > > > > > > > > > > add(new TestForm("testForm", model)); > > > > > > > > } > > > > > > > > class TestForm extends Form { > > > > /
Re: Repeat every 2 rows in a table
Hello Per, thank you for the links. I have following html code: Name Code Id The Java code looks like this: 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); List beans = Arrays.asList(new TestBean("Name1", "Code1", 1), new TestBean("Name2", "Code2", 2)); add(new ListView("forEachItem", beans) { /** * */ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label("itemName", new PropertyModel(item.getModel(), "name"))); item.add(new Label("itemCode", new PropertyModel(item.getModel(), "code"))); item.add(new Label("itemId", new PropertyModel(item.getModel(), "id"))); } }); } @Override protected void onSubmit() { logger.info("OnSubmit"); } } The code crashes here because itemId belongs to another row. Could you please advise? Thank you On Fri, Oct 14, 2016 at 10:29 AM, Per Newgro wrote: > Hello ganea, > > you can find many information about your problem at > http://examples7x.wicket.apache.org/index.html > espacially > http://examples7x.wicket.apache.org/repeater > > The user guide can you find here > https://ci.apache.org/projects/wicket/guide/7.x/ > Repeaters are explained here > https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html > > You can add a markup container to a list view item and add the required > row components to it. > > Hope that helps > Per > > > Am 14.10.2016 um 09:16 schrieb ganea iulia: > >> Hello, >> >> I have in the html file, a table where I need to repeat every two rows. >> So, my table is backed by a bean, where the bean values fill 2 rows of the >> table. >> When new bean instance is created, I need to add new 2 rows to the table. >> >> Thank you >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Repeat every 2 rows in a table
Thank you, works great. On Fri, Oct 14, 2016 at 12:06 PM, Peter Henderson < peter.hender...@starjar.com> wrote: > Hi > > Change your markup to > > ... > > .. > > > > > > > > > > > > > > > > > > On 14 October 2016 at 09:44, ganea iulia wrote: > > > Hello Per, thank you for the links. > > > > I have following html code: > > > > > > > > > width="100%"> > > > > > > Name > > Code > > > > > > Id > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The Java code looks like this: > > > > 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); > > > > List beans = Arrays.asList(new TestBean("Name1", "Code1", 1), > > new TestBean("Name2", "Code2", 2)); > > add(new ListView("forEachItem", beans) { > > /** > > * > > */ > > private static final long serialVersionUID = 1L; > > > > @Override > > protected void populateItem(ListItem item) { > > item.add(new Label("itemName", new PropertyModel(item.getModel(), > > "name"))); > > item.add(new Label("itemCode", new PropertyModel(item.getModel(), > > "code"))); > > item.add(new Label("itemId", new PropertyModel(item.getModel(), > "id"))); > > } > > }); > > } > > > > @Override > > protected void onSubmit() { > > > > logger.info("OnSubmit"); > > > > } > > } > > > > The code crashes here because itemId belongs to another row. > > Could you please advise? > > > > Thank you > > > > > > > > On Fri, Oct 14, 2016 at 10:29 AM, Per Newgro wrote: > > > > > Hello ganea, > > > > > > you can find many information about your problem at > > > http://examples7x.wicket.apache.org/index.html > > > espacially > > > http://examples7x.wicket.apache.org/repeater > > > > > > The user guide can you find here > > > https://ci.apache.org/projects/wicket/guide/7.x/ > > > Repeaters are explained here > > > https://ci.apache.org/projects/wicket/guide/7.x/guide/repeaters.html > > > > > > You can add a markup container to a list view item and add the required > > > row components to it. > > > > > > Hope that helps > > > Per > > > > > > > > > Am 14.10.2016 um 09:16 schrieb ganea iulia: > > > > > >> Hello, > > >> > > >> I have in the html file, a table where I need to repeat every two > rows. > > >> So, my table is backed by a bean, where the bean values fill 2 rows of > > the > > >> table. > > >> When new bean instance is created, I need to add new 2 rows to the > > table. > > >> > > >> Thank you > > >> > > >> > > > > > > - > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > > > -- > Peter Henderson > > Director > Starjar Ltd. > www.starjar.com > 0330 088 1662 >
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
:) 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: Clear input form values
Hello, Do you have any new advise on this? Thank you. On Fri, Oct 14, 2016 at 11:02 AM, ganea iulia wrote: > Hello, > But that was it. > The code contained both the > txtName.setOutputMarkupId(true) and the > txtName.add(new AjaxFormComponentUpdatingBehavior("change") { ... > > > I will paste all the code again (I have now only added the > txtLink.setOutputMarkupId(true) and the TestForm.setOutputMarkupId(true); > ) > Thank you > > ==HTML code== > > width="100%"> > > Name: > > > > > > > name="btnClear" /> > > > > > > ==JAVA CODE== > > public class TestPage extends WebPage { > > private static final long serialVersionUID = 311508940740808005L; > private static final Logger logger = LogManager.getLogger(TestPage.class); > > 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); > txtName.add(new AjaxFormComponentUpdatingBehavior("change") { > private static final long serialVersionUID = 1654345477970524731L; > > @Override > protected void onUpdate(AjaxRequestTarget target) { > target.add(txtName); > } > > }); > > AjaxLink clearLink = new AjaxLink("clearLink", model) > { > /** > * > */ > private static final long serialVersionUID = 1L; > > @Override > public void onClick(AjaxRequestTarget target) { > model.setObject(new TestBean()); > TestForm.this.clearInput(); > target.add(TestForm.this); > > } > > }; > clearLink.setOutputMarkupId(true); > add(clearLink); > } > > @Override > protected void onSubmit() { > > logger.info("OnSubmit"); > > } > } > > > } > > > ==THE BEAN== > > import java.io.Serializable; > > public class TestBean implements Serializable{ > > /** > * > */ > private static final long serialVersionUID = 1L; > private String name; > private String code; > private Integer id; > 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; > } > > } > > > > On Fri, Oct 14, 2016 at 10:43 AM, Martin Grigorov > wrote: > >> We can only advise on the code that you give us. >> Your real code may not work for many other reasons but since you give us >> some incomplete copies of it we have no idea what is wrong. >> >> Martin Grigorov >> Wicket Training and Consulting >> https://twitter.com/mtgrigorov >> >> On Fri, Oct 14, 2016 at 9:33 AM, ganea iulia >> wrote: >> >> > Hello, >> > >> > The txtName field has the .setOutputMarkupId(true). >> > I have also added it to the form. >> > But it doesn't work howevere. >> > I have event tested adding it to the txtLink, but still no change. >> > >> > However, the issue appears to come from the >> > txtName.add(new AjaxFormComponentUpdatingBehavior("change") {...} >> > >> > If I comment out this part, the clear is done. >> > But I need to have this behaviour kept. >> > >> > Could you please advise? >> > Thank you >> > >> > >> > On Fri, Oct 14, 2016 at 10:10 AM, Martin Grigorov > > >> > wrote: >> > >> > > On Fri, Oct 14, 2016 at 9:01 AM, ganea iulia >> > > wrote: >> > > >> > > > Hello, >> > > > >> > > > I'm using Wicket 7. >> > > > >> > > > Please help me with the following. >> > > > >> > > > I have a test form, with only one input text field on it. >> > > > When pressing on a link, I need to have the values in the form >> cleared >> > > out. >> > > > >> > > > This is the html and java code, but I could not make it work, the >> input >> > > > field just won't clear. >> > > > >> >
Check Group selected items called from other form loses the checked values
Hi, I have 2 forms. Bottom form = testForm - I have a listview with checkboxes. As I needed a checkAll control also, I have uses CheckGroup, CheckGroupSelector and Check wicket components. Top form = testForm0 -I have only an link The use case is the following: I check one item (or all) in bottom form, but then I need to get the selected values when click on link in top form. The check doesn't do submit so the values are not retained. I alsways get the size = 0 message. Could you tell me how I can manage this? Here is the code: =HTML= Name Code Id ==JAVA== private static final long serialVersionUID = 311508940740808005L; private static final Logger logger = LogManager.getLogger(TestPage.class); private TestForm tst; public TestPage(IModel model) { super(model); TestForm0 tst0 = new TestForm0("testForm0"); tst0.setOutputMarkupId(true); add(tst0); tst = new TestForm("testForm", model); tst.setOutputMarkupId(true); add(tst); } class TestForm0 extends Form { /** * */ private static final long serialVersionUID = 1L; public TestForm0(String id) { super(id); Link print = new Link("print") { private static final long serialVersionUID = 15L; @Override public void onClick() { System.out.println("size=" + tst.getCheckedTestBeans().size()); } }; add(print); } } class TestForm extends Form { /** * */ private static final long serialVersionUID = 1L; private List checkedTestBeans; public List getCheckedTestBeans() { return checkedTestBeans; } public void setCheckedTestBeans(List checkedTestBeans) { this.checkedTestBeans = checkedTestBeans; } public TestForm(String id, IModel model) { super(id, model); checkedTestBeans = new ArrayList(); TextField txtName = new TextField("txtName", new PropertyModel(getModelObject(), "name")); add(txtName); txtName.setOutputMarkupId(true); txtName.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(txtName); } }); SubmitLink clearForm = new SubmitLink("clearForm", this){ /** * */ private static final long serialVersionUID = 1L; @Override public void onSubmit() { model.setObject(new TestBean()); TestForm.this.clearInput(); }; }; clearForm.setOutputMarkupId(true); add(clearForm); AjaxLink clearLink = new AjaxLink("clearLink", model) { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { model.setObject(new TestBean()); TestForm.this.clearInput(); target.add(TestForm.this); txtName.setConvertedInput(""); } }; clearLink.setOutputMarkupId(true); add(clearLink); /// CheckGroup group = new CheckGroup("group", checkedTestBeans); CheckGroupSelector cgs = new CheckGroupSelector("allCheck"); group.add(cgs); List beans = Arrays.asList(new TestBean("Name1", "Code1", 1), new TestBean("Name2", "Code2", 2)); final WebMarkupContainer itemsContainer = new WebMarkupContainer("itemsContainer"); itemsContainer.setOutputMarkupId(true); itemsContainer.add(new ListView("forEachItem", beans) { /** * */ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label("itemName", new PropertyModel(item.getModel(), "name"))); item.add(new Label("itemCode", new PropertyModel(item.getModel(), "code"))); item.add(new Label("itemId", new PropertyModel(item.getModel(), "id"))); item.add(new Check("itemCheck", item.getModel(), group)); } }); group.add(itemsContainer); add(group); //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 paramString; } }; 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("size=" + checkedTestBeans.size()); } }
Re: Check Group selected items called from other form loses the checked values
Hello, I have actually made this to work by adding this behaviour to the checkgroup: group.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(group); } }); However, now I face following issue: If I replace my ListView component, with a RefreshingView, I cannot check any of the checks from the items. I check it, but then it gets unchecked right away. This is because the RefreshingView repaints its model at every roundtrip to the server. I have tried this: http://stackoverflow.com/questions/12282492/add-row-to-refreshingview-without-repainting-entire-refreshingview by setting: listOfItems.setItemReuseStrategy(new ReuseIfModelsEqualStrategy()); But it did not change a thing for me. Please guide on how to have a Check for every item of the RepeatingView, that can be checked. Thank you. On Tue, Oct 18, 2016 at 1:28 PM, ganea iulia wrote: > Hi, > I have 2 forms. > > Bottom form = testForm > - I have a listview with checkboxes. > As I needed a checkAll control also, I have uses CheckGroup, > CheckGroupSelector and Check wicket components. > > Top form = testForm0 > -I have only an link > > The use case is the following: > I check one item (or all) in bottom form, but then I need to get the > selected values when click on link in top form. > > The check doesn't do submit so the values are not retained. I alsways get > the > size = 0 message. > > Could you tell me how I can manage this? > > Here is the code: > =HTML= > > width="100%"> > > > /> > > > > > > > width="100%"> > > > Name > Code > > > Id > > > > > > > > > > > > /> > > > > > > > name="btnSave" value="OK" /> > > > > > > > > > ==JAVA== > private static final long serialVersionUID = 311508940740808005L; > private static final Logger logger = LogManager.getLogger(TestPage.class); > private TestForm tst; > > public TestPage(IModel model) { > super(model); > > TestForm0 tst0 = new TestForm0("testForm0"); > tst0.setOutputMarkupId(true); > add(tst0); > tst = new TestForm("testForm", model); > tst.setOutputMarkupId(true); > add(tst); > > } > > class TestForm0 extends Form { > > /** > * > */ > private static final long serialVersionUID = 1L; > > public TestForm0(String id) { > super(id); > > Link print = new Link("print") { > private static final long serialVersionUID = 15L; > > @Override > public void onClick() { > System.out.println("size=" + tst.getCheckedTestBeans().size()); > } > }; > add(print); > } > } > class TestForm extends Form { > /** > * > */ > private static final long serialVersionUID = 1L; > > private List checkedTestBeans; > public List getCheckedTestBeans() { > return checkedTestBeans; > } > > public void setCheckedTestBeans(List checkedTestBeans) { > this.checkedTestBeans = checkedTestBeans; > } > > public TestForm(String id, IModel model) { > super(id, model); > > checkedTestBeans = new ArrayList(); > TextField txtName = new TextField("txtName", new > PropertyModel(getModelObject(), "name")); > add(txtName); > txtName.setOutputMarkupId(true); > txtName.add(new AjaxFormComponentUpdatingBehavior("change") { > private static final long serialVersionUID = 1654345477970524731L; > > @Override > protected void onUpdate(AjaxRequestTarget target) { > target.add(txtName); > } > > }); > > SubmitLink clearForm = new SubmitLink("clearForm", this){ > > /** > * > */ > private static final long serialVersionUID = 1L; > @Override > public void onSubmit() { > model.setObject(new TestBean()); > TestForm.this.clearInput(); > }; > }; > clearForm.setOutputMarkupId(true); > add(clearForm); > AjaxLink clearLink = new AjaxLink("clearLink", model) > { > /** > * > */ > private static final long serialVersionUID = 1L; > > @Override > public void onClick(AjaxRequestTarget target) { > model.setObject(new TestBean()); > TestForm.this.clearInput(); > target.add(TestForm.this); > txtName.setConvertedInput(""); > > } > > }; > clearLink.setOutputMarkupId(true); > add(clearLink); > /// > CheckGroup group = new CheckGroup("group", > checkedTestBeans); > CheckGroupSelector cgs = new Chec
Re: Check Group selected items called from other form loses the checked values
Hello, Thank you for the samples. But I will explain again what I have: I have two forms on my page. In the bottom form I have a RefreshingView component, with check all checkbox in the header, and check components for each items. In the top form there is a link, where I need to get the checked items from the second form (the bottom form); This is what I have done: For checkAll and the individual checks I have used CheckGroup, CheckGroupSelector and Check. The issue is that because the refreshing view refreshes the model at every server roundtrip, when I check on item, the check doesn't maintain it's value, because it receives every time a new model. So this bit from the RefreshingView always returns a new model which makes the checks to dissapera: @Override protected Iterator> getItemModels() { List lst = SpringCtx.getAppDB(TestBeanDao.class).selectAll(); List> models = new ArrayList>(); for (TestBean tstSN:lst) { IModel modTst = new Model(tstSN); models.add(modTst); } return models.iterator(); } Isn;t there any way that I can still use the CheckGroup and Check components? As this comes easy when it is needed a CheckAll functionality. Thank you Here is the code: =Java code= private static final long serialVersionUID = 311508940740808005L; private static final Logger logger = LogManager.getLogger(TestPage.class); private TestForm tst; public TestPage(IModel model) { super(model); TestForm0 tst0 = new TestForm0("testForm0"); tst0.setOutputMarkupId(true); add(tst0); tst = new TestForm("testForm", model); tst.setOutputMarkupId(true); add(tst); } class TestForm0 extends Form { /** * */ private static final long serialVersionUID = 1L; public TestForm0(String id) { super(id); Link print = new Link("print") { private static final long serialVersionUID = 15L; @Override public void onClick() { System.out.println("size=" + tst.getCheckedTestBeans().size()); } }; add(print); } } class TestForm extends Form { /** * */ private static final long serialVersionUID = 1L; private List checkedTestBeans; public List getCheckedTestBeans() { return checkedTestBeans; } public void setCheckedTestBeans(List checkedTestBeans) { this.checkedTestBeans = checkedTestBeans; } public TestForm(String id, IModel model) { super(id, model); checkedTestBeans = new ArrayList(); TextField txtName = new TextField("txtName", new PropertyModel(getModelObject(), "name")); add(txtName); txtName.setOutputMarkupId(true); txtName.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(txtName); } }); /// CheckGroup group = new CheckGroup("group1", checkedTestBeans); group.setOutputMarkupId(true); group.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(group); } }); CheckGroupSelector cgs = new CheckGroupSelector("allCheck1"); group.add(cgs); final WebMarkupContainer itemsContainer = new WebMarkupContainer("itemsContainer1"); itemsContainer.setOutputMarkupId(true); itemsContainer.add(new RefreshingView("forEachItem1") { /** * */ private static final long serialVersionUID = 1L; @Override protected Iterator> getItemModels() { List lst = SpringCtx.getAppDB(TestBeanDao.class).selectAll(); List> models = new ArrayList>(); for (TestBean tstSN:lst) { IModel modTst = new Model(tstSN); models.add(modTst); } return models.iterator(); } @Override protected void populateItem(Item item) { item.add(new Label("itemName", new PropertyModel(item.getModel(), "name"))); item.add(new Label("itemCode", new PropertyModel(item.getModel(), "code"))); item.add(new Label("itemId", new PropertyModel(item.getModel(), "id"))); Check chk = new Check("itemCheck", item.getModel(), group); item.add(chk); } }); group.add(itemsContainer); add(group); } @Override protected void onSubmit() { logger.info("OnSubmit"); System.out.println("size=" + checkedTestBeans.size()); } } =HTML= Name Code Id On Wed, Oct 19, 2016 at 7:24 PM, Francois Meillet < francois.meil...@gmail.com> wrote: > Have a look at > > https://cwiki.apache.org/confluence/display/WICKET/ > Listview+with+checkboxes <https://cwiki.apache.org/ > confluence/display/WICKET/Listview+with+checkboxes> > > https://www.mkyong.com/wicket/wicket-multiple-checkboxes-example- > checkboxmultiplechoice/ <https://www.mkyong.com/wicket/wicket-multiple- > checkboxes-example-checkboxmultiplechoice/> > > > > François > > > > > Le 19 oct. 2016 à 16:11, ganea iulia a é
Re: Check Group selected items called from other form loses the checked values
Thank you so much for these examples. This is great. On Thu, Oct 20, 2016 at 2:22 PM, Francois Meillet < francois.meil...@gmail.com> wrote: > Hi, > > Use a ListView. > > The model of the second form is not updated until the form is submitted. > You need to perform a submit if you want to see this model updated, and > the correct value for tst.getCheckedTestBeans().size(). > > If you want to avoid the manual submit phase, you need to use Ajax. > > Please find here your code slightly modified. > > TestPage > http://pastebin.com/DYNpeZLt > TestPage.html > http://pastebin.com/gFa6Z5ZS > ModelForForm > http://pastebin.com/EhjezBWJ > Wrapper > http://pastebin.com/8B7n68VH > > > François > > > > > > Le 20 oct. 2016 à 08:38, ganea iulia a écrit : > > > > Hello, Thank you for the samples. > > But I will explain again what I have: > > > > I have two forms on my page. > > In the bottom form I have a RefreshingView component, with check all > > checkbox in the header, and check components for each items. > > In the top form there is a link, where I need to get the checked items > from > > the second form (the bottom form); > > > > This is what I have done: > > For checkAll and the individual checks I have used CheckGroup, > > CheckGroupSelector and Check. > > > > The issue is that because the refreshing view refreshes the model at > every > > server roundtrip, when I check on item, the check doesn't maintain it's > > value, because it receives every time a new model. > > > > So this bit from the RefreshingView always returns a new model which > makes > > the checks to dissapera: > > @Override > > protected Iterator> getItemModels() { > > List lst = SpringCtx.getAppDB(TestBeanDao.class).selectAll(); > > List> models = new ArrayList>(); > > for (TestBean tstSN:lst) { > > IModel modTst = new Model(tstSN); > > models.add(modTst); > > } > > return models.iterator(); > > } > > > > > > Isn;t there any way that I can still use the CheckGroup and Check > > components? As this comes easy when it is needed a CheckAll > functionality. > > > > Thank you > > > > Here is the code: > > > > =Java code= > > > > private static final long serialVersionUID = 311508940740808005L; > > private static final Logger logger = LogManager.getLogger(TestPage. > class); > > private TestForm tst; > > public TestPage(IModel model) { > > super(model); > > > > TestForm0 tst0 = new TestForm0("testForm0"); > > tst0.setOutputMarkupId(true); > > add(tst0); > > tst = new TestForm("testForm", model); > > tst.setOutputMarkupId(true); > > add(tst); > > > > > > } > > > > class TestForm0 extends Form { > > > > /** > > * > > */ > > private static final long serialVersionUID = 1L; > > > > public TestForm0(String id) { > > super(id); > > > > Link print = new Link("print") { > > private static final long serialVersionUID = 15L; > > > > @Override > > public void onClick() { > > System.out.println("size=" + tst.getCheckedTestBeans().size()); > > } > > }; > > add(print); > > } > > } > > class TestForm extends Form { > > /** > > * > > */ > > private static final long serialVersionUID = 1L; > > > > private List checkedTestBeans; > > public List getCheckedTestBeans() { > > return checkedTestBeans; > > } > > > > public void setCheckedTestBeans(List checkedTestBeans) { > > this.checkedTestBeans = checkedTestBeans; > > } > > > > public TestForm(String id, IModel model) { > > super(id, model); > > > > checkedTestBeans = new ArrayList(); > > TextField txtName = new TextField("txtName", new > > PropertyModel(getModelObject(), "name")); > > add(txtName); > > txtName.setOutputMarkupId(true); > > txtName.add(new AjaxFormComponentUpdatingBehavior("change") { > > private static final long serialVersionUID = 1654345477970524731L; > > > > @Override > > protected void onUpdate(AjaxRequestTarget target) { > > target.add(txtName); > > } > > > > }); > > > > /// > > CheckGroup group = new CheckGroup("group1", > > checkedTestBeans); > > group.setOutputMarkupId(true); > > group.add(new AjaxFormChoiceComponentUpdatingBehavior() { > > private static final long serialVersionUID = 16543454779705247
AutocompleteTextField on submit : The value of .. is not a valid ...
Hi, Please help me with following issue: I'm using wicket 7. I have a form with a AutocompleteTextField. The autocompletion works ok until I need to submit the form, when I get following message: - The value of 'test' is not a valid TestBean. Here is my component: IAutoCompleteRenderer testRenderer = new IAutoCompleteRenderer() { private static final long serialVersionUID = -7038764178796856779L; @Override public void render(TestBean object, Response response, String criteria) { response.write((new StringBuilder()).append("").toString()); response.write(object.getUniqueName()); response.write(""); } @Override public void renderFooter(Response response, int ItemId) { response.write(""); } @Override public void renderHeader(Response response) { response.write(""); } }; AutoCompleteTextField txt = new AutoCompleteTextField("test", new PropertyModel(this, "myTestBean"), TestBean.class, testRenderer, (new AutoCompleteSettings().setPreselect(true))) { private static final long serialVersionUID = 1L; private List TestList = null; @Override protected Iterator getChoices(String input) { if (Strings.isEmpty(input)) { return Collections.emptyIterator(); } else { if (input.length() > 0) { if (TestList == null || TestList.isEmpty() || !input.substring(0, 1).toUpperCase().equals(TestList.get(0).getUniqueName().substring(0, 1).toUpperCase())) { TestList = SpringCtx.getAppDB(TestBeanDao.class).selectAproxByUniqueName(input.substring(0, 1)); } } } int autoCompleteFieldNumChoices = 20; List choices = new ArrayList(autoCompleteFieldNumChoices); for (int i = 0; i < TestList.size(); i++) { final TestBean testBean = TestList.get(i); final String testName = testBean.getUniqueName(); if (testName.toUpperCase().startsWith(input.toUpperCase())) { choices.add(testBean); if (choices.size() == autoCompleteFieldNumChoices) { break; } } } return choices.iterator(); } };
How to access wicket parent page wicket:message
[pageTitle] Hi, I'm using wicket 7.5. I have a parent page, and child pages that extend it: In my child .properties pages, I always had the pageTitle=My Titile. I now need to dinamically change the title of the page, inside my child page constructor. Could you please advise? Thank you
Re: How to access wicket parent page wicket:message
Hello, Could you please provide an example? I have added the below line in my constructor, but nothing appears where the title should be. add(new Label("pageTitle", new ResourceModel("pageTitle", "my title"))); In the child .properties files I have left the pageTitle empty: pageTitle= In the child .html page, I haven't added anything. Thank you. On Tue, Nov 1, 2016 at 10:14 AM, Martin Grigorov wrote: > Hi, > > You will need to use a Label component with ResourceModel instead of > . > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Tue, Nov 1, 2016 at 9:02 AM, ganea iulia > wrote: > > > [pageTitle] > > > > Hi, > > I'm using wicket 7.5. > > > > I have a parent page, and child pages that extend it: > > > > In my child .properties pages, I always had the pageTitle=My Titile. > > > > I now need to dinamically change the title of the page, inside my child > > page constructor. > > > > Could you please advise? > > > > Thank you > > >
Re: How to access wicket parent page wicket:message
Hello again, So I need to change the parent page markup? I was thinking if there was a way to not change anything in the parent page... So my parent page html contains this markup: [pageTitle] I need in my child pages, to be able to dinamically change the title. Until now, every child page had a pageTitle property in the .properties file and that was setting the title. But now, I have a situation where I need to open up the same child page with different titles, based on some condition. Thank you On Tue, Nov 1, 2016 at 10:57 AM, Martin Grigorov wrote: > I'd expect Wicket to complain (i.e. throw an exception) that you have added > a component in the Java code but there is no element for it in the HTML. > You need to remove and add wicket:id="pageTitle" on the > element. > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Tue, Nov 1, 2016 at 9:39 AM, ganea iulia > wrote: > > > Hello, > > > > Could you please provide an example? > > > > I have added the below line in my constructor, but nothing appears where > > the title should be. > > > > add(new Label("pageTitle", new ResourceModel("pageTitle", "my title"))); > > > > In the child .properties files I have left the pageTitle empty: > pageTitle= > > > > In the child .html page, I haven't added anything. > > > > > > Thank you. > > > > > > > > > > > > > > On Tue, Nov 1, 2016 at 10:14 AM, Martin Grigorov > > wrote: > > > > > Hi, > > > > > > You will need to use a Label component with ResourceModel instead of > > > . > > > > > > Martin Grigorov > > > Wicket Training and Consulting > > > https://twitter.com/mtgrigorov > > > > > > On Tue, Nov 1, 2016 at 9:02 AM, ganea iulia > > > wrote: > > > > > > > [pageTitle] > > > > > > > > Hi, > > > > I'm using wicket 7.5. > > > > > > > > I have a parent page, and child pages that extend it: > > > > > > > > In my child .properties pages, I always had the pageTitle=My Titile. > > > > > > > > I now need to dinamically change the title of the page, inside my > child > > > > page constructor. > > > > > > > > Could you please advise? > > > > > > > > Thank you > > > > > > > > > >
DataTable with input columns, refresh values shown in other columns
Hello, I'm using wicket 7.5. I have a DataTable, where one of the columns is an input textfield with a clickable icon near it. When providing data for the input field, and clicking the icon, some validations are done, and the fields for other columns should be updated accordingly. However they are not updated at all. Could you please advise how I can implement this? Thank you.
Re: DataTable with input columns, refresh values shown in other columns
Hello, thank you for the help. It did solve some of the situations, but not all of them. Here is where I still face issues. In my table row, I have an input field and a icon near it. I insert text into input field and press the icon (AjaxLink component). 1. If data exists in the db for that input value, the data is shown in others columns - OK, this works now. 2. If data does not exist in the db for that input value, a popup window opens allowing to insert the new values - NOK This does not work because when coming back from the pop window the row is not refreshed with the new inserted values in the db. 3. on change event of the input, the data from the others row cells should be emptied - NOK, this does not work either. //this is how I get the row MarkupContainer row = cellItem.findParent(Item.class); //change event txt.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1654345477970524731L; @Override protected void onUpdate(AjaxRequestTarget target) { getModelObject().setValue1(null); getModelObject().setValue2(null); target.add(row); } }); Thank you for your help On Wed, Nov 9, 2016 at 12:43 PM, Sven Meier wrote: > Hi, > > I'm assuming you're using Ajax, so you should update the whole row after > your behavior/component has changed the field. > > Each row item has to output a markup id, e.g. you can use a custom Item > subclass that calls #setOutputMarkupId(true): > > protected Item newRowItem(final String id, final int index, final > IModel model) > { > return new RowItem<>(id, index, model); > } > > This has the advantage, that you can update the row from wherever you are > inside the row: > > @Override > protected void onUpdate(AjaxRequestTarget target) { > RowItem row = findParent(RowItem.class); > target.addComponent(row); > } > > Alternatively you can use Wicket event bubbling to notify the rowItem to > update itself. > > Hope this helps > Sven > > > > Am 09.11.2016 um 09:41 schrieb ganea iulia: > >> Hello, >> >> I'm using wicket 7.5. >> I have a DataTable, where one of the columns is an input textfield with a >> clickable icon near it. When providing data for the input field, and >> clicking the icon, some validations are done, and the fields for other >> columns should be updated accordingly. >> >> However they are not updated at all. >> Could you please advise how I can implement this? >> >> Thank you. >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: DataTable with input columns, refresh values shown in other columns
Hello, 2) Yes, the target.add(row) is on the callback from the modalWindow. 3) yes, I need to update the other values after user leaves the input, I don't want immediate changes after each character change. While in debug mode, I can see the change event being called, and the all the values set to null, but the row is still not getting updated. On Thu, Nov 10, 2016 at 12:08 PM, Sven Meier wrote: > Hi, > > 2) > usually you would have a callback on your popup, that is called when the > it closes. This would be the time to update the edited row. > > 3) > the browser invokes the 'change' event only *after* leaving the input > field. You can listen for immediate changes with Wicket's > OnChangeAjaxBehavior - but updating the whole row while you're editing one > input inside of it will interfere with the user's input :/. > > Hope this helps > Sven > > > > > Am 10.11.2016 um 10:55 schrieb ganea iulia: > >> Hello, thank you for the help. >> It did solve some of the situations, but not all of them. >> Here is where I still face issues. >> >> In my table row, I have an input field and a icon near it. I insert text >> into input field and press the icon (AjaxLink component). >> >> 1. If data exists in the db for that input value, the data is shown in >> others columns - OK, this works now. >> 2. If data does not exist in the db for that input value, a popup window >> opens allowing to insert the new values - NOK >> This does not work because when coming back from the pop window the >> row >> is not refreshed with the new inserted values in the db. >> 3. on change event of the input, the data from the others row cells should >> be emptied - NOK, this does not work either. >> >> //this is how I get the row >> MarkupContainer row = cellItem.findParent(Item.class); >> >> //change event >> txt.add(new AjaxFormComponentUpdatingBehavior("change") { >> private static final long serialVersionUID = 1654345477970524731L; >> >> @Override >> protected void onUpdate(AjaxRequestTarget target) { >> >> >> getModelObject().setValue1(null); >> getModelObject().setValue2(null); >> >> target.add(row); >> } >> >> }); >> >> >> Thank you for your help >> >> >> On Wed, Nov 9, 2016 at 12:43 PM, Sven Meier wrote: >> >> Hi, >>> >>> I'm assuming you're using Ajax, so you should update the whole row after >>> your behavior/component has changed the field. >>> >>> Each row item has to output a markup id, e.g. you can use a custom Item >>> subclass that calls #setOutputMarkupId(true): >>> >>> protected Item newRowItem(final String id, final int index, final >>> IModel model) >>> { >>> return new RowItem<>(id, index, model); >>> } >>> >>> This has the advantage, that you can update the row from wherever you are >>> inside the row: >>> >>> @Override >>> protected void onUpdate(AjaxRequestTarget target) { >>> RowItem row = findParent(RowItem.class); >>> target.addComponent(row); >>> } >>> >>> Alternatively you can use Wicket event bubbling to notify the rowItem to >>> update itself. >>> >>> Hope this helps >>> Sven >>> >>> >>> >>> Am 09.11.2016 um 09:41 schrieb ganea iulia: >>> >>> Hello, >>>> >>>> I'm using wicket 7.5. >>>> I have a DataTable, where one of the columns is an input textfield with >>>> a >>>> clickable icon near it. When providing data for the input field, and >>>> clicking the icon, some validations are done, and the fields for other >>>> columns should be updated accordingly. >>>> >>>> However they are not updated at all. >>>> Could you please advise how I can implement this? >>>> >>>> Thank you. >>>> >>>> >>>> - >>> 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 > >
Datatable with drop down choice
Hello, Could you please advise what would be the best option to have in my DataTable, a column, where the cells contain a drop down choice? Thank you
Iterate through lines from datatable with editable columns
Hello, I m using wicket 7.5. I have a datatable, where some of the columns contain editable components: -dropdownchoices -checkboxes -TextFields After I edit some of the editable cells, when hitting a process button, I need to iterate through all lines from the datatable and save the changes. But I cannot see the changes. The initial values always appear. Could you please advise on how I can iterate through a DataTable, and get the values of the cells as they are shown? Thank you.
Reading Image from absolute path
Hello, Wicket 7. I have been struggling to read an image from absolute path but with no luck. I have a folder with some images inside catalina base directory from where I need to display images in my web page. However, this does not work. Could you please guide me on how to do this? Thank you.
Re: Reading Image from absolute path
Hello, Do you have any link for a tutorial? On Fri, Dec 16, 2016 at 1:04 PM, Ernesto Reinaldo Barreiro < reier...@gmail.com> wrote: > Mount a resource that readi image form that folder > > On Fri, Dec 16, 2016 at 11:54 AM, ganea iulia > wrote: > > > Hello, > > Wicket 7. > > > > I have been struggling to read an image from absolute path but with no > > luck. > > > > I have a folder with some images inside catalina base directory from > where > > I need to display images in my web page. > > However, this does not work. > > > > > > Could you please guide me on how to do this? > > > > Thank you. > > > > > > -- > Regards - Ernesto Reinaldo Barreiro >
Re: Reading Image from absolute path
Thank you all, I will give it a try. On Fri, Dec 16, 2016 at 3:32 PM, Tobias Soloschenko < tobiassolosche...@googlemail.com> wrote: > Hi, > > if you mean absolute file system path > > https://ci.apache.org/projects/wicket/apidocs/7.x/ > org/apache/wicket/resource/FileSystemResourceReference.html > > If you mean path my URL: > > https://ci.apache.org/projects/wicket/apidocs/7.x/ > org/apache/wicket/markup/html/image/ExternalImage.html > > Examples are in the javadoc > > kind regards > > Tobias > > > Am 16.12.2016 um 13:14 schrieb Ernesto Reinaldo Barreiro < > reier...@gmail.com>: > > > > I think this example > > > > http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/ > > > > will do if you implement the getBytes method to read image from file > system. > > > > On Fri, Dec 16, 2016 at 12:19 PM, ganea iulia > > wrote: > > > >> Hello, > >> Do you have any link for a tutorial? > >> > >> On Fri, Dec 16, 2016 at 1:04 PM, Ernesto Reinaldo Barreiro < > >> reier...@gmail.com> wrote: > >> > >>> Mount a resource that readi image form that folder > >>> > >>> On Fri, Dec 16, 2016 at 11:54 AM, ganea iulia > >>> wrote: > >>> > >>>> Hello, > >>>> Wicket 7. > >>>> > >>>> I have been struggling to read an image from absolute path but with no > >>>> luck. > >>>> > >>>> I have a folder with some images inside catalina base directory from > >>> where > >>>> I need to display images in my web page. > >>>> However, this does not work. > >>>> > >>>> > >>>> Could you please guide me on how to do this? > >>>> > >>>> Thank you. > >>>> > >>> > >>> > >>> > >>> -- > >>> Regards - Ernesto Reinaldo Barreiro > >>> > >> > > > > > > > > -- > > Regards - Ernesto Reinaldo Barreiro >
Form with backing loadabledetachable model
Hello, I have a list of items in a Refreshing View. When I click on a link inside the Refreshing View, a form in the same page should get populated with the values from the line. I have managed to do this, by having inside the Form a LoadableDetacheableModel and then use this model as backing model for the components in the form. However, I have also a drop down inside the form, but when changing the value, the LoadableDetacheableModel does not get updated with the new value. Or if using getModelObject(), all values are null, because, the backing model of the form is null. Could you please advise? Thank you
Re: Form with backing loadabledetachable model
Hello, =Here is the RefreshingView link item. When clicking on this link, the form should be filled with the values of this RefreshingView line. When click on the link, I set the property itemmodel with the line model. The itemmodel is then used by the LoadableDetacheableModel, to get the values for the form. // edit link AjaxLink linkEditItem = new AjaxLink("linkEditForm", model) { private static final long serialVersionUID = 15L; @Override public void onClick(AjaxRequestTarget target) { feedbackPanel.getFeedbackMessages().clear(); editForm.clearInput(); editForm.setItemmodel(new Model(item.getModelObject())); target.add(editForm); target.add(feedbackPanel); } }; =Here is the form: class EditForm extends Form { /** * Form where you can edit the items from the list */ private static final long serialVersionUID = 1L; private IModel itemmodel; public void setItemmodel(IModel itemmodel) { this.itemmodel = itemmodel; } public EditForm(String id, IModel model) { super(id, model); this.itemmodel = model; final LoadableDetachableModel poItemsListModel = new LoadableDetachableModel() { private static final long serialVersionUID = 0L; @Override protected MyBean load() { return itemmodel.getObject(); } }; // Edit ITEMS final WebMarkupContainer editContainer = new WebMarkupContainer("editContainer"); editContainer.setOutputMarkupId(true); add(editContainer); final MyBean tst = poItemsListModel.getObject(); // unrepairable DropDownChoice unrepairable = new DropDownChoice("unrepairable", lstSN, renderer) { private static final long serialVersionUID = 1L; *@Override* * public boolean isEnabled() {* * return (tst.getId() == null || (tst.getIrreparableSal() != null && !tst.getIrreparableSal().equals("S")));* * }* }; unrepairable.setModel(new PropertyModel(poItemsListModel, "irreparableSal")); unrepairable.setOutputMarkupId(true); editContainer.add(unrepairable); unrepairable.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(unrepairable); } }); In this piece of code(also in bold above), I cannot ever get the actual values of my LoadableDetacheableModel; they are always null, they never get updated with the values of the line. *@Override* *public boolean isEnabled() {* * return (tst.getId() == null || (tst.getIrreparableSal() != null && !tst.getIrreparableSal().equals("S")));* *}* On Fri, Dec 16, 2016 at 9:52 PM, Sven Meier wrote: > Hi, > > >Or if using getModelObject(), all values are null, because, the backing > >model of the form is null. > > how does your LDM load its model object? > > Show us some code or better create a quickstart so someone can take a look > at it. > > Sven > > > > On 16.12.2016 16:24, ganea iulia wrote: > >> Hello, >> I have a list of items in a Refreshing View. >> When I click on a link inside the Refreshing View, a form in the same page >> should get populated with the values from the line. >> >> I have managed to do this, by having inside the Form a >> LoadableDetacheableModel and then use this model as backing model for the >> components in the form. >> >> However, I have also a drop down inside the form, but when changing the >> value, the LoadableDetacheableModel does not get updated with the new >> value. >> >> Or if using getModelObject(), all values are null, because, the backing >> model of the form is null. >> >> Could you please advise? >> >> Thank you >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Free library for barcode
Hello, I need to generate barcodes. Do you know what is the best way in wicket? Or can you indicate any good commercially free libraries? Thank you
ListView color background lineitem dinamically not working
Hello, I have a listview and I want to dinamically color some of the rows (items). But it is not working, nothing gets colored when it should. *Here is the markup:* [item1] [item2] [item3] [item4] [item5] [item6] [item7] [item8] [item9] [item10] Area *Here is the code:* @Override protected ListItem newItem(final int index, IModel model) { return new ListItem(index, getListItemModel(getModel(), index)) { @Override protected void onComponentTag(final ComponentTag tag) { Items line = getModelObject(); if (line.getIdLn() == 6) tag.put("style", "background-color:green"); else if (line.getIdLn() == 4 ) tag.put("style", "background-color:red"); // continue with default behavior super.onComponentTag(tag); } }; } Could you please advise?
Re: ListView color background lineitem dinamically not working
Thank you so much for you explanation. I had to put the two inside the because I need to repeat every two rows. On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier wrote: > Hi, > > it seems your ListView is bound to the wicket:id="forEachItem"> tag, which cannot be styled. > > Change your markup to: > > > > > Have fun > Sven > > > On 16.03.2017 09:58, ganea iulia wrote: > >> Hello, >> >> I have a listview and I want to dinamically color some of the rows >> (items). >> But it is not working, nothing gets colored when it should. >> >> *Here is the markup:* >> >> >> >> >> [item1] >> [item2] >> [item3] >> [item4] >> [item5] >> [item6] >> [item7] >> [item8] >> [item9] >> [item10] >> >> >> > cols="100">Area >> >> >> >> >> >> *Here is the code:* >> >> @Override >> protected ListItem newItem(final int index, IModel model) { >> return new ListItem(index, getListItemModel(getModel(), index)) { >> >> @Override >> protected void onComponentTag(final ComponentTag tag) { >> Items line = getModelObject(); >> if (line.getIdLn() == 6) >> tag.put("style", "background-color:green"); >> else if (line.getIdLn() == 4 ) >> tag.put("style", "background-color:red"); >> >> // continue with default behavior >> super.onComponentTag(tag); >> >> } >> }; >> } >> >> Could you please advise? >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: ListView color background lineitem dinamically not working
Thank you so much for you explanation. I had to put the two inside the because I need to repeat every two rows. Do you have any hint on how to do it and still be able to change the color? On Thu, Mar 16, 2017 at 12:36 PM, ganea iulia wrote: > Thank you so much for you explanation. > I had to put the two inside the because I need to > repeat every two rows. > > > > On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier wrote: > >> Hi, >> >> it seems your ListView is bound to the > wicket:id="forEachItem"> tag, which cannot be styled. >> >> Change your markup to: >> >> >> >> >> Have fun >> Sven >> >> >> On 16.03.2017 09:58, ganea iulia wrote: >> >>> Hello, >>> >>> I have a listview and I want to dinamically color some of the rows >>> (items). >>> But it is not working, nothing gets colored when it should. >>> >>> *Here is the markup:* >>> >>> >>> >>> >>> [item1] >>> [item2] >>> [item3] >>> [item4] >>> [item5] >>> [item6] >>> [item7] >>> [item8] >>> [item9] >>> [item10] >>> >>> >>> >> cols="100">Area >>> >>> >>> >>> >>> >>> *Here is the code:* >>> >>> @Override >>> protected ListItem newItem(final int index, IModel model) { >>> return new ListItem(index, getListItemModel(getModel(), index)) { >>> >>> @Override >>> protected void onComponentTag(final ComponentTag tag) { >>> Items line = getModelObject(); >>> if (line.getIdLn() == 6) >>> tag.put("style", "background-color:green"); >>> else if (line.getIdLn() == 4 ) >>> tag.put("style", "background-color:red"); >>> >>> // continue with default behavior >>> super.onComponentTag(tag); >>> >>> } >>> }; >>> } >>> >>> Could you please advise? >>> >>> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >
Re: ListView color background lineitem dinamically not working
Thank you, it's great! On Thu, Mar 16, 2017 at 1:05 PM, Sven Meier wrote: > Hi, > > you'll have to add two MarkupContainers and style both : > > > > ... > ... > > > protected void populateItem(ListItem item) { > WebMarkupContainer firstRow = new WebMarkupContainer("firstRow") { > @Override > protected void onComponentTag(final ComponentTag tag) { > Items line = item.getModelObject(); > if (line.getIdLn() == 6) > tag.put("style", "background-color:green"); > else if (line.getIdLn() == 4 ) > tag.put("style", "background-color:red"); > > // continue with default behavior > super.onComponentTag(tag); > }; > item.add(firstRow); > > firstRow.add(... > > WebMarkupContainer secondRow = ...; > } > > Best regards > Sven > > > On 16.03.2017 11:39, ganea iulia wrote: > >> Thank you so much for you explanation. >> I had to put the two inside the because I need to >> repeat every two rows. >> Do you have any hint on how to do it and still be able to change the >> color? >> >> >> >> On Thu, Mar 16, 2017 at 12:36 PM, ganea iulia >> wrote: >> >> Thank you so much for you explanation. >>> I had to put the two inside the because I need to >>> repeat every two rows. >>> >>> >>> >>> On Thu, Mar 16, 2017 at 11:26 AM, Sven Meier wrote: >>> >>> Hi, >>>> >>>> it seems your ListView is bound to the >>> wicket:id="forEachItem"> tag, which cannot be styled. >>>> >>>> Change your markup to: >>>> >>>> >>>> >>>> >>>> Have fun >>>> Sven >>>> >>>> >>>> On 16.03.2017 09:58, ganea iulia wrote: >>>> >>>> Hello, >>>>> >>>>> I have a listview and I want to dinamically color some of the rows >>>>> (items). >>>>> But it is not working, nothing gets colored when it should. >>>>> >>>>> *Here is the markup:* >>>>> >>>>> >>>>> >>>>> >>>>> [item1] >>>>> [item2] >>>>> [item3] >>>>> [item4] >>>>> [item5] >>>>> [item6] >>>>> [item7] >>>>> [item8] >>>>> [item9] >>>>> [item10] >>>>> >>>>> >>>>> >>>> cols="100">Area >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> *Here is the code:* >>>>> >>>>> @Override >>>>> protected ListItem newItem(final int index, IModel >>>>> model) { >>>>> return new ListItem(index, getListItemModel(getModel(), index)) >>>>> { >>>>> >>>>> @Override >>>>> protected void onComponentTag(final ComponentTag tag) { >>>>> Items line = getModelObject(); >>>>> if (line.getIdLn() == 6) >>>>> tag.put("style", "background-color:green"); >>>>> else if (line.getIdLn() == 4 ) >>>>> tag.put("style", "background-color:red"); >>>>> >>>>> // continue with default behavior >>>>> super.onComponentTag(tag); >>>>> >>>>> } >>>>> }; >>>>> } >>>>> >>>>> Could you please advise? >>>>> >>>>> >>>>> - >>>> 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 > >