<p>Hi BIRT Guru's,</p>
<p>I have blank rptdesign and all my elements are in library. I need to add the elements from library at runtime(based on parameters).</p>
<p> </p>
<p> </p>
<p>In my library i have one grid(1 row, 1 column) and a label with some text.</p>
<p> </p>
<p>I am adding the libraries at runtime to the report design and copying the elements from library to report design on onPrepare() method. When i try to add a label within a grid i am getting the below error.</p>
<p> </p>
<p> </p>
<p>onPrepare Code:</p>
<p><span style="color:#0000ff;">importPackage(Packages.org.eclipse.birt.report.model.api);<br><br>
reportContext.getDesignHandle().includeLibrary("TestLibrary.rptlibrary","TestLibrary");<br><br>
grid = reportContext.getDesignHandle().getLibrary("TestLibrary").findElement("grid1")<br>
newGrid = reportContext.getDesignHandle().getElementFactory().newElementFrom(grid,"G1");<br>
label = reportContext.getDesignHandle().getLibrary("TestLibrary").findElement("label1");<br>
newLabel = reportContext.getDesignHandle().getElementFactory().newElementFrom(label,"label2");<br><br>
//reportContext.getDesignHandle().dropLibraryAndBreakExtends(reportContext.getDesignHandle().getLibrary("TestLibrary"));<br><br>
//add label in the grid<br>
newGrid.getCell(1,1).getContent().add(newLabel);<br><br>
//add grid to the report body<br>
reportContext.getDesignHandle().getBody().add(newGrid);</span></p>
<p> </p>
<p><strong>Output Error:</strong></p>
<p><span style="color:#b22222;">Wrapped org.eclipse.birt.report.model.api.command.ContentException: Element "Grid("G1").Rows[0].Cells[0]" is child element or a virtual element( inside the child ), can not change its structure. (/report/method[
@name="onPrepare"]#11)<br>
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1245)<br>
at org.eclipse.birt.report.engine.api.impl.ScriptedDesignHandler.processOnPrepareScript(ScriptedDesignHandler.java:229)<br>
at org.eclipse.birt.report.engine.api.impl.ScriptedDesignHandler.handleOnPrepare(ScriptedDesignHandler.java:110)</span></p>
<p> </p>
<p> </p>
<p>I know that <strong>dropLibraryAndBreakExtends() </strong>will do the trick but i am not familiar in using it.</p>
<p> </p>
<p>Please help me on it.</p>
<p> </p>