Hi Donald,
I'd recommend reading in the URL via ConfigurationManager (or in 6.x and
newer, the DSpaceConfigurationService) and reading the label in from the
i18n Messages file so it can be translated if needed.
In 5.x and previous, you could import org.dspace.core.ConfigurationManager
in StatisticsTransformer and use it where the other static strings are
created, like
private static final String T_link_feedback_url =
ConfigurationManager.getProperty("xmlui.statistics.feedback_url");
or in 6.x+, import org.dspace.services.factory.DSpaceServicesFactory and
use it much the same way
private static final String T_link_feedback_url =
DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("xmlui.statistics.feedback_url");
And read in a message key from the i18n messages.xml files like:
private static final Message T_label_feedback_url =
message("xmlui.statistics.feedback_label");
Now these values can be fed into the Xref, using addContent() instead of
passing the second parameter because the constructor itself expects a
String, not a Message:
valListRow.addCell("02", Cell.ROLE_DATA,
"datacell").addXref(T_link_feedback_url).addContent(T_label_feedback_url);
In dspace.cfg with the other XMLUI properties (or in a local customised cfg
file under $dspace/config/modules/), you could put
xmlui.statistics.feedback_url = http://www.mycustomurl.com
And in the XMLUI i18n messages.xml file(s), add
<message key="xmlui.statistics.feedback_label">Click to see
feedback</message>
Regarding the target attribute, I know that that third value passed in is
technically a "rendering hint" rather than strictly a class, but I'm not
sure exactly how rendering hints get processed and added as classes later
on the chain - that might be a place where you could make Xref (or wing
elements generally) be more clever by using rendering hints to create
target attribute if appropriate.
Hope this helps!
Cheers
Kim
On Tuesday, January 10, 2017 at 8:13:37 AM UTC+13, Donald Bynum wrote:
>
> I am running DSpace 5.5 with XMLUI. I am making some customizations to
> the StatisticsTransformer java module. I am hoping to crack two nuts with
> this post/question. I have written my own version of the procedure
> "addDisplayListing". I want to be able to render a custom hyperlink. So,
> I know that I need to use the addXref function. I'd like to have the
> target URL as a string in some config file somewhere (like messages.xml).
> I'd also like to be able to have the target URL open in a new browser
> winder (i.e. setting the "target" attribute of the resulting <A></A> tag),
>
> Currently, in order to render the <A></A> tag content, I have:
>
> valListRow.addCell("02", Cell.ROLE_DATA, "datacell").addXref("
> http://mySpecialURL.com", "Click to see feedback");
>
> This results in <A href="http://mySpecialURL.com">Click to see
> feedback</A>
>
> Q1. So, how/where can I make "http://mySpecialURL.com" configurable so
> that I don't have to do a special build for dev and another for test and
> another for prod?
>
> Q2. I know that there is version of addXref with a third parameter, but
> that results in setting the "class" attribute of the <A></A> tag (there is
> no way in CSS to target a new browser window - if there were, this would be
> the solution). So, is there some way of injecting the "target" attribute
> into the resulting <A></A> tag?
>
> Best regards,
>
> Don.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.