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

Dynamic attribute


pedro.riky

Recommended Posts

 Hi all

         i have my application that use Jasper to print a document, the user can decide row for row the font and the size of the text.

         is there the possibility to substitute the attribute of a reportElement?

         I want something like this :

     


              <textField isBlankWhenNull="true" isStretchWithOverflow="true">
                          <reportElement positionType="FixRelativeToTop" x="0" y="0" width="505" height="8"                    
                                   isPrintWhenDetailOverflows="true" style="mystyle"  isPrintInFirstWholeBand="true">
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Top">
                    <font size="@mysize"/>
                </textElement>
                <textFieldExpression class="java.lang.String">
                    <![CDATA[$F{titolo}]]>
                </textFieldExpression>
            </textField>
    

 

any idea?

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 weeks later...

Hi Frank

thanks for the answer, i try but i'm not able to use it.

 

I have my default style

   
       </conditionalStyle>
   </style>

 

the field is

 <field name="rowstyle" class="java.lang.String">
       <fieldDescription><![CDATA[@rowstyle]]></fieldDescription>
       </field>

 

and my data is

 

 

<totale titolo="2) costi di ricerca, di sviluppo e di pubblicita`;" rowstyle="D" font-size=""
       font-type="" text-align="" testo-sostitutivo=""/>

 

 

What is wrong?

the only font is used is my default.

Link to comment
Share on other sites

I am facing a similar situation, where I would like to parameterize the RGB value of a foreground color on various text elements. My experiement so far seems to indicate that my values are being ignored. For example:

        <parameter name="rgb_value" class="java.lang.String" isForPrompting="false">                <defaultValueExpression><![CDATA[new String("#FF0000")]]></defaultValueExpression>        </parameter>

Which is then referenced later in the JRXML file as forecolor:

        <staticText>            <reportElement style="default" x="434" y="569" width="166" height="38" forecolor="$P{rgb_value}"/>            <textElement/>            <text><![CDATA[investigate the market in quartiles - where each quartile is 25% of homes ordered by price.]]></text>         </staticText>

When the report is rendered, this text is displayed as black, not red (#FF0000).

I could do a conditional style for every possible color option, but that would be very tedious. Is there any other way to use a parameter value $P{variable_name} as the value of an attribute?



Post Edited by jbuberel at 11/15/2011 23:54
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...