Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 19:02 Go to next message
ivkina Mising name is currently offline ivkina Mising nameFriend
Messages: 44
Registered: April 2012
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.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.setType(new StringPropertyType());

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?

Re: How to add User Defined Property and Named Expression programmatically? [message #1002572 is a reply to message #1002521] Fri, 18 January 2013 21:25 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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);

// Add one new user-defined property definition

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

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

Current Time: Mon Jan 30 03:12:08 GMT 2023

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

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

Back to the top