unplugged / unplugged-controls

7 stars 9 forks source link

unpComputedNav needs an object element for url parameter #498

Closed RichSharpe closed 10 years ago

RichSharpe commented 10 years ago

Is it possible that a url parameter can be added to the link in the Navigator? Real world scenario: I have links in the computedNav pointing to the same XPage and I need to pass in the cat filter. I can't do this with a sessionScope var.

Workaround: Added this to the unpComputedNav manually but as hard coded objects for now.

whitemx commented 10 years ago

This is already possible.

Here's an example of a computed nav that uses URL parameters:

var filter = context.getUrlParameter('filter');
var names = ['Claire Jones', 'Fred Bloggs', 'Jane Doe', 'John Smith', 'Richard Wright'];
var out = [];
for (var i=0; i<names.length; i++){
    var obj = {};
    obj.label = names[i];
    obj.hasSubMenu = false;
    obj.page = '/UnpDemoCalendarFilter.xsp?filter=' + @ReplaceSubstring(names[i], ' ', '%20') + '&';
    if (names[i] == filter){
        obj.state = 'Active';
    }else{
        obj.state = 'Inactive';
    }
    obj.ajaxloadid = "contentwrapper";
    obj.ajaxtargetid = "content";
    out.push(obj);
}
return out;