Hippo CMS: Create an extra menu item in Content Images section

108 views
Skip to first unread message

Daniel Sequeira

unread,
Nov 25, 2015, 5:59:56 AM11/25/15
to Hippo Community

Hi guys,

So today I found this little tutorial on your website: http://www.onehippo.org/library/concepts/plugins/menu-plugin.html that explains how to create an extra menu item for the Content Documents section of Hippo CMS.

Can you help me on how to do the same for the Images section?

Cheers,
Daniel Sequeira

Minos Chatzidakis

unread,
Nov 25, 2015, 9:32:26 AM11/25/15
to Hippo Community
Hi Daniel,

I think this is not supported currently. I did some research however and I could find 2 ways to do it, however I cannot recommend neither of them. They feel more of a hack than proper solutions. But here they are:
  1. Extend or override the wicket plugin used to render the context menu for gallery section. This plugin is org.hippoecm.frontend.plugins.standardworkflow.FolderWorkflowPlugin and registered in /hippo:configuration/hippo:workflows/threepane/image-gallery/frontend:renderer/plugin.class. The class is not easily extensible.

  2. Alternatively, try the following:
    a. Follow the documentation page you found ([1]) to the letter. Make sure this is working exactly as it should before going to the next step. Don't take shortcuts, do exactly what is mentioned in the doc page
    b. Then replace node at /hippo:configuration/hippo:workflows/threepane/image-gallery/frontend:renderer with /hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer 
I think option 2 is better than 1, but I cannot give any guarantees about side effects. To me it seems to work just fine. But keep in mind this is not supported officially. The trick is done by using the ListViewPlugin, see /hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer/root/plugin.class. This class reads the list of plugins defined under the frontend:renderer node and invokes each plugin.

[1] http://www.onehippo.org/library/concepts/plugins/menu-plugin.html

Hope this helps!
Minos
--


--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 745 Atlantic Ave, Eight Floor, MA 02111

Daniel Sequeira

unread,
Nov 25, 2015, 10:29:05 AM11/25/15
to Hippo Community

Hi Minos,

First of all thanks for your reply.

So I did exactly as you said, but I ended up with the new menu item duplicated, in the Documents section and now in the Images section also.

My doubt is, after replacing the node at /hippo:configuration/hippo:workflows/threepane/image-gallery/frontend:renderer with /hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer should I keep the three create-index nodes that the tutorial asks at /hippo:configuration/hippo:workflows/threepane/folder-permissions/frontend:renderer,
/hippo:configuration/hippo:workflows/threepane/folder-extended/frontend:renderer and
/hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer?

Best,
Daniel

Minos Chatzidakis

unread,
Nov 25, 2015, 11:13:01 AM11/25/15
to Hippo Community
On Wed, Nov 25, 2015 at 4:29 PM, Daniel Sequeira <daniel....@getbynder.com> wrote:

Hi Minos,

First of all thanks for your reply.

So I did exactly as you said, but I ended up with the new menu item duplicated, in the Documents section and now in the Images section also. 

Duplicate? You mean the "create-index" menu item appears twice in the context menu? 
 

My doubt is, after replacing the node at /hippo:configuration/hippo:workflows/threepane/image-gallery/frontend:renderer with /hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer should I keep the three create-index nodes that the tutorial asks at /hippo:configuration/hippo:workflows/threepane/folder-permissions/frontend:renderer,
/hippo:configuration/hippo:workflows/threepane/folder-extended/frontend:renderer and
/hippo:configuration/hippo:workflows/threepane/folder/frontend:renderer?

No, don't keep it unless you need it. In general, you only need to add the "create-index" menu item wherever you need it. So, simply remove it from the renderers you don't need it.

The important thing here is that with this approach we're changing the renderer used for the gallery to one that is dynamic (using the ListViewPlugin as mentioned in my previous reply)

Hope it's more clear now
Minos
--

Daniel Sequeira

unread,
Nov 27, 2015, 4:04:24 AM11/27/15
to Hippo Community

Hi again Minos,

Since option 2 didn't really worked as I expected for what I want to achieve, I tried option 1: "Extend or override the wicket plugin used to render the context menu for gallery section. This plugin is org.hippoecm.frontend.plugins.standardworkflow.FolderWorkflowPlugin and registered in /hippo:configuration/hippo:workflows/threepane/image-gallery/frontend:renderer/plugin.class. The class is not easily extensible."

So I created this class:

public class BynderGalleryPlugin extends FolderWorkflowPlugin {


    private static final long serialVersionUID = 1L;


    public BynderGalleryPlugin(final IPluginContext context, final IPluginConfig config) {

        super(context, config);


        add(new StdWorkflow<FolderWorkflow>("id",

                new StringResourceModel("id", this, null),

                getModel()) {


            private static final long serialVersionUID = 1L;


            @Override

            protected Component getIcon(final String id) {

                HippoIconStack iconStack = new HippoIconStack(id, IconSize.M);

                PackageResourceReference reference = new PackageResourceReference(getClass(), "bynder-logo-crop.png");

                iconStack.addFromResource(reference);

                return iconStack;

            }


            @Override

            protected Dialog createRequestDialog() {

                return new org.hippoecm.frontend.dialog.Dialog<>();

            }

        });

    }


}


My goal for now is to try to open a Dialog when I click this extra menu item. The problem is I'm getting these exceptions when I click it:

[INFO] [talledLocalContainer] 27.11.2015 10:00:49 ERROR http-nio-8080-exec-10 [DefaultExceptionMapper.mapUnexpectedExceptions:170] Unexpected error occurred

[INFO] [talledLocalContainer] org.apache.wicket.WicketRuntimeException: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at org.hippoecm.addon.workflow.MenuLink$2@5fa272e5 on component [MenuLink [Component id = link]] threw an exception

[INFO] [talledLocalContainer] at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268)

[INFO] [talledLocalContainer] at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241)

[INFO] [talledLocalContainer] at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:250)

[INFO] [talledLocalContainer] at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236)

[INFO] [talledLocalContainer] at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:890)

[INFO] [talledLocalContainer] at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)

[INFO] [talledLocalContainer] at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)

[INFO] [talledLocalContainer] at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)

[INFO] [talledLocalContainer] at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)

[INFO] [talledLocalContainer] at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

[INFO] [talledLocalContainer] at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)

[INFO] [talledLocalContainer] at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)

[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)

[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

[INFO] [talledLocalContainer] at org.hippoecm.frontend.plugins.login.ConcurrentLoginFilter.doFilter(ConcurrentLoginFilter.java:54)

[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)

[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)

[INFO] [talledLocalContainer] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)

[INFO] [talledLocalContainer] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

[INFO] [talledLocalContainer] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)

[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)

[INFO] [talledLocalContainer] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)

[INFO] [talledLocalContainer] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)

[INFO] [talledLocalContainer] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)

[INFO] [talledLocalContainer] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)

[INFO] [talledLocalContainer] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)

[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

[INFO] [talledLocalContainer] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745)

[INFO] [talledLocalContainer] Caused by: java.lang.reflect.InvocationTargetException

[INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

[INFO] [talledLocalContainer] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:497)

[INFO] [talledLocalContainer] at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)

[INFO] [talledLocalContainer] ... 32 more

[INFO] [talledLocalContainer] Caused by: java.lang.NullPointerException

[INFO] [talledLocalContainer] at org.hippoecm.addon.workflow.StdWorkflow.invoke(StdWorkflow.java:216)

[INFO] [talledLocalContainer] at org.hippoecm.addon.workflow.ActionDescription.run(ActionDescription.java:92)

[INFO] [talledLocalContainer] at org.hippoecm.addon.workflow.MenuItem$1.onClick(MenuItem.java:50)

[INFO] [talledLocalContainer] at org.hippoecm.addon.workflow.MenuLink$2.onEvent(MenuLink.java:86)

[INFO] [talledLocalContainer] at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:146)

[INFO] [talledLocalContainer] at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:633)

[INFO] [talledLocalContainer] ... 37 more


Do you know what might be the problem?

Thanks for your time!

Daniel Sequeira

Minos Chatzidakis

unread,
Nov 27, 2015, 7:23:29 AM11/27/15
to Hippo Community
Hi Daniel,

No I don't know what exactly is causing this, but looking into the StdWorkflow, at line 216 it reads:

pluginContext.getService(IDialogService.class.getName(), IDialogService.class).show(dialog);

Did you debug this? Did you find what is giving you the NPE? I'm noticing that you don't pass the context variable to the constructor of your StdWorkflow so perhaps it's that.

The second approach I mentioned in my email (replacing the renderer nodes) worked fine when I tried it, I got no duplicates or other issues. And it's way more recommended than extending the FolderWorkflowPlugin. I'm wondering what didn't work when you tried it. In your last email you mentioned that the item appeared as duplicate in the Documents section but if that's true then you're actually saying that the documentation page you followed didn't really work for you. So I'm thinking that perhaps you missed some step or that the documentation page is wrong (probably it's not wrong cause I followed it as well and it worked).

cheers,
Minos
--

Reply all
Reply to author
Forward
0 new messages