Jump to content
Changes to the Jaspersoft community edition download ×

Adding a hyperlink on a textField w/ java


2004 IR Help

Recommended Posts

By: Guillaume Dupont - guigounet

Adding a hyperlink on a textField w/ java

2005-04-05 11:09

Hello,

 

I need to add a hyperlink to a textField using Java. Using the setHyperlinkReferenceExpression method I tried the following code:

 

// adding hyperlink

expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("http://www.google.com");

 

// setting the type of hyperlink

Map hyperlinkTypeMap = JRXmlConstants.getHyperlinkTypeMap();

byte type = ((Byte)(hyperlinkTypeMap.get("Reference"))).byteValue();

 

// adding the hyperlink to the textField

textField.setHyperlinkType(type); textField.setHyperlinkReferenceExpression(expression);

 

But this returns the following error:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: [...]TrackingTemplateJasperReport.java:136: ')' expected

value = (java.lang.String)(http://www.google.com);

 

If I switch "java.lang.String" to "java.net.URL", i get another error saying "java.net.URL" is not supported.

 

How can I do to add a hyperlink to a textField with java?

 

Thanks,

 

Guillaume

 

 

 

 

 

 

 

 

By: Bernard Tran - tbtran

RE: Adding a hyperlink on a textField w/ java

2005-05-13 11:29

Hey Guillaume, do this:

 

expression.setText(""http://www.google.com"";);

 

Anytime you're adding text to an Expression manually, you must do it this way.

 

B. Tran

 

 

 

 

By: Bernard Tran - tbtran

RE: Adding a hyperlink on a textField w/ java

2005-05-13 11:31

Oops typo, minus the two semi-colons.

 

expression.setText(""http://www.google.com"");

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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