Skip to main content



      Home
Home » Archived » BIRT » How to add User Defined Property and Named Expression programmatically?
How to add User Defined Property and Named Expression programmatically? [message #1002521] Fri, 18 January 2013 14:02 Go to next message
Eclipse UserFriend
hello,
we are struggling to find the right code using Design Engine API to add User Defined Property and Named Expressions to an element:
....
DataItemHandle control = (DataItemHandle) elementFactory.newDataItem("COLUMN1");
control.setResultSetColumn("COLUMN1");

control.setProperty("MyProperty", "test");
control.setExpressionProperty("MyExpression", new Expression("\"test\"", ExpressionType.JAVASCRIPT));

....


Both setProperty() and setExpressionProperty() throw exceptions that the property name is invalid. Looks like you have to add it first - I found addUserPropertyDefn() method for simple properties but even after I add the property:
UserPropertyDefn p = new UserPropertyDefn();
p.setName("MyProperty");
p.setType(new StringPropertyType());
control.addUserPropertyDefn(p);

control.setProperty("MyProperty", "test"); throws another exception saying that value type is invalid...

And I cannot find any API method that would allow you to add a NamedExpression as opposed to User Defined Property. Could somebody who knows API help with that?

Thanks,
Alexey
Re: How to add User Defined Property and Named Expression programmatically? [message #1002572 is a reply to message #1002521] Fri, 18 January 2013 16:25 Go to previous message
Eclipse UserFriend
Try something like:

MetaDataDictionary dd = MetaDataDictionary.getInstance( );
PropertyType strType = dd.getPropertyType( PropertyType.STRING_TYPE );

UserPropertyDefn newPropDefn = new UserPropertyDefn( );
newPropDefn.setName( "myProp4" ); //$NON-NLS-1$
newPropDefn.setType( strType );

PropertyType expType = dd.getPropertyType( PropertyType.EXPRESSION_TYPE );

UserPropertyDefn newNamedDefn = new UserPropertyDefn( );
newNamedDefn.setName( "myNamedExpression" ); //$NON-NLS-1$
newNamedDefn.setType( expType );
Expression expr = new Expression("\"test\"", ExpressionType.JAVASCRIPT);
newNamedDefn.setDefault(expr);



// Add one new user-defined property definition

table.addUserPropertyDefn( newPropDefn );
table.addUserPropertyDefn( newNamedDefn );

Jason
Previous Topic:How to eliminate the outline of a meter chart?
Next Topic:crosstab dimension drilldown
Goto Forum:
  


Current Time: Tue Mar 18 01:12:16 EDT 2025

Powered by FUDForum. Page generated in 0.02825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top