Forum Stats

  • 3,722,541 Users
  • 2,244,332 Discussions
  • 7,849,915 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[ADF] How to access node attributes from contextual menu?

2840355
2840355 Member Posts: 5
edited September 2015 in JDeveloper and ADF

Hi,

I work with ADF Tree component:

<af:tree value="#{bindings.TreeVO.treeModel}" var="node">
                                                    <f:facet name="nodeStamp">
                                                        <af:outputText value="#{node.Label}"
                                                                       id="nodeLabel"/>
                                                    </f:facet>
                                                    <f:facet name="contextMenu">
                                                        <af:popup id="RemoteTreePopup" childCreation="deferred"
                                                                  autoCancel="disabled">
                                                            <af:menu text="menu 1" id="m1">
                                                                <af:iterator id="i2"
                                                                             value="#{bindings.CtxMenVO.collectionModel}"
                                                                             var="element">
                                                                    <af:commandMenuItem text="#{element.Label}/#{node.Label}" ...

What I expect: when I right-click on a node (represented by the output text "node-label", a contextual menu appears with "element-label/clicked-node-label"

What I see: the output text of the node is ok, but #{node.Label} has no value in <af:commandMenuItem

How can I retrieve node.label from commandMenuItem?

Tagged:

Best Answer

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015 Accepted Answer

    Hello,

    setPropertyListener must go inside the popup.

    <af:popup id="RemoteTreePopup" childCreation="deferred" autoCancel="disabled">
        <af:setPropertyListener from="#{node.DeviceType}"  to="#{viewScope.selectedNodeDeviceType}" type="popupFetch"/>
    
    

    Also remember to use contentDelivery="lazyUncached" in the popup

    regards,

    Ruben.

Answers

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015

    Hello,

    You can try to use a setPropertyListener on poupFetch and store the value in view scope.

    <af:setPropertyListener from="#{node.label}" to="#{viewScope.selectedNodeLabel}" type="popupFetch"/>

    and

    <af:commandMenuItem text="#{viewScope.selectedNodeLabel}"/>

    If you are going to get more values store the rowData in a bean and retrieve the value that you want.

    also remember to use contentDelivery="lazyUncached" in your popup.

    The scope where you store the value has to be at least viewScope.

    regards,

    Ruben.

  • 2840355
    2840355 Member Posts: 5
    edited September 2015

    Thanks for your answer.

    Unfortunately, I have an error when using popupFetch type:

    javax.faces.view.facelets.FaceletException: ADF_FACES-60069:Aucune information methodData n''est disponible pour le type popupFetch.

    at oracle.adfinternal.view.faces.facelets.rich.SetPropertyListenerHandler.apply(SetPropertyListenerHandler.java:123)

    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)

    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)

    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:195)

    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)

    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)

    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)

    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:195)

    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)

    When I use different type, it does not work (for example “focus” or “selection”).

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015

    Hello,

    can you share your code?

    JDev version?

    regards,

    Ruben.

  • 2840355
    2840355 Member Posts: 5
    edited September 2015

    My code is a little bit different from the simplified example I gave you (node.DeviceType is data I want to display in my MenuItem):

    <af:tree value="#{bindings.TreeViewsEOView1.treeModel}" var="node"

    rendered="#{MainTreeBean.tree_is_rendered}"

    rowSelection="single" id="t1"

    focusListener="#{MainTreeBean.treeFocusListener}"

    rowDisclosureListener="#{MainTreeBean.treeRowDisclosureListener}"

    expandAllEnabled="false" displayRow="selected"

    selectionListener="#{MainTreeBean.treeSelectionListener}">

    <f:attribute name="devType" value="#{node.DeviceType}"/>

    <af:setPropertyListener from="#{node.DeviceType}"

    to="#{viewScope.selectedNodeDeviceType}"

    type="popupFetch"/>

    <f:facet name="nodeStamp">

    <af:outputText value="#{node.TreeViewName}#{node.DeviceExternalId}"

    id="nodeLabel"/>

    <af:outputText value="(#{node.CompanyId}#{node.DeviceType})"

    id="nodeDebug"/>

    <!TODO Remove when finished debugging>

    </f:facet>

    <f:facet name="contextMenu">

    <af:popup id="RemoteTreePopup" childCreation="deferred"

    autoCancel="disabled">

    <af:menu text="menu 1" id="m1">

    <af:iterator id="i2"

    value="#{bindings.CtxMenuItemEOView1.collectionModel}"

    var="rowy">

    <af:commandMenuItem text="#{vcBundle[rowy.MenuItemId]}(#{rowy.DeviceType}/#{viewScope.selectedNodeDeviceType})[#{rowy.Rendered}]"

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015 Accepted Answer

    Hello,

    setPropertyListener must go inside the popup.

    <af:popup id="RemoteTreePopup" childCreation="deferred" autoCancel="disabled">
        <af:setPropertyListener from="#{node.DeviceType}"  to="#{viewScope.selectedNodeDeviceType}" type="popupFetch"/>
    
    

    Also remember to use contentDelivery="lazyUncached" in the popup

    regards,

    Ruben.

  • 2840355
    2840355 Member Posts: 5
    edited September 2015

    It seems to work better. The only matter I still have is that I have to right-click twice on a node to make contextual menu appearing, but maybe that's another issue...

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015

    Hello,

    I didn't have that problem.

    In blog post there is a link to my github repository to download the example: rsantrod's Blog: ADF: af:tree custom context menu using selected row values

    regards,

    Ruben.

  • 2840355
    2840355 Member Posts: 5
    edited September 2015

    I've reproduced the problem with a fresh download of your github project.

    When doing right-click on a node, sometimes does not work (nothing appears, have to double-right click or label can match with previous clicked node), depending on the level of the tree you right-click on. Maybe iterator does not always refresh correctly.

    I have a video shot and logs to share if necessary.

    Maybe we have to create another post about that or document it into your github project as an issue?

    Tested on FF40.0.3 and IE11.0.9600, Windows 7.

    Weblogic integrated server in JDev Studio Edition Version 12.1.3.0.0

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015

    Hello,

    I can reproduce "When doing right-click on a node, sometimes does not work (nothing appears, have to double-right click or label can match with previous clicked node), depending on the level of the tree you right-click on. Maybe iterator does not always refresh correctly."

    It is a strange behavior. You can open a new post if you want.

    regards,

    Ruben.

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited September 2015

    Hello,

    Try with contextMenuSelect="false" property in your tree.

    It improves a lot to me.

    regards,

    Ruben.

This discussion has been closed.