• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem with conversion

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was following a tutorial on doing conversion. If I enter in something wrong, it's supposed to display my error message I think, but instead I get a stacktrace error.

Here is my code:


Here's what I get if I intentionally make a mistake:
 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you register CircleTypeConverter as the type converter for Circle class??
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. It works fine if I type everything correctly. If I intentionally make a mistake though, it gives that error.
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any ideas?
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Updates:

I forgot an INPUT result type. Now I put it in, and it returns back to the offending JSP page. It still throws a stack trace and the field error it returns is some default field error, not one that I specified.

The first field error it threw was from my global properties file:
xwork.default.invalid.fieldvalue

I commented that out, and then it just returned a generic error message.

1) I would like a stack trace to not be thrown
2) I would like the message that I specify in my code to be shown:
 
Ankit Garg
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It works fine if I type everything correctly. If I intentionally make a mistake though, it gives that error.


I'm still not getting this statement. What are you trying to say here. The stack trace says that Struts is looking for a setCircle(String[]) method in your CustomConverterTest class which means that your conversion class was not called. Can you show us how you've configured CircleTypeConverter as a custom type converter...
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the file CustomConverterTest-conversion.properties:

circle=converters.CircleTypeConverter

I'm not really sure how to make it more clear. If I type in a string, that I would like to convert to a Circle object, and I type in the string correctly (as in, its in the correct syntax/format that my converter expects) then it works. If I type in the string incorrectly (wrong format or syntax) then I see that stack trace AND instead of the field errors that I pass as parameters to the TypeConversionException, I get generic error messages.
 
    Bookmark Topic Watch Topic
  • New Topic