AW: Override the JSF Standard Converter for java.util.Date.class
Hi Thomas, I checked it already. Myfaces and mojarra behave in the same way. In my code @FacesConverter does not affect the behaviour. Thanks, Georg Tel: E-Mail: devn...@safir-wid.de Internet: https://www.safir-wid.de safir Wirtschaftsinformationsdienst GmbH Sitz der Gesellschaft: Möllendorffstr.49, 10367 Berlin Geschäftsführer: Thilo Kind Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681 USt-ID: DE 193584747 -Ursprüngliche Nachricht- Von: Thomas Andraschko Gesendet: Montag, 16. November 2020 11:00 An: MyFaces Discussion Betreff: Re: Override the JSF Standard Converter for java.util.Date.class Hi, i think @FacesConverter should work the same as #addConverter. Could you do us a favor, and check if Mojarra does the same as MyFaces? Am Mo., 16. Nov. 2020 um 10:48 Uhr schrieb DevNews : > Hallo, > > in order to convert inputs in h:inputtext from the WebPage to the > class java.util.Date JSF uses the standard converter > javax.faces.convert.DateTimeConverter. > We would like to change this standard converter to my own imlementation. > So we would not be forced to add a converter-id to every h:inputtext > binded to a date-member. > > Reason for the custom converter: > We use a database that cannot persist dates before the year 1753 and > after the year . We would like to prevent the user writing such > dates already from the webpage. > > Because we have to deliver the app to different customers we deploy to > WildFly13/mojarra 2.2 and WebSphhere 9.0/myfaces 2.2. > > > According to my investigation I created a own converter class and > annotated it like this: > > @FacesConverter(forClass = java.util.Date.class) public class > MyDateConverter extends DateTimeConverter { > > But in this way the standard converter used by jsf was not changed. > > > Then I added manually my own converter to the Application in an post > construct method of an application scoped bean, that is created > directly with the first request to my application: > > @PostConstruct > void initAppBean() > { > FacesContext.getCurrentInstance().getApplication().addConverter(java.u > til.Date.class, "de.safir.web.jsf.converter.MyDateConverter"); > > Now the standard converter used by jsf is set to my own class. > > > My question: > > Is this the approriate way to change the standard converter class? > > > Thanks, > > Georg > > > > Tel: > E-Mail: devn...@safir-wid.de > Internet: https://www.safir-wid.de > > safir Wirtschaftsinformationsdienst GmbH Sitz der Gesellschaft: > Möllendorffstr.49, 10367 Berlin > Geschäftsführer: Thilo Kind > Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681 > USt-ID: DE 193584747 > > > > > -- > This email was Malware checked by UTM 9. http://www.sophos.com > -- This email was Malware checked by UTM 9. http://www.sophos.com
Re: Override the JSF Standard Converter for java.util.Date.class
Hi, i think @FacesConverter should work the same as #addConverter. Could you do us a favor, and check if Mojarra does the same as MyFaces? Am Mo., 16. Nov. 2020 um 10:48 Uhr schrieb DevNews : > Hallo, > > in order to convert inputs in h:inputtext from the WebPage to the class > java.util.Date > JSF uses the standard converter javax.faces.convert.DateTimeConverter. > We would like to change this standard converter to my own imlementation. > So we would not be forced to add a converter-id to every h:inputtext binded > to a date-member. > > Reason for the custom converter: > We use a database that cannot persist dates before the year 1753 and after > the year . We would like to prevent the user writing such dates already > from the webpage. > > Because we have to deliver the app to different customers we deploy to > WildFly13/mojarra 2.2 and WebSphhere 9.0/myfaces 2.2. > > > According to my investigation I created a own converter class and > annotated it like this: > > @FacesConverter(forClass = java.util.Date.class) > public class MyDateConverter extends DateTimeConverter > { > > But in this way the standard converter used by jsf was not changed. > > > Then I added manually my own converter to the Application in an post > construct method of an application scoped bean, that is created directly > with the first request to my application: > > @PostConstruct > void initAppBean() > { > FacesContext.getCurrentInstance().getApplication().addConverter(java.util.Date.class, > "de.safir.web.jsf.converter.MyDateConverter"); > > Now the standard converter used by jsf is set to my own class. > > > My question: > > Is this the approriate way to change the standard converter class? > > > Thanks, > > Georg > > > > Tel: > E-Mail: devn...@safir-wid.de > Internet: https://www.safir-wid.de > > safir Wirtschaftsinformationsdienst GmbH > Sitz der Gesellschaft: Möllendorffstr.49, 10367 Berlin > Geschäftsführer: Thilo Kind > Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681 > USt-ID: DE 193584747 > > > > > -- > This email was Malware checked by UTM 9. http://www.sophos.com >
Override the JSF Standard Converter for java.util.Date.class
Hallo, in order to convert inputs in h:inputtext from the WebPage to the class java.util.Date JSF uses the standard converter javax.faces.convert.DateTimeConverter. We would like to change this standard converter to my own imlementation. So we would not be forced to add a converter-id to every h:inputtext binded to a date-member. Reason for the custom converter: We use a database that cannot persist dates before the year 1753 and after the year . We would like to prevent the user writing such dates already from the webpage. Because we have to deliver the app to different customers we deploy to WildFly13/mojarra 2.2 and WebSphhere 9.0/myfaces 2.2. According to my investigation I created a own converter class and annotated it like this: @FacesConverter(forClass = java.util.Date.class) public class MyDateConverter extends DateTimeConverter { But in this way the standard converter used by jsf was not changed. Then I added manually my own converter to the Application in an post construct method of an application scoped bean, that is created directly with the first request to my application: @PostConstruct void initAppBean() { FacesContext.getCurrentInstance().getApplication().addConverter(java.util.Date.class, "de.safir.web.jsf.converter.MyDateConverter"); Now the standard converter used by jsf is set to my own class. My question: Is this the approriate way to change the standard converter class? Thanks, Georg Tel: E-Mail: devn...@safir-wid.de Internet: https://www.safir-wid.de safir Wirtschaftsinformationsdienst GmbH Sitz der Gesellschaft: Möllendorffstr.49, 10367 Berlin Geschäftsführer: Thilo Kind Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681 USt-ID: DE 193584747 -- This email was Malware checked by UTM 9. http://www.sophos.com