-
1. Re: rich calender for jbpm task variable not working
laszlovandenhoek Jul 20, 2011 3:05 AM (in response to peterbasutkar)I'm using the jBPM 3.2.10 packaged with JBoss SOA Platform 5.1, but on all other points you are describing exactly the same problem I'm having.
The problem does not occur the first time you enter a value in the rich:calendar (that is, you are not overwriting any previously registered process variables). Therefore, I suspect the problem is that jBPM persists this initial Date through the underlying DbPersistenceService, and then the next time you retrieve the value from the database, it is wrapped in a java.sql.Timestamp and rich:calendar trips over it.
This gives rise to two possible solutions: either make the DbPersistenceService return a java.util.Date, or make rich:calendar properly handle java.sql.Timestamp values.
-
2. Re: rich calender for jbpm task variable not working
laszlovandenhoek Jul 29, 2011 10:57 AM (in response to laszlovandenhoek)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
in faces-config.xml:
{code:xml}
<converter>
<converter-id>calendarTimestampConverter</converter-id>
<converter-class>my.client.CalendarTimestampConverter</converter-class>
</converter>
{code:xml}
CalendarTimestampConverter.java:
{code:java}
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:java}
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.