如何以编程方式将 portlet 添加到 JBoss Portal 仪表板

发布于 2024-07-09 15:25:40 字数 1560 浏览 11 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为你拒绝所有暧昧 2024-07-16 15:25:40

希望这种和平的代码能有所帮助:

   //container
    container = (CustomizationManager)MBeanProxy.get(CustomizationManager.class, new ObjectName("portal:service=CustomizationManager"), MBeanServerLocator.locateJBoss());

    //transaction manager
    tm = (TransactionManager) new InitialContext().lookup("java:/TransactionManager");      

    tm.begin();

    //dashboard
    dashboard = container.getDashboard(new org.jboss.portal.identity.User() {

        public boolean validatePassword(String arg0) {
            return false;
        }

        public void updatePassword(String arg0) throws IdentityException {
        }

        public String getUserName() {
            return userId;
        }

        public Object getId() {
            return null;
        }
    });     
    System.out.println("!!! Portlal: " + dashboard.toString());

    //default page
    defaultPage = dashboard.getPage("default");
    System.out.println("!!! Page: " + defaultPage.toString());

    //gets page windows
    Collection<PortalObject> objects = defaultPage.getChildren();
    if (objects != null && objects.size() > 0) {
        for (PortalObject object : objects) {
            System.out.println("!!! PageChild: " + object.getName());
            System.out.println("!!! WindowRegion: " + object.getDeclaredProperty("theme.region"));

            String windowPortletName = object.getDeclaredProperty("portletName");

            if (StringUtils.equals(object.getDeclaredProperty("theme.region"), "column1"))
            {
                column1Windows.add(object.getName());

                System.out.println("!!! Column1Window: " + object.getName());
                System.out.println("!!! Column1WindowPortletName: " + object.getDeclaredProperty("portletName"));

                //removes from portlets list if already exists
                Iterator iterator = portlets.iterator();
                while (iterator.hasNext())
                {
                    Portlet tempPortlet = (Portlet) iterator.next();
                    if (StringUtils.equals(tempPortlet.getSystemName(), windowPortletName))
                    {
                        iterator.remove();
                    }                       
                }
            }
            else if (StringUtils.equals(object.getDeclaredProperty("theme.region"), "column2"))
            {
                column2Windows.add(object.getName());
                System.out.println("!!! Column2Window: " + object.getName());

                //removes from portlets list if already exists
                Iterator iterator = portlets.iterator();
                while (iterator.hasNext())
                {
                    Portlet tempPortlet = (Portlet) iterator.next();
                    if (StringUtils.equals(tempPortlet.getSystemName(), windowPortletName))
                    {
                        iterator.remove();
                    }                       
                }

            }
        }
    }

    tm.commit();        

Hope this peace of code helps:

   //container
    container = (CustomizationManager)MBeanProxy.get(CustomizationManager.class, new ObjectName("portal:service=CustomizationManager"), MBeanServerLocator.locateJBoss());

    //transaction manager
    tm = (TransactionManager) new InitialContext().lookup("java:/TransactionManager");      

    tm.begin();

    //dashboard
    dashboard = container.getDashboard(new org.jboss.portal.identity.User() {

        public boolean validatePassword(String arg0) {
            return false;
        }

        public void updatePassword(String arg0) throws IdentityException {
        }

        public String getUserName() {
            return userId;
        }

        public Object getId() {
            return null;
        }
    });     
    System.out.println("!!! Portlal: " + dashboard.toString());

    //default page
    defaultPage = dashboard.getPage("default");
    System.out.println("!!! Page: " + defaultPage.toString());

    //gets page windows
    Collection<PortalObject> objects = defaultPage.getChildren();
    if (objects != null && objects.size() > 0) {
        for (PortalObject object : objects) {
            System.out.println("!!! PageChild: " + object.getName());
            System.out.println("!!! WindowRegion: " + object.getDeclaredProperty("theme.region"));

            String windowPortletName = object.getDeclaredProperty("portletName");

            if (StringUtils.equals(object.getDeclaredProperty("theme.region"), "column1"))
            {
                column1Windows.add(object.getName());

                System.out.println("!!! Column1Window: " + object.getName());
                System.out.println("!!! Column1WindowPortletName: " + object.getDeclaredProperty("portletName"));

                //removes from portlets list if already exists
                Iterator iterator = portlets.iterator();
                while (iterator.hasNext())
                {
                    Portlet tempPortlet = (Portlet) iterator.next();
                    if (StringUtils.equals(tempPortlet.getSystemName(), windowPortletName))
                    {
                        iterator.remove();
                    }                       
                }
            }
            else if (StringUtils.equals(object.getDeclaredProperty("theme.region"), "column2"))
            {
                column2Windows.add(object.getName());
                System.out.println("!!! Column2Window: " + object.getName());

                //removes from portlets list if already exists
                Iterator iterator = portlets.iterator();
                while (iterator.hasNext())
                {
                    Portlet tempPortlet = (Portlet) iterator.next();
                    if (StringUtils.equals(tempPortlet.getSystemName(), windowPortletName))
                    {
                        iterator.remove();
                    }                       
                }

            }
        }
    }

    tm.commit();        
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文