I would like to add an URL fragment #top to a HtmlOutcomeTargetLink, but cant figure out how. For an HtmlOutputLink I just use the following:
HtmlOutputLink link = new HtmlOutputLink();
String urlWithFragment = url + "#top";
link.setValue(urlWithFragment);
How to acomplish this for a HtmlOutcomeTargetLink?
Unfortunately the following does not work:
HtmlOutcomeTargetLink link = new HtmlOutcomeTargetLink();
String urlWithFragment = context.getViewRoot().getViewId() + "#top";
link.setOutcome(urlWithFragment);
Thanks for your help!
The
outcomeofHtmlOutcomeTargetLink(the<h:link>) only takes navigation case outcomes, not URLs. The navigation case outcomes do not support URL fragments. Those needs to be set as a separatefragmentattribute.See also:
<h:link>tag documentationUpdate: wait, there’s no setter for that on the
UIOutcomeTargetparent class. I suspect an oversight in the generated code (funnily it’s mentioned here in Mojarra snapshot docs and here in a MyFaces testcase). You should be able to set it directly on the attribute map: