top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Custom error message per converter

0 votes
323 views

Is it possible to configure a custom error message per converter? For example I have this in my xwork-conversion.properties:

java.util.Date=mx.com.afirme.midas2.converter.DateConverter

Whenever a Date conversion fails in any action I'd like to show a message like this:

Incorrect format, expected mm/dd/yyyy

I don't want to define a custom message per property as mentioned in the documentation:

http://struts.apache.org/release/2.3.x/docs/type-conversion.html

"However, sometimes you may wish to override this message on a per-field basis. You can do this by adding an i18n key associated with just your action (Action.properties) using the pattern invalid.fieldvalue.xxx, where xxx is the field name."

posted May 22, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Could you show source code of your DateConverter?
Sure.

public class DateConverter extends StrutsTypeConverter {
 @SuppressWarnings("rawtypes")
 public Object convertFromString(Map context, String[] values, Class toClass) {
 if (values != null && values.length > 0 && values[0] != null &
 try {
 return sdf.parse(values[0]);
 }
 catch(ParseException e) {
 throw new TypeConversionException(e);
 }
 }
 return null;
 }
 @SuppressWarnings("rawtypes")
 public String convertToString(Map context, Object o) {
 if (o instanceof Date) {
 SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
 return sdf.format((Date)o);
 }
 return "";
 }
}

1 Answer

0 votes

Conversion errors are always reported with a default message defined in the xwork.default.invalid.fieldvalue (Invalid field value for field "xxx", where xxx is the field name) but what I want is a way to be more specific depending of the type. For example for java.math.BigDecimal a custom message for java.lang.Integer another message and so on and if no custom message is found the default is showed.

answer May 23, 2013 by anonymous
Similar Questions
0 votes

I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it.

0 votes

I am using Apache 2.2 on LE for several years now and I use intensively the virtual host mechanism (300 virtual hosts per http instance).

As soon as you start sharing resources between applications, you want to protect your platform and prevent an application from taking all the threads and cause a resource starvation for the others.

To do so i used the third party mod_qos module to limit the number of simultaneous connections per virtual hosts. Now that i intend to migrate to Apache 2.4, my first tests reveal that this module is not compatible with this version of Apache, thats also the warning that developer raised for his module.

It appears that I don't find any real alternative to substitute the mod_qos module with something else. Here are my questions :
- Can you confirm that Apache does not provide any mechanism allowing to limit the number of connection per virtual host, just to be sure that I am not missing something ?
- Why Apache doesn't provide such a functionality ? :) From my very humble user perspective, I am surprised that this is not a native functionality as it seems to me that my need is probably shared by many users. Moreover Apache provides many other complex functionalities, the one I am describing would be probably something simple to implement compared to other functionalities already available.

+1 vote

We have a set up like Apahce (80,443) redirects the request to Tomcat (8080) using mod_jk.

The new requirement is to route the request from the same apache to another tomcat (8090). Hence I made the different config file for apache with different ports (86,4444) and different worker for mod_jk which routes the request to tomcat.

Now the issue is when I hit the url http://:86 and after providing the credentials, it is redirecting to https://:86 and throwing the below error.

Error in browser:

Secure Connection Failed

An error occurred during a connection to x.x.x.x:86. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

Error in logs:

"x16x03x01" 501

[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_io.c(1523): OpenSSL: I/O error, 11 bytes expected to read on BIO#1bf568 [mem: 1f3930]
[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_kernel.c(1806): OpenSSL: Exit: error in SSLv2/v3 read client hello A
[Thu Jan 08 08:22:46 2015] [info] (70014)End of file found: SSL handshake interrupted by system [Hint: Stop button pressed in browser?!]
[Thu Jan 08 08:22:46 2015] [info] Connection to child 3 closed with abortive shutdown(server pritoolvca1.sw.ericsson.se:443 [2], client 153.88.164.216)
[Thu Jan 08 08:23:53 2015] [error] [client 172.17.136.153] Invalid method in request x16x03x01

Could you please suggest where it might went wrong and the way forward..

+1 vote

Need some help here, want to replace the standard 503 page of Apache with my custom maintenance page. Read some blogs which gives direction of replacing the page with my html page and just do some rewrite of URL to display it.with help of .htaccess.

I am not able to find the .htaccess file on the server, could some one please help me on that, where is htaccess file by default on the server.

Could some body also suggest if there is any other solution to achieve maintenance page.

...