Logo
My activities
Submit a Ticket >

Toll Free: 1.877.776.2995

Form a Hyperlink Using Groovy

In order to form a hyperlink against a field using groovy, we have a method which will give output as a link provided in the groovy.

Below is a sample.

public String getObjectDisplayValue(Object object, Object attributeObject, String attributeId, String attributeType, boolean isInEditModel) {
if ("customAttributes.string3".equalsIgnoreCase(attributeId) && "customLink".equals(attributeType)) {
if (super.isNullOrEmptyValue(attributeObject)) {
return "N/A";
} else
 return "<a href='http://www.agiliance.com' target='_blank'>" +                               super.getObjectDisplayValue(attributeObject)+ "</a>";
     }

   return super.getObjectDisplayValue(attributeObject);
  }
}

This hyperlink formation will get blocked if ESAPI Validatior.URL properties file(C:\Server\Tomcat\webapps\spc\WEB-INF\classes\esapi)) does not have characters provided in the hyperlink. So to allow this we have to add those characters in Validatior.URL properties file.

By replacing the below property will make sure to by pass all the characters that URL might have.

#Validator.URL=^(ht|f)tp(s?)\\:\\/\\/[0-9a-zA-Z ]([-.\\w]*[0-9a-zA-Z ])*(:(0-9)*)*(\\/?)([a-zA-Z0-9 \\-\\.\\?\\,\\:\\'\\/\\\\\\+_={}&amp;%\\$#ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüŸ¡¿çÇŒœßØøÅåÆæÞþÐ𶧥«»’„”“”–€œŒ ]*)?$

replaced by

Validator.URL=^.*$

Please make sure there should be no space after $.

Follow
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request
Powered by Zendesk