Jump to content
JasperReports Library 7.0 is now available ×

Accessing "Sub" objects


JohnL

Recommended Posts

Lets say I have two classes FirstObject and OtherObject (defined below), and lets say I'm going to pass a collection of FirstObject to my report.

 

How can I call the equivalent of getOtherObject().getOtherString() in my report template?

 

Can I use more complicated objects that have other objects as members, maybe even a list that I can use in the detail part of the template?

if not is there a way to convert an object to XML and use XML in my template?

 

Any tips would be very appreciated

 

public class FirstObject

{

 

public FirstObject()

{ }

 

private String one;

private OtherObject otherObject;

 

 

public String getOne()

{

return one;

}

 

public void setOne(String one)

{

this.one = one;

}

 

public OtherObject getOtherObject()

{

return otherObject;

}

 

public void setOne(OtherObject otherObject)

{

this.otherObject = otherObject;

}

}

 

public class OtherObject

{

 

public OtherObject()

{ }

 

private String otherString;

 

 

public String getOtherString()

{

return otherString;

}

 

public void setOne(String otherString)

{

this.one = one;

}

}

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Well I got part 1 solved. It kind of hurts when you see how simple it is.

<field name="tailObj" class="java.lang.String">

<fieldDescription>

<![CDATA[otherObject.otherString]]>

</fieldDescription>

</field>

 

but still what about even more complicated objects? Can someone point me in the right direction?

 

One more thing: before you start to think I should put SQL/HQL in my report I'll need to tell you that that will not be permitted in my environment. I'll only have access to "pre-populated" classes.

 

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...