Re: NumberFormatException from Requests with invalid URIs

2013-07-25 Thread Martin Funk
done
https://issues.apache.org/jira/browse/WICKET-5287


2013/7/25 Sven Meier 

> ServletWebRequest#**getContextRelativeUrl() passes "foo://:/" to
> Url#parse() and that one fails.
>
> Please create a Jira issue.
>
> Sven
>
>
> On 07/24/2013 05:06 PM, Martin Funk wrote:
>
>> Hi Sven,
>>
>> we still can reproduce this on any version.
>>
>> Maybe this git diff gives a clearer picture:
>>
>> diff --git
>> a/wicket-core/src/test/java/**org/apache/wicket/protocol/**http/servlet/*
>> *ServletWebRequestTest.java
>> b/wicket-core/src/test/java/**org/apache/wicket/protocol/**http/servlet/*
>> *ServletWebRequestTest.java
>> index f974a06..9ee3308 100644
>> ---
>> a/wicket-core/src/test/java/**org/apache/wicket/protocol/**http/servlet/*
>> *ServletWebRequestTest.java
>> +++
>> b/wicket-core/src/test/java/**org/apache/wicket/protocol/**http/servlet/*
>> *ServletWebRequestTest.java
>> @@ -191,6 +191,16 @@
>>assertEquals("any/source/of/**error", errorClientUrl.toString());
>>}
>>
>> + @Test
>> + public void wicketFoo()
>> + {
>> + String filterPath = "filterPath";
>> + MockHttpServletRequest httpRequest = new MockHttpServletRequest(null,
>> null, null);
>> + httpRequest.setURL("http://**localhost <http://localhost>" + '/' +
>> filterPath +
>> "/request/foo://:/");
>> +
>> + ServletWebRequest webRequest = new ServletWebRequest(httpRequest,
>> filterPath);
>> + }
>> +
>>private static class CustomRequestPage extends WebPage implements
>> IMarkupResourceStreamProvider
>>{
>>private static final long serialVersionUID = 1L;
>>
>> This tests leads to this exption
>>
>> java.lang.**NumberFormatException: For input string: ""
>> at java.lang.**NumberFormatException.**forInputString(Unknown Source)
>> at java.lang.Integer.parseInt(**Unknown Source)
>> at java.lang.Integer.parseInt(**Unknown Source)
>> at org.apache.wicket.request.Url.**parse(Url.java:277)
>> at
>> org.apache.wicket.protocol.**http.servlet.**ServletWebRequest.**
>> getContextRelativeUrl(**ServletWebRequest.java:208)
>> at
>> org.apache.wicket.protocol.**http.servlet.**ServletWebRequest.(**
>> ServletWebRequest.java:112)
>> at
>> org.apache.wicket.protocol.**http.servlet.**ServletWebRequest.(**
>> ServletWebRequest.java:82)
>> at
>> org.apache.wicket.protocol.**http.servlet.**ServletWebRequestTest.**
>> wicketFoo(**ServletWebRequestTest.java:**201)
>> at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native Method)
>> at sun.reflect.**NativeMethodAccessorImpl.**invoke(Unknown Source)
>> at sun.reflect.**DelegatingMethodAccessorImpl.**invoke(Unknown Source)
>> at java.lang.reflect.Method.**invoke(Unknown Source)
>> at
>> org.junit.runners.model.**FrameworkMethod$1.**runReflectiveCall(**
>> FrameworkMethod.java:47)
>> at
>> org.junit.internal.runners.**model.ReflectiveCallable.run(**
>> ReflectiveCallable.java:12)
>> at
>> org.junit.runners.model.**FrameworkMethod.**invokeExplosively(**
>> FrameworkMethod.java:44)
>> at
>> org.junit.internal.runners.**statements.InvokeMethod.**
>> evaluate(InvokeMethod.java:17)
>> at org.junit.runners.**ParentRunner.runLeaf(**ParentRunner.java:271)
>> at
>> org.junit.runners.**BlockJUnit4ClassRunner.**runChild(**
>> BlockJUnit4ClassRunner.java:**70)
>> at
>> org.junit.runners.**BlockJUnit4ClassRunner.**runChild(**
>> BlockJUnit4ClassRunner.java:**50)
>> at org.junit.runners.**ParentRunner$3.run(**ParentRunner.java:238)
>> at org.junit.runners.**ParentRunner$1.schedule(**ParentRunner.java:63)
>> at org.junit.runners.**ParentRunner.runChildren(**ParentRunner.java:236)
>> at org.junit.runners.**ParentRunner.access$000(**ParentRunner.java:53)
>> at org.junit.runners.**ParentRunner$2.evaluate(**ParentRunner.java:229)
>> at org.junit.runners.**ParentRunner.run(ParentRunner.**java:309)
>> at
>> org.eclipse.jdt.internal.**junit4.runner.**JUnit4TestReference.run(**
>> JUnit4TestReference.java:50)
>> at
>> org.eclipse.jdt.internal.**junit.runner.TestExecution.**
>> run(TestExecution.java:38)
>> at
>> org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> runTests(RemoteTestRunner.**java:467)
>> at
>> org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> runTests(RemoteTestRunner.**java:683)
>> at
>> org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> run

Re: NumberFormatException from Requests with invalid URIs

2013-07-25 Thread Sven Meier
ServletWebRequest#getContextRelativeUrl() passes "foo://:/" to 
Url#parse() and that one fails.


Please create a Jira issue.

Sven

On 07/24/2013 05:06 PM, Martin Funk wrote:

Hi Sven,

we still can reproduce this on any version.

Maybe this git diff gives a clearer picture:

diff --git
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
index f974a06..9ee3308 100644
---
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
+++
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
@@ -191,6 +191,16 @@
   assertEquals("any/source/of/error", errorClientUrl.toString());
   }

+ @Test
+ public void wicketFoo()
+ {
+ String filterPath = "filterPath";
+ MockHttpServletRequest httpRequest = new MockHttpServletRequest(null,
null, null);
+ httpRequest.setURL("http://localhost"; + '/' + filterPath +
"/request/foo://:/");
+
+ ServletWebRequest webRequest = new ServletWebRequest(httpRequest,
filterPath);
+ }
+
   private static class CustomRequestPage extends WebPage implements
IMarkupResourceStreamProvider
   {
   private static final long serialVersionUID = 1L;

This tests leads to this exption

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.wicket.request.Url.parse(Url.java:277)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:208)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:112)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:82)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequestTest.wicketFoo(ServletWebRequestTest.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

cheers,


Martin



2013/7/24 Mathias Binder 


We work with Version 6.7.0

Mathias

2013/7/24 Sven Meier :

Hi,

which Wicket version? Url parsing has been improved on lately:

 @Test
 public void weirdUrl()
 {
 Url url = Url.parse("http://wicket.apache.org/h@@p://h@@p://";);

 assertEquals("wicket.apache.org", url.getHost());
 assertEquals("/h@@p://h@@p://", url.getPath());
 }


Works fine with 6.10.0-SNAPSHOT.

Sven


On 07/24/2013 10:29 AM, Mathias Binder wrote:

Hi,

we became aware of a problem caused by requests with invalid URIs on
our wicket-application. The URI contains strings like "*://*:*", so
wicket tries to determine and parse a port number, that is not
present. This leads to NumberFormatExceptions with URIs like, e.g.
http:///h@@p://h@@p://

java.lang.NumberFormatException: For input string: ""



java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

java.lang.Integer.parseInt(Integer.java:470)
java.lang.Integer.parseInt(Integer.java:499)
org.apache.wicket.request.Url.parse(Url.java:197)



org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)



org.apache.wicket.protocol.http.servlet.ServletWeb

Re: NumberFormatException from Requests with invalid URIs

2013-07-24 Thread Martin Funk
Hi Sven,

we still can reproduce this on any version.

Maybe this git diff gives a clearer picture:

diff --git
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
index f974a06..9ee3308 100644
---
a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
+++
b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
@@ -191,6 +191,16 @@
  assertEquals("any/source/of/error", errorClientUrl.toString());
  }

+ @Test
+ public void wicketFoo()
+ {
+ String filterPath = "filterPath";
+ MockHttpServletRequest httpRequest = new MockHttpServletRequest(null,
null, null);
+ httpRequest.setURL("http://localhost"; + '/' + filterPath +
"/request/foo://:/");
+
+ ServletWebRequest webRequest = new ServletWebRequest(httpRequest,
filterPath);
+ }
+
  private static class CustomRequestPage extends WebPage implements
IMarkupResourceStreamProvider
  {
  private static final long serialVersionUID = 1L;

This tests leads to this exption

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.wicket.request.Url.parse(Url.java:277)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:208)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:112)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:82)
at
org.apache.wicket.protocol.http.servlet.ServletWebRequestTest.wicketFoo(ServletWebRequestTest.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

cheers,


Martin



2013/7/24 Mathias Binder 

> We work with Version 6.7.0
>
> Mathias
>
> 2013/7/24 Sven Meier :
> > Hi,
> >
> > which Wicket version? Url parsing has been improved on lately:
> >
> > @Test
> > public void weirdUrl()
> > {
> > Url url = Url.parse("http://wicket.apache.org/h@@p://h@@p://";);
> >
> > assertEquals("wicket.apache.org", url.getHost());
> > assertEquals("/h@@p://h@@p://", url.getPath());
> > }
> >
> >
> > Works fine with 6.10.0-SNAPSHOT.
> >
> > Sven
> >
> >
> > On 07/24/2013 10:29 AM, Mathias Binder wrote:
> >>
> >> Hi,
> >>
> >> we became aware of a problem caused by requests with invalid URIs on
> >> our wicket-application. The URI contains strings like "*://*:*", so
> >> wicket tries to determine and parse a port number, that is not
> >> present. This leads to NumberFormatExceptions with URIs like, e.g.
> >> http:///h@@p://h@@p://
> >>
> >> java.lang.NumberFormatException: For input string: ""
> >>
> >>
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
> >> java.lang.Integer.parseInt(Integer.java:470)
> >> java.lang.Integer.parseInt(Integer.java:499)
> >> org.apache.wicket.request.Url.parse(Url.java:197)
> >>
> >>
> org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)
> >>
> >>
> org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequ

Re: NumberFormatException from Requests with invalid URIs

2013-07-24 Thread Mathias Binder
We work with Version 6.7.0

Mathias

2013/7/24 Sven Meier :
> Hi,
>
> which Wicket version? Url parsing has been improved on lately:
>
> @Test
> public void weirdUrl()
> {
> Url url = Url.parse("http://wicket.apache.org/h@@p://h@@p://";);
>
> assertEquals("wicket.apache.org", url.getHost());
> assertEquals("/h@@p://h@@p://", url.getPath());
> }
>
>
> Works fine with 6.10.0-SNAPSHOT.
>
> Sven
>
>
> On 07/24/2013 10:29 AM, Mathias Binder wrote:
>>
>> Hi,
>>
>> we became aware of a problem caused by requests with invalid URIs on
>> our wicket-application. The URI contains strings like "*://*:*", so
>> wicket tries to determine and parse a port number, that is not
>> present. This leads to NumberFormatExceptions with URIs like, e.g.
>> http:///h@@p://h@@p://
>>
>> java.lang.NumberFormatException: For input string: ""
>>
>> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
>> java.lang.Integer.parseInt(Integer.java:470)
>> java.lang.Integer.parseInt(Integer.java:499)
>> org.apache.wicket.request.Url.parse(Url.java:197)
>>
>> org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)
>>
>> org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:126)
>>
>> org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:83)
>>
>> org.apache.wicket.protocol.http.WebApplication.newWebRequest(WebApplication.java:413)
>>
>> org.apache.wicket.protocol.http.WebApplication.createWebRequest(WebApplication.java:458)
>>
>> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:183)
>>
>> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)
>>
>>
>> Should this issue be fixed in the URL representation from wicket?
>> Something like a check if the string that represents the port-number
>> to be parsed is not emtpy?
>>
>> Thanks
>>
>> -
>> 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
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: NumberFormatException from Requests with invalid URIs

2013-07-24 Thread Sven Meier

Hi,

which Wicket version? Url parsing has been improved on lately:

@Test
public void weirdUrl()
{
Url url = Url.parse("http://wicket.apache.org/h@@p://h@@p://";);

assertEquals("wicket.apache.org", url.getHost());
assertEquals("/h@@p://h@@p://", url.getPath());
}


Works fine with 6.10.0-SNAPSHOT.

Sven

On 07/24/2013 10:29 AM, Mathias Binder wrote:

Hi,

we became aware of a problem caused by requests with invalid URIs on
our wicket-application. The URI contains strings like "*://*:*", so
wicket tries to determine and parse a port number, that is not
present. This leads to NumberFormatExceptions with URIs like, e.g.
http:///h@@p://h@@p://

java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:470)
java.lang.Integer.parseInt(Integer.java:499)
org.apache.wicket.request.Url.parse(Url.java:197)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:126)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:83)
org.apache.wicket.protocol.http.WebApplication.newWebRequest(WebApplication.java:413)
org.apache.wicket.protocol.http.WebApplication.createWebRequest(WebApplication.java:458)
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:183)
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)


Should this issue be fixed in the URL representation from wicket?
Something like a check if the string that represents the port-number
to be parsed is not emtpy?

Thanks

-
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



NumberFormatException from Requests with invalid URIs

2013-07-24 Thread Mathias Binder
Hi,

we became aware of a problem caused by requests with invalid URIs on
our wicket-application. The URI contains strings like "*://*:*", so
wicket tries to determine and parse a port number, that is not
present. This leads to NumberFormatExceptions with URIs like, e.g.
http:///h@@p://h@@p://

java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:470)
java.lang.Integer.parseInt(Integer.java:499)
org.apache.wicket.request.Url.parse(Url.java:197)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContextRelativeUrl(ServletWebRequest.java:222)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:126)
org.apache.wicket.protocol.http.servlet.ServletWebRequest.(ServletWebRequest.java:83)
org.apache.wicket.protocol.http.WebApplication.newWebRequest(WebApplication.java:413)
org.apache.wicket.protocol.http.WebApplication.createWebRequest(WebApplication.java:458)
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:183)
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)


Should this issue be fixed in the URL representation from wicket?
Something like a check if the string that represents the port-number
to be parsed is not emtpy?

Thanks

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Inputing string instead of a double value in junit test case throws NumberFormatException

2012-05-02 Thread Andrea Del Bene
At first sight I would say that your problem could be related to a 
different Locale used during unit test. You should compare the output of 
'myData.getAmount()' when is called during testing and when is called 
running on Jetty server.

I have a integration test case:

 FormTester formTester =
wicketTester.newFormTester("
myForm");
formTester.select("option", 0);

this.wicketTester.executeAjaxEvent("myForm:option", "onchange");

formTester.setValue("fragment:amount","1000");

..

wicketTester.executeAjaxEvent("myForm:fragment:submit",
"onclick");


In java class, for the input field 'amount':

amount = new RequiredTextField("amount", new
Model(), Double.class);
amount.add(new FocusOnLoadBehavior());
amount.setOutputMarkupId(true);
amount.add(new MinimumValidator(0.01));

when submit:
 myData.setAmount(amount.getDefaultModelObjectAsString());
when updating db, it throws java.lang.NubmerFormatException on line:
statement.setBigDecimal(1, new BigDecimal(myData
.getAmount()));


It works in web page input in Jetty Web server, but fails when using
WicketTester.


Here is exception:

 ERROR
service.dao.dbImpl.MyDAOImpl - null
java.lang.NumberFormatException
at java.math.BigDecimal.(BigDecimal.java:459)
at java.math.BigDecimal.(BigDecimal.java:728)
at service.dao.dbImpl.MyDAOImpl.updateAmount(MyDAOImpl.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.wicket.proxy.LazyInitProxyFactory
$JdkHandler.invoke(LazyInitProxyFactory.java:416)
...
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:143)
at
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
at
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
at
org.apache.wicket.util.tester.BaseWicketTester.executeAjaxEvent(BaseWicketTester.java:1236)
at
org.apache.wicket.util.tester.BaseWicketTester.executeAjaxEvent(BaseWicketTester.java:1109)
at

integration.AmountUpdateITCase.updateAmount(AmountUpdateITCase.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at
org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner
$1.runUnprotected(TestClassRunner.java:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: NumberFormatException

2011-08-17 Thread Andrea Del Bene

Hi  Jencity,

you use 'gateway' as model object. Probably this object has one or more 
numeric field binded to a String TextField.
In this case you should use a numeric TextField (for example 
TextField...)




Hello,

i have got a problem with getting my form working. I have got a form called
gatewayForm. I added several textfields and a CompoundPropertyModel to this
form. Everytime I submit the form I get a NumberFormatException. All
textfields are Strings.

/
TextField  name = new TextField("name");
...
Form gatewayForm = new Form("gatewayForm");
CompoundPropertyModel gatewayModel = new CompoundPropertyModel(gateway);
gatewayForm.setModel(gatewayModel);
gatewayForm.add(name);
.../

I tried different notations, but the failure doesn't change. I hope someone
can explain me why this happens or how to get it working.

Thank you very much,

Jencity

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/NumberFormatException-tp3749632p3749632.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



NumberFormatException

2011-08-17 Thread Jencity
Hello,

i have got a problem with getting my form working. I have got a form called
gatewayForm. I added several textfields and a CompoundPropertyModel to this
form. Everytime I submit the form I get a NumberFormatException. All
textfields are Strings.

/
TextField name = new TextField("name");
...
Form gatewayForm = new Form("gatewayForm");
CompoundPropertyModel gatewayModel = new CompoundPropertyModel(gateway);
gatewayForm.setModel(gatewayModel);
gatewayForm.add(name);
.../

I tried different notations, but the failure doesn't change. I hope someone
can explain me why this happens or how to get it working. 

Thank you very much,

Jencity

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/NumberFormatException-tp3749632p3749632.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: Enum with RadioChoice leads to NumberFormatException

2009-08-15 Thread Mischa Dasberg

Hi Reinout,

I guess your Person object has a private int sex; instead of private  
SexType sex;
So what happens is that you are trying to convert a SexType to an  
Integer which obviously returns an

illegalArgumentException.

Put it like this and it should work.

public class Person {
private SexType sex;

public enum SexType {
SEX_UNKNOWN(0), SEX_MALE(1), SEX_FEMALE(2),  
SEX_NOT_APPLICABLE(9);

private int id;

SexType(int id) { this.id = id; }

public int getId() { return this.id; }
public String getName() { return this.name(); }
}


public Person() {}

public SexType getSex() { return sex; }
}

and the Page as follows:

public class TestPage extends WebPage {

public TestPage() {
Form form = new Form("form", new  
CompoundPropertyModel(new Person()));
form.add(new RadioChoice("sex",  
Arrays.asList(SexType.values()), new ChoiceRenderer() {

private static final long serialVersionUID = 1L;

@Override
public String getDisplayValue(SexType sexType) {
return getString(sexType.toString());
}
}));
add(form);
}
}

Kind regards,

Mischa Dasberg

Op 14 aug 2009, om 18:43 heeft Reinout van Schouwen het volgende  
geschreven:



Hi all,

If I have an enum 'SexTypes' in the class Person like this:


 public static enum SexTypes {
   SEX_UNKNOWN(0),
   SEX_MALE(1),
   SEX_FEMALE(2),
   SEX_NOT_APPLICABLE(9);
/* Values for sex are taken from ISO 5218:1977 Representation of  
Human Sexes  */

   private final int intValue;

   SexTypes(int intValue) {
 this.intValue = intValue;
   }

   public int getIntValue() {
 return this.intValue;
   }

   public String getName() {
 return this.name();
   }
 }


...And I want to display them, localized, in a Form like this:


ChoiceRenderer renderer = new ChoiceRenderer("name", "intValue")
 {
   @Override
   public String getDisplayValue(Object object) {
 return getString((String)super.getDisplayValue(object));
   }
 };
 form.add(new RadioChoice("sex",  
Arrays.asList(Person.SexTypes.values()), renderer));

   }


...then, when the form is submitted, I get an  
IllegalArgumentException:


Caused by: java.lang.IllegalArgumentException: Cannot format given  
Object as a Number

   at java.text.DecimalFormat.format(DecimalFormat.java:504)
   at java.text.Format.format(Format.java:157)
   at  
org 
.apache 
.wicket 
.util 
.convert 
.converters 
.AbstractNumberConverter 
.convertToString(AbstractNumberConverter.java:109)
   at  
org 
.apache 
.wicket 
.util 
.lang 
.PropertyResolverConverter.convert(PropertyResolverConverter.java:84)
   at org.apache.wicket.util.lang.PropertyResolver 
$MethodGetAndSet.setValue(PropertyResolver.java:1094)
   at org.apache.wicket.util.lang.PropertyResolver 
$ObjectAndGetSetter.setValue(PropertyResolver.java:589)
   at  
org 
.apache 
.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:137)
   at  
org 
.apache 
.wicket 
.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:164)
   at org.apache.wicket.Component.setModelObject(Component.java: 
2934)
   at  
org 
.apache 
.wicket 
.markup.html.form.FormComponent.updateModel(FormComponent.java:1069)
   at org.apache.wicket.markup.html.form.Form 
$21.validate(Form.java:1866)
   at org.apache.wicket.markup.html.form.Form 
$ValidationVisitor.formComponent(Form.java:166)
   at  
org 
.apache 
.wicket 
.markup 
.html 
.form 
.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java: 
421)
   at  
org 
.apache 
.wicket 
.markup 
.html 
.form 
.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java: 
408)
   at  
org 
.apache 
.wicket 
.markup 
.html 
.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java: 
385)
   at  
org 
.apache 
.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java: 
1089)
   at  
org 
.apache 
.wicket 
.markup.html.form.Form.internalUpdateFormComponentModels(Form.java: 
1858)
   at  
org 
.apache 
.wicket.markup.html.form.Form.updateFormComponentModels(Form.java: 
1825)
   at org.apache.wicket.markup.html.form.Form.process(Form.java: 
871)
   at  
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:808)

   ... 30 moremberFormatException:


I believe this is caused because the DecimalFormat.format() method is
being passed a SexType instead of a Number object. My question is, how
can I solve this elegantly so that the radiochoice value will be
resolved to a number?

regards,

--
Reinout van Schouwen


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





Enum with RadioChoice leads to NumberFormatException

2009-08-14 Thread Reinout van Schouwen
Hi all,

If I have an enum 'SexTypes' in the class Person like this:


  public static enum SexTypes {
SEX_UNKNOWN(0),
SEX_MALE(1),
SEX_FEMALE(2),
SEX_NOT_APPLICABLE(9);
/* Values for sex are taken from ISO 5218:1977 Representation of Human Sexes  */
private final int intValue;

SexTypes(int intValue) {
  this.intValue = intValue;
}

public int getIntValue() {
  return this.intValue;
}

public String getName() {
  return this.name();
}
  }


...And I want to display them, localized, in a Form like this:


 ChoiceRenderer renderer = new ChoiceRenderer("name", "intValue")
  {
@Override
public String getDisplayValue(Object object) {
  return getString((String)super.getDisplayValue(object));
}
  };
  form.add(new RadioChoice("sex", Arrays.asList(Person.SexTypes.values()), 
renderer));
}


...then, when the form is submitted, I get an IllegalArgumentException:

Caused by: java.lang.IllegalArgumentException: Cannot format given Object as a 
Number
at java.text.DecimalFormat.format(DecimalFormat.java:504)
at java.text.Format.format(Format.java:157)
at 
org.apache.wicket.util.convert.converters.AbstractNumberConverter.convertToString(AbstractNumberConverter.java:109)
at 
org.apache.wicket.util.lang.PropertyResolverConverter.convert(PropertyResolverConverter.java:84)
at 
org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1094)
at 
org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:589)
at 
org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:137)
at 
org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:164)
at org.apache.wicket.Component.setModelObject(Component.java:2934)
at 
org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1069)
at org.apache.wicket.markup.html.form.Form$21.validate(Form.java:1866)
at 
org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form.java:166)
at 
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:421)
at 
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrderHelper(FormComponent.java:408)
at 
org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java:385)
at 
org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java:1089)
at 
org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:1858)
at 
org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:1825)
at org.apache.wicket.markup.html.form.Form.process(Form.java:871)
at 
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:808)
... 30 moremberFormatException:


I believe this is caused because the DecimalFormat.format() method is
being passed a SexType instead of a Number object. My question is, how
can I solve this elegantly so that the radiochoice value will be
resolved to a number?

regards,

-- 
Reinout van Schouwen


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org