سؤال

A small question regarding mind map and the select event in primefaces.

Here is my component

        <h:form>
            <prime:mindmap value="#{artifactSelectionBackingBean.root}"
                style="width:100%;height:600px;border:1px solid black;"
                rendered="#{artifactSelectionBackingBean.visibleMindmap}">
                <prime:ajax event="select"
                    listener="#{artifactSelectionBackingBean.onNodeSelect}" />
                <prime:ajax event="dblselect"
                    listener="#{artifactSelectionBackingBean.onNodeDblselect}"
                    update="output" oncomplete="details.show()" />
            </prime:mindmap>

            <prime:dialog widgetVar="details" header="Node Details"
                resizable="true" modal="true" showEffect="fade" hideEffect="fade">
                <h:outputText id="output"
                    value="#{artifactSelectionBackingBean.selectedNode.data}" />
            </prime:dialog>
        </h:form>

Now the other methods are exactly copy/pasted from the show case (http://www.primefaces.org/showcase/ui/mindmap.jsf). The behavior is that the mind map renders (w/ the correct root and start-up configuration), however, the "select" event doesn't do anything and the "double select" returns an empty box. What am I doing wrong? This has been copied directly from the show case after all...

Also, I am using primefaces 3.5. Any help is appreciated!!!

P.S. I know I added a rendered attribute, but it is "true" since I set it correctly and the mindmap renders correctly at the beginning.

هل كانت مفيدة؟

المحلول

OK! I finally found the answer as I was browsing through stackoverflow through all sorts of mindmap/primefaces related problems and desperately trying to apply any solution.

Apparently, the ManagedBean/Named bean (if you use CDI) must be @SessionScoped and NOT @RequestScoped (which is by default). If it is @RequestScoped you get peculiar behavior and certain events (in my case the "select" event) do NOT fire.

I do not know whether this is a bug or is carefully omitted out of the documentation. However, someone should document it explicitly!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top