0

我设法让 jquery portlet 在我的带有 java 后端的 JSP 上工作,使用这个例子作为起点:http: //jqueryui.com/demos/sortable/#portlets

对于每个 portlet,我需要在 portlet 标题上添加一个附加图标,具体取决于用户是否具有该 portlet 的权限。所以它就像

$(".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 */
});

我的问题有点基本 - 每个 portlet 将该信息传递给 jquery 的最佳方式是什么?传递参数?(如果是这样,如何?)隐藏的div?我使用 jquery 的时间还不够长,无法知道最好的方法。

4

1 回答 1

0

因为它对所有 portlet 和 UI 相关的最佳实现位置进行了概括,所以它是 Theme/Skin。

实现此恕我直言的最佳方法如下

  • 每个 Portlet 都有 Preference 字段:privilege
  • 管理员将为“特权”设置值(谁拥有权限示例“管理员”)
  • 实现在皮肤/主题中显示标题图标的逻辑。它将在哪里获得特定 portlet 的首选项并对其进行检查。并相应地显示标题图标。
于 2010-01-30T02:55:39.503 回答