Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

2840355Sep 17 2015 — edited Sep 21 2015

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?

This post has been answered by Ruben Rodriguez on Sep 18 2015
Jump to Answer

Comments

Ruben Rodriguez

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

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

Hello,

can you share your code?

JDev version?

regards,

Ruben.

2840355

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
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.

Marked as Answer by 2840355 · Sep 27 2020
2840355

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

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

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

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

Hello,

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

It improves a lot to me.

regards,

Ruben.

1 - 10
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 19 2015
Added on Sep 17 2015
10 comments
3,412 views