-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datepicker doesn't make use of converter during encodeBegin #558
Comments
Can you provide an example? How did you define the converter? |
Oh, wait. You did specify a If you don't want to implement a new converter, would using a Date instead of a long be a quick workaround for you? |
The stacktrace is self-explanatory, one can see from the flow of the source code that no converter is being employed. Here's the markup and the converter class: ` private static final Logger LOGGER = Logger.getLogger(CalendarConverter.class.getName()); // and so on the converter is created but neither of its methods is being called. @zhedar, what do you mean by "we didn't implement this use case"? The whole story about converters is that you actually don't need to worry about different use cases, just tell me what your component expects and it's gonna be my responsibility to use proper converter. |
You're right, but I originally thought, that you maybe expected it to handle long values as well (sometimes we get those misconceptions). This looks like something, that shouldn't happen. I will have a look at this later on and maybe we can get this done this week, so it will be in the next hotfix release. |
I'll fix the code and create a pull request, in the meantime I will be using snapshot with this issue fixed, cause the project is really great and I can't wait for so long)) |
Can you already estimate when you're submitting your pull request? We're currently pondering about to release version 1.0.1, so we'd like to include your PR if you're submitting it early enough. What about next weekend? If that's too early, I guess we're going to schedule a 1.0.2, too :). |
@stephanrauh I have already fixed the code, the question now is whether the DateTimePicker component should be changed the same way. So we're talking about a day or two tops here. |
Some time ago, we've decided to call BTW, I'm sure we won't publish a new release before Sunday. So take your time. |
@stephanrauh I've fixed both components so that they now rely on provided converters. That's all I've done, no errors are now thrown on initialisation. However I had no time to perform full tests plus I was unable to ajaxify any of the two components, which means I'm reverting back to the Primefaces's Calendar or plain text input. There's another very important point I'd like to make with regard to these two components. Forcing Java(!!!) developers to stick to a date/time format of a third-party JS(!!!) library is a very bad idea, especially when it comes to date/time conversion and Faces converters in particular. How one is expected to perform that conversion? So I would rewrite the components completely so that they use normal Java's date/time formats which in turn would be used to disassemble component value and internally convert it to whatever format is required for that JS library. Developers are supposed then to specify that Java format (which then doesn't get overridden by locale settings like in DateTimePicker), or use a default one which would depend on locale in use and showDate/showTime settings. The logic of that default format should be clear to developers cause they will need to rely on it (reproduce it) when creating converters. As for the minor fixes I've made, I will create a pull request, please have a look and test it. That will fix the original issue, but, again, the internals of the two components are not ready for converters, I would even say they are disrespecting general JSF concepts. |
Hi @0swald, first of all, thank you for your contribution.. we will look at your PR asap. Another point: what do you mean when you say "I was unable to ajaxify any of the two components"? |
@asterd , the docs are saying (as far as I remember) that the format must comply with the moments one. Now imagine you were to use DateTimePicker in a situation like mine, dates are of type long (could be any type, it's up to me). Then, if DateTimePicker followed the concept "ValueHolder + Converter", the only change you would need to make in your possibly huge code is to create a new FacesConverter. And to create one, you would need a Java library for conversion between moments and your internal date/time type. That's jumping through hoops. So it shouldn't be "provide the option to use Date objects", instead it should be able to use any types in the first place (given that a converter is provided), that's just what ValueHolder and FacesConverter are about, and that's the concept that is broken. Furthermore, Faces converters are about converting between String and Object back and forth, that's why I offered to stick internally to a String format as a core of the two components. As for the ajax, the DateTimePicker is not triggering <f:ajax>, adding ajax=true and custom process/update attributes resulted in changes of internal String representation of dates and thus made it impossible to use a FacesConverter. That's where I had to stop experimenting and decided to abandon the component until it starts respecting the ValueHolder interface. |
@asterd, forgot to mention that "if you specify your format string then you can use whatevet you want" is not true, and I've already mentioned that - the provided format gets changed by locale settings, which, again, makes it impossible to use faces converters. |
@0swald, I understand your point and in this case, I think that your help on this can be a good addition to the project. I'll try to take a look at the component to follow your request.. but if you can help us, it was good! |
@asterd I will gladly join fixing the component but I can make no commitments as to the dates and releases. Besides, in this particular case, there might be a better approach: The author(s) of the component create a "test environment" consisting of a markup and two Java classes:
Then they are offered to test the component in three different ViewRoot locales: en_GB, en_US and de_DE. I bet that'd be enough to fix all the major ValueHolder issues, plus it'd take much less time than if I decided to get involved on this stage. |
It looks like it happens during component initialisation when initial value has already been given (long type in my case). Here is the stacktrace:
21-Nov-2016 23:05:41.971 SEVERE [http-nio-8080-exec-750] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [/trade-web] threw exception [Value could be either String or java.util.Date, you may want to use a custom converter.] with root cause java.lang.IllegalArgumentException: Value could be either String or java.util.Date, you may want to use a custom converter. at net.bootsfaces.component.datePicker.DatePicker.getDateAsString(DatePicker.java:462) at net.bootsfaces.component.datePicker.DatePicker.encodeHTML(DatePicker.java:353) at net.bootsfaces.component.datePicker.DatePicker.encodeBegin(DatePicker.java:192) at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:527)
The text was updated successfully, but these errors were encountered: