Jump to content
We've recently updated our Privacy Statement, available here ×

Help needed in using Custom Element Property


skulaz

Recommended Posts

Hi Guys,
I'm trying to force the size of a single text element of my jasper print using the Custom Element Property
"net.sf.jasperreports.default.font.size"


But the result never changes.
I've seen, debugging the source code 
that in the class JRProperties 
there is this method called by JRBaseFiller at line 400:

..............
    public static List getProperties(JRPropertiesMap propertiesMap, String prefix)
    {
        int prefixLength = prefix.length();
        List values = new ArrayList();
        if (propertiesMap != null)
        {
            String[] propertyNames = propertiesMap.getPropertyNames();
            for (int i = 0; i < propertyNames.length; i++)
            {
                String name = propertyNames;
                if (name.startsWith(prefix))
                {
                    String suffix = name.substring(prefixLength);
                    String value = propertiesMap.getProperty(name);
                    values.add(new PropertySuffix(name, suffix, value));
                }
            }
        }
        return values;
    }
.........


debugging the code line in red i see that it expects in the name of my custom property
a string like this net.sf.jasperreports.export.
So I added this string in the name of my attribute changing the attribute name in "net.sf.jasperreports.export.net.sf.jasperreports.default.font.size"
and i successfully entered that if  construct, but the output result remains the same: the font for the elements is the default (10px).
Do you have any suggestion about this problem?
I'm using jasper 3.0.0
Thanks in advance.
Bye


Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

skulaz
Wrote:

I'm trying to force the size of a single text element of my jasper print using the Custom Element Property
"net.sf.jasperreports.default.font.size"

This property can only be set globally (per system), as stated in the configuration reference, and will not have any effect when set at report element level.

You should use the fontSize text attribute instead.

Regards,

Lucian

Link to comment
Share on other sites

You can set different font sizes for different rows, but the font size cannont be fully dynamic.  What you can do is to define a style that contains conditional styles with different font sizes (see below).

What you cannot do is to use an expression as font size.

Regards,

Lucian

Code:
<style>  <conditionalStyle>    <conditionExpression>$F{field}.equals("big")</conditionExpression>    <style fontSize="20"/>  </conditionalStyle>  <conditionalStyle>    <conditionExpression>$F{field}.equals("medium")</conditionExpression>    <style fontSize="14"/>  </conditionalStyle>  <conditionalStyle>    <conditionExpression>$F{field}.equals("small")</conditionExpression>    <style fontSize="20"/>  </conditionalStyle></style>
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...