task.setParameterValue [message #831080] |
Wed, 28 March 2012 08:50  |
Eclipse User |
|
|
|
Hi! I have a problem.
I want set param on xml, its Date type. Date Format: yyyy-MM-dd
And I see interested error
Quote:
SEVERE: org.eclipse.birt.report.engine.api.impl.ParameterValidationException: The type of parameter "DateParameter" is expected as "date", not "java.util.Date".
fragment code
if (p.type.equals(Param.TYPE_DATE))
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
formatter.setLenient (false);
try
{
Date date = formatter.parse(Date2SQL(p.value));
task.setParameterValue(paramName, date);
}
catch (Exception Ex)
{
//
}
fragment xml
<scalar-parameter name="DateParameter" id="98">
<text-property name="promptText">Дата</text-property>
<property name="valueType">static</property>
<property name="dataType">date</property>
<property name="distinct">true</property>
<simple-property-list name="defaultValue">
<value type="constant">2001-12-31</value>
</simple-property-list>
<list-property name="selectionList"/>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
|
|
|
|
Re: task.setParameterValue [message #832187 is a reply to message #831603] |
Thu, 29 March 2012 18:02   |
Eclipse User |
|
|
|
The Date parameter should be able to take a java.sql or java.util date.
Can you post the complete stack trace?
Jason
On 3/29/2012 12:56 AM, Sergey Syr wrote:
> Interested moment
> thats void, continue..
> if (p.type.equals(Param.TYPE_DATE_TIME))
> { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
> formatter.setLenient (false);
> try
> {
> Date date = formatter.parse(p.value.replaceAll(p.value.substring(0, 10),
> Date2SQL(p.value.substring(0, 10))));
> task.setParameterValue(paramName,date);
> }
> catch (Exception Ex)
> {
> //
> } //
> }
>
> This fragment work!
>
> I see my changed DataTime parameter on report form
>
> p.value - String parameter value from enter form
> Date2SQL - formated String from "dd.MM.yyyy" to "yyyy-MM-dd"
> (p.value.replaceAll(p.value.substring(0, 10),
> Date2SQL(p.value.substring(0, 10)))) - formated String from "dd.MM.yyyy
> HH:mm" to "yyyy-MM-dd HH:mm"
>
>
>
> what do you think about IScalarParameterDefn.TYPE_DATE ?
|
|
|
|
|
Re: task.setParameterValue [message #836124 is a reply to message #835714] |
Wed, 04 April 2012 01:08   |
Eclipse User |
|
|
|
DateTime type mismatching for Date parameter, because working another handler
DateTime type working totally normal.
if (p.type.equals(Param.TYPE_DATE_TIME))
{
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy HH:mm");
formatter.setLenient (false);
try
{
Date date = formatter.parse(p.value);
task.setParameterValue(paramName,date);
}
catch (Exception Ex)
{
//
}
//
}
if (p.type.equals(Param.TYPE_DATE))
{
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
formatter.setLenient (false);
try
{
Date date = formatter.parse(p.value);
task.setParameterValue(paramName, date);
}
catch (Exception Ex)
{
//
}
}
if (p.type.equals(Param.TYPE_DECIMAL))
{
Double n = Double.parseDouble(p.value.replace(',', '.'));
task.setParameterValue(paramName, n);
}
if (p.type.equals(Param.TYPE_INTEGER))
{
task.setParameterValue(paramName, (new Integer(p.value)));
}
//...etceteras, and so forth, and so on...
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09279 seconds