views:

362

answers:

1

I managed to get the jquery portlet working on my JSP with java backend, using this example as a starting point: http://jqueryui.com/demos/sortable/#portlets

for each portlet, i need to add an additional icon on the portlet header, depending on whether the user has permission on that portlet. so its something like

$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
.find(".portlet-header")
    .addClass("ui-widget-header ui-corner-all")
    .prepend('<span class="ui-icon ui-icon-plusthick"></span>')
    /* if user has permission for this portlet */
    .prepend('<span class="ui-icon ui-icon-pencil"></span>')
    .end()
.find(".portlet-content");

$(".portlet-header .ui-icon-pencil").click(function() {
    alert($(this).parents('.portlet').attr('id'))
/* go to a specific page for this portlet */
});

my question is a little basic - what is the best way for each portlet to pass that info to jquery ? passing parameter? (if so, how?) hidden divs? i haven't used jquery long enough to know the best way.

A: 

As its generalized for all portlets and UI related best place to implement it is Theme/Skin.

Best way to implement this IMHO is as follows

  • Each Portlet will have Preference field : privilege
  • Admin will set value for "privilege " (who has rights example 'admin')
  • Implement logic for displaying header icon in Skin/Theme. Where it will get preferences for particular portlet and check against it.And display header icon accordingly.
Rutvij Shah