Jump to content

Text/Fields Merging Expression


buiquyduc

Recommended Posts

Hi all,

Does any one know how to create a combination of text and data fields to a report like below:

..........

The first parameterized is %1 and the second is %2.

.........

Where %1 and %2 are merged fields that will be filled by data get from database.

 

Thanks in adavance.

Duc Bui

 

 



Post Edited by buiquyduc at 11/23/2010 02:33
Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

do you mean that you have a static text in your detail band?

if so it is very simple

add static text field and text fields combined together check following code...

I hope I am getting you in right direction. if not please share your jrxml and more details

Code:
			<textField>				<reportElement x="147" y="0" width="69" height="20"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{field1}]]></textFieldExpression>			</textField>			<staticText>				<reportElement x="16" y="0" width="131" height="20"/>				<textElement/>				<text><![CDATA[The first parameterized is ]]></text>			</staticText>			<textField>				<reportElement x="306" y="0" width="100" height="20"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{field2}]]></textFieldExpression>			</textField>			<staticText>				<reportElement x="216" y="0" width="100" height="20"/>				<textElement/>				<text><![CDATA[and the second is ]]></text>			</staticText>
Link to comment
Share on other sites

Hi Rajendra Tambat,

Thank you for your replies.
Sorry for my very short description the issue.
Actualy, my issue is have a text paragraph and somewhere in that paragraph, I need to fill data to that, for example, I have the sample letter below:

Dear All,

I’ve always believed that "Destiny is only by choice and not by chance" and I am glad that I chose to join %1.

If I hadn’t I would’ve missed meeting so many wonderful people, building on both personal and professional relationships and getting once in a lifetime experience.

The day has come when I have to say goodbye to a place which became my second home away from home. This eventful and joyous journey in company started on %2.

The heaven called %3 where I had the best days of my life with some of the most wonderful people of %4 batch. My heartiest thank you to my friends whom I spent most of my time with be it arguing on some topic to pulling each other’s leg ..
.......

Where %1,%2,%3,%4 are places that I need to fill from fields get from database. I assumed have fields and values
field1 = ABC
field2 = 22/12/2009
field3 = John
field4 = Development

Then the letter will be like:

Dear All,

I’ve always believed that "Destiny is only by choice and not by chance" and I am glad that I chose to join ABC.

If I hadn’t I would’ve missed meeting so many wonderful people, building on both personal and professional relationships and getting once in a lifetime experience.

The day has come when I have to say goodbye to a place which became my second home away from home. This eventful and joyous journey in company started on 22/12/2009.

The heaven called John where I had the best days of my life with some of the most wonderful people of Development batch. My heartiest thank you to my friends whom I spent most of my time with be it arguing on some topic to pulling each other’s leg ..
.......

Thanks in advance
Duc Bui



Post Edited by buiquyduc at 11/23/2010 08:08
Link to comment
Share on other sites

Good,

Still to achieive the same effect you can use textfield to draw a onle line of paragraph or a whole paragraph itself

and in expression of it you can simply use $F{Field1} which will automatically get replaced.

 

try below code in your text field expression replace values of field1 and filed2 appropriately

Code:
"The heaven called "+$F{Field1} +" where I had the best days of my life with some of the most wonderful people of " + $F{Field2} +" batch. My heartiest thank you to my friends whom I spent most of my time with be it arguing on some topic to pulling each other’s leg "
Link to comment
Share on other sites

Hi Rajendra Tamba,

Thank you very much about your replies.

 

One more question related to this topic.

In case of content is styled from RTF file, how do I fill values ?  The content like below:

 

Dear All,

I’ve always believed that "Destiny is only by choice and not by chance" and I am glad that I chose to join ABC.

If I hadn’t I would’ve missed meeting so many wonderful people, building on both personal and professional relationships and getting once in a lifetime experience.

The day has come when I have to say goodbye to a place which became my second home away from home. This eventful and joyous journey in company started on 22/12/2009.

The heaven called John where I had the best days of my life with some of the most wonderful people of Development batch. My heartiest thank you to my friends whom I spent most of my time with be it arguing on some topic to pulling each other’s leg ..

 

 

Thanks,
Bui Quy Duc



Post Edited by buiquyduc at 01/24/2011 04:06
Link to comment
Share on other sites

  • 2 months later...

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...