László van den Hoek [
http://community.jboss.org/people/laszlovandenhoek] created the
discussion
"Re: rich calender for jbpm task variable not working"
To view the discussion, visit:
http://community.jboss.org/message/618356#618356
--------------------------------------------------------------
I solved the problem using a Converter. I used this Ilya Shaikovsky's example in this
thread as a starting point:
http://community.jboss.org/message/57921#57921
http://community.jboss.org/message/57921
in faces-config.xml:
{code}
<converter>
<converter-id>calendarTimestampConverter</converter-id>
<converter-class>my.client.CalendarTimestampConverter</converter-class>
</converter>
{code}
CalendarTimestampConverter.java:
{code}
package my.client;
import java.util.Date;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
import org.apache.log4j.Logger;
public class CalendarTimestampConverter extends DateTimeConverter {
private Logger logger = Logger.getLogger(getClass());
@Override
public Object getAsObject(FacesContext arg0, UIComponent component,
String dateString) {
logger.debug("getAsObject(): " + dateString);
Object result;
try {
result = super.getAsObject(arg0, component, dateString);
if (result instanceof Date) {
//make it a Timestamp, because that is what jBPM
will make of it anyway
result = new java.sql.Timestamp(((Date)
result).getTime());
}
} catch (ConverterException ex) {
return null;
}
return result;
}
@Override
public String getAsString(FacesContext arg0, UIComponent component,
Object dateObject) {
logger.debug("getAsString(): " + (dateObject == null ? null
: (dateObject.getClass().getSimpleName() + " " + dateObject.toString())));
String result = null;
try {
result = super.getAsString(arg0, component, dateObject);
} catch (ConverterException ex) {
return null;
}
return result;
}
}
{code}
Then I simply add converter="calendarTimestampConverter" to my rich:calendar,
and presto! No more jBPM problems.
Still, this is a hack and should be fixed in jBPM, IMO.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/618356#618356]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]