I want to create a macro in velocity with a date as macro-parameter.
In the object of WikiMacroParameterClass with the name “someDate” I put as parameter type “java.util.Date”.
Inserting the macro in a page with WYSIWYG Editor I can double-click the macro and then fill the field of someDate. The Date-Picker ist working fine. So far, so good.
The problem is:
I can’t access the value of the choosen date in the macro code via wikimacro.parameters.someDate
The following macro-code
I think the problem is that the date converter (which is used to convert the String you provide into a Date object) does not use the same format (“M/d/yy” from what I understand) than what is produced by the date picker right now and the wiki macros just ignore failed conversions it seems.
Thank you very much for your reply. Do you consider it as a bug that should be repaired? Or do you think there’s no solution to adapt the converter to the Date Picker and thereby allow to use wikimakro.parameter?
Otherwise the consequence would be that one has to decide between using the Date Picker or the binding via wikimakro.
The alternative via xcontext.macro.param is not recommended, isn’t it?
I found a workarround, but I don’t know if it’s more recommendable than xcontext:
With this solution I receive the value from the Date Picker as an object of Type Date. The same solution would work with xcontext.macro, perhaps more straight forward, but seems to be deprecated.
The fact that the default displayer associated to macro parameters of type Date is not compatible with the Date converter is definitely a bug, yes. Would be great if you could create a BUG issue for that situation on Loading....
It’s definitely less deprecated than the xcontext based solution, so I would recommend it with a comment explaining why you used it and linking to the jira issue.