I need to write a simple customization bean for a dynamic view panel so dates will always be displayed as yyyy-MM-dd but I have no clue which method to overwrite and how to modify my value so it shows what I want.
Any starter code would be apprciated (and yes, I looked at Jesse's code and it is way too complex for what I want to achieve).
Thanks
Edit: This now the code I have in my customization bean, but it does absolutely nothing...
public class DynamicViewCustomizerBean_Ben extends DominoViewCustomizer {
public static class ExtendedViewColumnConverter extends ViewColumnConverter {
@Override
public String getValueAsString(final FacesContext context, final UIComponent component, final Object value) {
if(value instanceof DateTime) {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return fmt.format(value);
}
if(value instanceof Date) {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
return fmt.format(value);
}
// for other cases, just return super
return super.getValueAsString(context, component, value);
}
}
}
And yes, the name of my customization bean is set properly on my Dynamic view panel:
<xe:dynamicViewPanel id="dynamicViewPanel1"
showColumnHeader="true"
customizerBean="com.videotron.xpages.DynamicViewCustomizerBean_Ben"
var="rowData">
...
Am I missing something? Is it the good event that is being overridden? I'm asking because if I set a value of "test" instead of the fmt.format(), it doesn't even show up. Nothing in the logs, no visible errors... I can't seem to find a working example of this on the web...
In the ExtendedViewColumnConverter.getValueAsString(FacesContext, UIComponent, Object)
method of your customizer bean you need to return the desired value if the value object is a Date instance.
Here's a simple example:
if (value instanceof Date) {
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
return fmt.format(value);
}