Home
Analytics
Access Footer Master Page
smgomes
Hi,
I recently had need to access the footer (Masterpage) programatically using API...
I tried for this method :
SimpleMasterPageHandle master = (SimpleMasterPageHandle) design.getMasterPages().getElementHandle();
Iterator<SlotHandle> itSlot = master.getPageFooter().getContents().iterator();
while (itSlot.hasNext()){
Object object = itSlot.next();
if (object instanceof GridHandle){
< MY CODE>
}
}
...but without success =(
Can you help me access the footer programatically? At my ".rtpdesign" i'm using only one MasterPage.
Thanks!
Find more posts tagged with
Comments
mwilliams
From script inside the report, it's something like:
reportContext.getDesignHandle().getMasterPages().get(0).getSlot(1);
This grabs the footer slot. Then, say if you wanted to drop the default date element that is in the footer, you'd do:
reportContext.getDesignHandle().getMasterPages().get(0).getSlot(1).drop(0);
What are you trying to do?
smgomes
Hi,<br />
<br />
thanks for the reply, it helped me a lot !<br />
<br />
I need to do by using the JAVA API, and used this method :<br />
<br />
Iterator<SlotHandle> iteratorObject = design.getMasterPages().get(0).getSlot(1).getContents().iterator();<br />
<p class='bbc_indent' style='margin-left: 40px;'>while (iteratorObject.hasNext()){</p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>Object shContents = iteratorObject.next();</p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>if (shContents instanceof GridHandle){</p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>GridHandle grid = (GridHandle) shContents;</p></p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>SlotHandle grRows = grid.getRows();</p></p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><MYCODE: Iterate over the Grid Cells></p></p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><strong class='bbc'>if (cellContents instanceof DataItemHandle)</strong>{</p></p></p>
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>MYCODE: To verify if exists</p></p></p></p>
<br />
My goal is to make sure the bottom of all the templates (placed on the clients) there is a specific DataItemHandle. <br />
<br />
There is an easier way to find out whether a particular DataItemHandle exists in the template? Anything like : design.getBody().getAllDataItems()...<br />
<br />
Iterate the tables one by one cell and the cell search is a very complicated, even more complicated when we have a table inside another table ...<br />
<br />
Thanks.
mwilliams
If you were to give the element a name, you could look up the element by its name. If null is returned, it doesn't exist. Something like:
reportContext.getDesignHandle().findElement("myElement");
smgomes
Thanks for the reply.
I knew this function... The problem is my element has no name :S I never used this feature in BIRT...
There is a function that return me all the elements of a given type ? (GridHandle, TableHandle, DataItemHandle)... help me greatly if there ...
Thanks
mwilliams
If your element doesn't have a name, how are you going to determine that the element is indeed in the report?
This might allow you to grab all the elements:
reportContext.getDesignHandle().getDesign().getAllElements();
smgomes
Hi, <br />
<br />
I do not have this function
, i'm using BIRT 3.7.1.<br />
<br />
<img src='
https://lh4.googleusercontent.com/-QIy5D7PnkBY/T00bFpUwxbI/AAAAAAAAB18/G-AXBgoXMMY/s800/All3.jpeg'
alt='Posted Image' class='bbc_img' /><br />
<br />
I tried using it but without success :<br />
<br />
Iterator<VariableElementHandle> itVariable = design.getAllVariables().iterator();<br />
while (itVariable.hasNext()){<br />
VariableElementHandle varElement = itVariable.next();<br />
System.out.println("VALUE : " + varElement.getValue());<br />
}<br />
<br />
Thanks
mwilliams
Since you're not naming the element, how are you determining if the element is the element you're looking for when you grab its handle?
smgomes
Hi,
if I can have access to the element can test through the expression, anything like :
if (dataItem.getResultSetColumn() == "<myCode>" ) {
...
}
but do not have access to this function through the Java API :
reportContext.getDesignHandle().getDesign().getAllElements();
really need for a solution to this
Thanks
smgomes
<blockquote class='ipsBlockquote' data-author="'smgomes'" data-cid="96998" data-time="1330516930" data-date="29 February 2012 - 05:02 AM"><p>
Hi, <br />
<br />
if I can have access to the element can test through the expression, anything like : <br />
<br />
if (dataItem.getResultSetColumn() == "<myCode>" ) {<br />
...<br />
}<br />
<br />
but do not have access to this function through the Java API : <br />
reportContext.getDesignHandle().getDesign().getAllElements();<br />
<br />
really need for a solution to this
<br />
<br />
Thanks<br /></p></blockquote>
<br />
I found this funtion : <strong class='bbc'>design.getModuleHandle().getModule().getAllElements();</strong><br />
<br />
and tried this:<br />
<br />
Iterator iterator = design.getModuleHandle().getModule().getAllElements().iterator();<br />
while (iterator.hasNext()){<br />
<p class='bbc_indent' style='margin-left: 40px;'>Object object = iterator.next();<br />
if (object instanceof DataItemHandle){</p>
<br />
<p class='bbc_indent' style='margin-left: 40px;'><p class='bbc_indent' style='margin-left: 40px;'>System.out.println("DataItem Founded!!");<br />
<br />
DataItemHandle dataItem = (DataItemHandle) object;<br />
System.out.println("Nome : " + dataItem.getName());<br />
System.out.println("Display Name : " + dataItem.getDisplayName());<br />
System.out.println("Display Label : " + dataItem.getDisplayLabel());<br />
System.out.println("Expression : " + dataItem.getResultSetColumn());</p></p>
<br />
<br />
But still doesn't work
The message "DataItem Founded" never appears, it fails in "if condition"<br />
<br />
Can you help me?Thanks
mwilliams
How deeply embedded can this element possibly be? Will it sometimes be the only element within the footer? Or will it always be embedded in a grid cell? Will it ever go further than that? Embedded within a grid, within the main grid? This can all be done by stepping through the grid cells after grabbing the masterpage footer, but it'd definitely be easier if you knew it would always be on the first level inside the main grid. I'll look at the AllElements() some more, too.