extLib / appllicationLayout: how can I define link node to open a page in a new tab? - xpages

using extLib's applicationLayout control I'd like to place a link to a different application inside the bannerApplicationLinks node. This basically works fine using a basicLeafNode if it wasn't for the fact that the other application opens in the same browser tab. There apprently isn't any way to set the target for any kind of linking node control.
Before I go ahead and rebuild layout and navigator from scratch so that I can use standard link controls: does probably someone know some kind of well-kept secret how I could accomplish this task the simple way?
This limitation btw. applies to all types of link node elements available from extLib...

It doesn't look like this is easy to add. Unlike normal links, the basicLeafNode does not seem to have a target attribute. If it did, a theme would allow you to set the default value of the target to "_new".
If you want to try extending the basicLeafNode, the code for the component is in com.ibm.xsp.extlib.controls plugin, com.ibm.xsp.extlib.tree.complex.ComplexLeafTreeNode. You would need to add a target property and also expose it in the configuration files in com.ibm.xsp.extlib.config package (extlib-outline_en.properties, extlib-outline.xsp-config and raw-extlib-outline.xsp-config.
The link is written in the renderEntryItemContent method in com.ibm.xsp.extlib.renderkit.html_extended.outline.tree.HtmlTagsRenderer (bear in mind that this covers other link classes, not all of which will have a target attribute).

The best option you have is to use CSS (for targeting) and CSJS in the onLoad event to add the target attribute to the links. In the onLoad you select all links with a specific class (or all links inside a named element) and add the target "_blank" attribute.

Related

Accessing properties across pages in AEM HTL (Sightly)

I have a carousel component, whose slide content will be the content from another page, accessed via reference component. I want to get some properties authored in the carousel to be accessible inside the referenced page. i.e. I have Page A- with a Carousel accessing PageB through reference component. I want to get proeprties from PageA in PageB. Can this be achieved?
Sure it can, you will need to lookup/query the content and find pages where PageB is included, then get the properties of those pages (there might be more than one) and merge them. It will have to be custom code though as this is not available out-of-the-box as of AEM 6.3.
The solution could be adding a query parameter or setting a request parameter. But then again, this depends on the requirement. For me, this worked!!

Proper Kentico object for non-user-editable block of static html/javascript

The Situation: I've got a mid-sized chunk of html/javascript that contains an authentication script/input (it's a text input, radio control, and a combo box and a few buttons). What it is is less important than the concept that it's a mass of static client side code that the marketing department can pretty easily accidentally the whole thing.
The Desire: I want the users to be able to add it as a whole to a page, but not be able to modify it. When something needs to change, I want to change it in one place and have it be changed on all the pages.
What I've Tried: Widget with a default text. It works, but feels wrong. Users can edit it, and if they do when I fix it one place it doesn't propagate to all the instances. I'm a bit of a Kentico noob, but it seems like there should be a better way to do this.
Also note: I'm using portal engine if that makes a difference.
A widget is the proper usage. What you make your widget inherit from is the key in this case. I'd suggest creating a new widget based on a static HTML webpart. This way you can set the static HTML markup and hide the property from the content editor on the front end. You can do this by going to the Properties tab of the widget and setting the visibility of the field on the form. Don't delete the field, just hide it. It should be a checkbox that says hide on public form or editing form.
** Edit **
As I read through my answer and comments, I realized I meant to say clone the static HTML webpart and set its default text to your javascript. Then create a widget based on that cloned webpart. The text will reside in the web part and will allow you to update it in one place later, if needed.
I will not do it this way because you will be not able to make changes in the future. You can better create a new webpart this can be an empty webpart and then create a custom layout. In this layout you can put you're code. In this way you can always change you're code in the future and then it will be changed on all the places where the widget is placed.
I'd use a new widget based on the Static HTML webpart (make the field read only or hide it as Brenden mentioned), but store the data in a new custom setting.
no coding needed (only a macro to read the custom setting)
able to edit the script on the fly on any instance in the settings module. If you have multiple of these settings you won't need to go through all kinds of widgets to adjust their default setting but find them on a central place.
Cheers!
David
In this case I think it makes sense to create a custom web part to store all your code in it and use it that way. If you want to achieve it without creating a custom web part, you have to store the code in some non-web part and not widget specific object. I like the suggestion of creating a custom setting. You can then access this custom setting via a macro. This macro can be used as a default property of a newly created web part (inherited e.g. from the static text web part, you'd use the text property). You may as well create a widget out of it. Another approach is to use Kentico localization keys as a workaround. you can create a key in the Localization application and access it again, via a macro, e.g. {?customkey.myhtml?}. The approach with a custom setting however sounds cleaner to me.
This syntax should be working to access a custom setting value via macro:
{%Settings.CustomSettings.xxx%}
{%Settings.CustomSettings["xxx"]%}
{%Settings.CustomSettings.GetValue("xxx")%}

Is there a way to use a javascript object as a custom control property?

I'm currently building a custom control to be used as an application's view navigator (classic OneUI style). First of all: this is a 8.5.3 based project, and unfortunately there's no way to use Extlib stuff or other extensions / plug-ins. So we have to build all the tricky stuff ourselves using only what came "out-of-the-box" with 8.5.3.
I'd llike to build my navigator using a repeat control containing <xp:link> controls. Datasource could be an array of javascript objects where each single object would look like this:
var navEntry = {"entryLabel" : "label-of-link",
"entryTarget" : "target-url-of-link",
"entryStyle" : "style-to-emphasize-selected-link"}
Each array element then would describe a single navigator entry.
Since the navigator will be used in all possible "DominoView" Xpages it yould make sense to build the array of JS objects at the Xpage level and then pass that info into the custom control.
I'm aware that there are multiple ways to do this, and one could be "Custom Control Properties". If there was a way to pass my JS object array.
(Hope I could make clear what I'm trying to do here...)
That object looks like a HashMap to me really. You should be able to pass that in to a custom control via custom property if you use the type java.util.HashMap I'd think. You'll need to type it in I'm sure. I've passed custom objects in by using java.lang.Object.
The custom control will get loaded during the Page Load event, and usually properties have to be available at that point. If they're loaded during the Render Response phase, that's too late. So your SSJS object will need to be Compute on Page Load.
To use contents of a repeat control, you would need to set repeatControls=true, otherwise the repeat is only built during render response. Until then it's just a single set of controls with no data in them. However, Im pretty sure repeatControls="true" means you only get the number of rows you define. You can't change it via a pager.
You can manually define the type of the custom property. For a standard SSJS Object you use "com.ibm.jscript.std.ObjectObject", for a SSJS Array you use "com.ibm.jscript.std.ArrayObject" etc. As editor for the custom property, I set the string editor ("String value").

Adding item to all view menus

In Eclipse, it is possible to extend to any pop-up menu using the following special location URI:
popup:org.eclipse.ui.popup.any
Is it possible to do the same for the view menus (the little triangle in each view)? (I am developing an Eclipse RCP application, not extending the IDE. The purpose for this item is to help debugging and testing of the application.).
The short answer: no, that is not possible, unless you add the items by hand for all views.
The slightly longer answer: yes, if you
manually go through the view registry
create a new AbstractContributionFactory with the location URI "menu:<view-id>" and whatever createContributionItems(...) you want for each. (Alternatively you can create AbstractMenuAdditionCacheEntry or even better MenuAdditionCacheEntry - though these are internal and requires a little extra work... The last allows you to have a centrally defined menus extension point that is used for all these additions.)
add these to the workbench using IMenuService.addContributionFactory(AbstractContributionFactory factory) (use IWorkbenchWindow.getService(IMenuService.class) to acquire the menu service).
I haven't tested the above recipe, but I have used something very similar in an application...

How can a graphic be placed in the OneUI .lotusBanner area using the Application Layout Control

I am using the Extension Libraries Application Layout Control and need to have a banner graphic placed in the .lotusBanner div on the right. How can this be done as it seems that the Application Layout Control can't be modified.
You could use the utilityLinksFacet on the extended control that Steve Pridemore did.
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&documentId=CED2E61A75526CD086257997006DA95B
or you could use onload javascript to add it.
I was able to place a graphic in the upper right of the Application Layout Control in the Banner area by doing the following:
In the control under the Banner > Utility links I added a Basic node. For the node I specified the href and image. This worked and placed the image n the correct spot.
Artifacts of this were the location of the Banner Application links. To remedy this I used some CSS for the .lotusBanner ul.lotusLinks {margin-top: 45px;position:absolute;}
The margin-top was to push the links down so I could enlarge the logo that is used by the Application Layout Control.
The applicationLayout control in ExtLib is, as you have found out, locked down to only allow certain aspects of the configuration to be changed by the developer. You can add links to different sections of the applicationLayout but nothing beyond that.
One possible alternative is to NOT use the applictionLayout control itself but create your own approximation of it in a custom control, You would need to add all the necessary panels/divs with the special oneUI2 classes in all the correct places and then add editable areas and callbacks within these panels for the parts that you would want to customize throughout the application. All of the other sections in the applicationLayout control, like the bannerUtilityLinks are created using the ListofLinks control that is also found in the Extension Library.

Resources