clickLink() ? shouldnt you be submitting the form? links dont submit forms afaik.
-igor On Fri, Sep 25, 2009 at 8:21 AM, Caristi, Joe <jcari...@whisolutions.com> wrote: > I have a very simple Wicket web page with one TextArea for data entry on a > form. This is contained in a NavomaticBorder. The form works properly, as > the data is successfully saved to the database when the Submit button is > clicked. My JUnit test fails however, because the data is null. I am using > the setValue method of the FormTester object, and when I step through the > code can see the value being saved. However, when I execute clickLink() and > get into the form submit method, the data is null. I even tried stepping > through the Wicket source code, but I can't figure out where the data gets > lost. > > > > Can someone help with this? Here is my test code: > > > WicketTester tester = new WicketTester(partSelectLicenseWeb); > tester.startPage(LicenseDataReplace.class); > FormTester formTester = > tester.newFormTester("navomaticBorder:licenseDataReplaceForm"); > formTester.setValue("licenseCode", "xyz"); > tester.clickLink("navomaticBorder:licenseDataReplaceForm:submitButton"); > tester.assertRenderedPage(LicenseDataReplaceResult.class); > Page resultPage = tester.getLastRenderedPage(); > numLicensesSaved = resultPage.get("numLicensesSaved").toString(); > > Here is my form HTML: > > <form wicket:id="licenseDataReplaceForm" action=""> > <wicket:message key="copy.paste.license.code">Copy and paste a license > code:</wicket:message><br/> > <textarea cols="50" rows="1" wicket:id="licenseCode"></textarea><br/> > <input wicket:id="submitButton" type="submit" value="Submit" > wicket:message="value:submit" /> > </form> > > Here is my (simplified) web page code: > > public class LicenseDataReplace extends WebPage { > > TextArea licenseCode = new TextArea("licenseCode", new Model()); > > public LicenseDataReplace() { > > class LicenseDataReplaceForm extends Form { > > protected void onSubmit() { > > String enteredCode = LicenseDataReplace.this > .getLicenseCode() > > .getDefaultModelObjectAsString()); > > ... save enteredCode to database > ... navigate to next page > } > > public LicenseDataReplaceForm(String id) { > super(id); > } > }; > > NavomaticBorder navomaticBorder = new > NavomaticBorder("navomaticBorder"); > navomaticBorder.add(new Image("logo")); > navomaticBorder.add(new Image("message")); > Form form = new LicenseDataReplaceForm("licenseDataReplaceForm"); > form.add(licenseCode); > SubmitLink submitLink = new SubmitLink("submitButton"); > form.add(submitLink); > navomaticBorder.add(form); > add(navomaticBorder); > } > > > ________________________________ > STATEMENT OF CONFIDENTIALITY: > > > > The information contained in this electronic message and any attachments to > this message are intended for the exclusive use of the addressee(s) and may > contain confidential or privileged information. If you are not the intended > recipient, please notify WHI Solutions immediately at g...@whisolutions.com, > and destroy all copies of this message and any attachments. > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org