Form Data Not Available When Testing a TextArea component

2009-09-25 Thread Caristi, Joe
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.codeCopy and paste a license 
code:/wicket:messagebr/
  textarea cols=50 rows=1 wicket:id=licenseCode/textareabr/
  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.


RE: Form Data Not Available When Testing a TextArea component

2009-09-25 Thread Caristi, Joe
Thank you. That was it. I appreciate the help!

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
Sent: Friday, September 25, 2009 12:22 PM
To: users@wicket.apache.org
Subject: Re: Form Data Not Available When Testing a TextArea component

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.codeCopy and paste a license 
 code:/wicket:messagebr/
  textarea cols=50 rows=1 wicket:id=licenseCode/textareabr/
  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


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



RE: Newbie IMG question

2008-11-14 Thread Caristi, Joe
Hello Martijn:

Thank you for your prompt reply.  This was exactly what I needed.  I did 
purchase your Wicket in Action book and I started reading it yesterday.  The 
book is great!  I also appreciate the high quality sample application, which 
will be very helpful as I begin to create my own applications.

Regards,

Joe Caristi

-Original Message-
From: Martijn Dashorst [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2008 9:54 AM
To: users@wicket.apache.org
Subject: Re: Newbie IMG question

it depends where you put the image. If you put it next to the html and
java file, you should surround the img tag with
wicket:link/wicket:link otherwise Wicket won't know that you want
Wicket to serve the image.

If you put it in the context root, then usually you don't have to do
anything (depending on your filter mapping). If you want to control
the image from Java code, but still put it in the context root, then
you should use the ContextImage component.

Martijn

On Fri, Nov 14, 2008 at 3:37 PM, jcaristi [EMAIL PROTECTED] wrote:

 I am using Wicket 1.4-rc1 (I also tried 1.3.5). I have a very simple
 application with a very simple IMG tag:

 img src=whi-06sliced_02.gif

 In the browser, the image does not display and the page source looks like
 this:

 img src=../whi-06sliced_02.gif

 From all of the documentation I've read, this does not seem to be the
 correct behavior.  I've tried locating the image everywhere I can think of,
 without success.  I think the image should be in the same folder (or a
 sub-folder) of the Java and HTML for the page.  Is this correct?  How do I
 get the relative path to be properly set?

 Here is my web.xml:

 filter
filter-nameWicketFilter/filter-name

 filter-classorg.apache.wicket.protocol.http.WicketFilter/filter-class
init-param
param-nameapplicationClassName/param-name
param-valuecom.whisolutions.pss.web.NexPartPS/param-value
/init-param
 /filter
 filter-mapping
filter-nameWicketFilter/filter-name
url-pattern/admin/*/url-pattern
 /filter-mapping

 Here is the code:

 http://www.nabble.com/file/p20501647/ServerCode.java ServerCode.java
 http://www.nabble.com/file/p20501647/ServerCode.html ServerCode.html
 http://www.nabble.com/file/p20501647/NexPartPS.java NexPartPS.java

 I'm using Maven for the Wicket dependency:

 dependency
groupIdorg.apache.wicket/groupId
artifactIdwicket/artifactId
version1.4-rc1/version
 /dependency

 --
 View this message in context: 
 http://www.nabble.com/Newbie-IMG-question-tp20501647p20501647.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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 [EMAIL PROTECTED],
and destroy all copies of this message and any attachments.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]