on 2016 Aug 24 5:29 PM
Hi Experts,
we have to display some date attributes for entities in a ExtendedMultiReferenceEditor (https://help.hybris.com/6.1.0/hcd/8bab997f86691014852cfbeabd21a5c8.html).
Things work flawlessly except we weren't able to find out how to configure the date format. In fact we would only need the date (without time or time zone) both for output as well as input.
This requirement can be done easy be fulfilled for the default date editor (see https://help.hybris.com/6.1.0/hcd/8baaee208669101492bbcf156de5928f.html), but couldn't find anything for extended multi reference editor.
Thanks, Best Regards, Norbert
Request clarification before answering.
Hi Norbert,
In order to change displaying value, you have two options:
Changing base configuration for java.util.Date and creating your own LabelProvider:
cockpit-config.xml:
context type="java.util.Date" component="base">
<y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:labels beanId="dateLabelProvider"/>
</y:base>
</context>
spring-config.xml
import com.hybris.cockpitng.labels.LabelProvider;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateLabelProvider implements LabelProvider<Date>
{
@Override
public String getLabel(final Date object)
{
return new SimpleDateFormat("MM-dd-yyyy").format(object);
}
@Override
public String getDescription(final Date object)
{
return "";
}
@Override
public String getIconPath(final Date object)
{
return "";
}
}
The second option is providing your own DateListCellRenderer:
public class DateListCellRenderer extends AbstractWidgetComponentRenderer<Listcell, ListColumn, Object>
{
private WidgetRenderingUtils widgetRenderingUtils;
@Override
public void render(Listcell listcell, ListColumn configuration, Object o, DataType dataType, WidgetInstanceManager widgetInstanceManager) {
final String qualifier = configuration.getQualifier();
final QualifierLabel label = getWidgetRenderingUtils().getAttributeLabel(o, dataType, qualifier);
final String formattedDate = ""; // do sth with label
listcell.setLabel(formattedDate);
}
public WidgetRenderingUtils getWidgetRenderingUtils()
{
return widgetRenderingUtils;
}
@Required
public void setWidgetRenderingUtils(final WidgetRenderingUtils widgetRenderingUtils)
{
this.widgetRenderingUtils = widgetRenderingUtils;
}
}
spring-config.xml
<bean id="dateListCellRenderer" class="com.hybris.training.renderer.DateListCellRenderer" >
<property name="widgetRenderingUtils" ref="widgetRenderingUtils"/>
</bean>
cockpit-config.xml:
<list-view:column qualifier="startTime" spring-bean="dateListCellRenderer"/>
Unfortunately, AFAIK it's not possible to change (configure) dateEditor for extendedMultiReferenceEditor
Regards,
Łukasz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
22 | |
17 | |
4 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.